bwh-auth 0.5.0 → 0.6.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.
package/dist/index.cjs CHANGED
@@ -37,19 +37,27 @@ __export(index_exports, {
37
37
  PasskeySection: () => PasskeySection,
38
38
  PasswordResetRequestForm: () => PasswordResetRequestForm,
39
39
  ResetPasswordForm: () => ResetPasswordForm,
40
+ ScopePicker: () => ScopePicker,
40
41
  SignupForm: () => SignupForm,
41
42
  TwoFactorForm: () => TwoFactorForm,
42
43
  arrayBufferToBase64url: () => arrayBufferToBase64url,
43
44
  authenticateWithPasskey: () => authenticateWithPasskey,
44
45
  base64urlToArrayBuffer: () => base64urlToArrayBuffer,
46
+ closeImplications: () => closeImplications,
45
47
  describeDuration: () => describeDuration,
46
48
  getCsrfToken: () => getCsrfToken,
47
49
  getDefaultPasskeyName: () => getDefaultPasskeyName,
50
+ inCatalogOrder: () => inCatalogOrder,
48
51
  isAbortError: () => isAbortError,
49
52
  isConditionalMediationAvailable: () => isConditionalMediationAvailable,
53
+ neededBy: () => neededBy,
50
54
  registerPasskey: () => registerPasskey,
51
55
  relyingApplicationsFrom: () => relyingApplicationsFrom,
52
- safeApplicationHref: () => safeApplicationHref
56
+ restrictImplications: () => restrictImplications,
57
+ safeApplicationHref: () => safeApplicationHref,
58
+ sameSelection: () => sameSelection,
59
+ withScopes: () => withScopes,
60
+ withoutScopes: () => withoutScopes
53
61
  });
54
62
  module.exports = __toCommonJS(index_exports);
55
63
 
@@ -999,25 +1007,314 @@ function relyingApplicationsFrom(value) {
999
1007
  }
1000
1008
 
1001
1009
  // src/api-credentials-section.tsx
1010
+ var React6 = __toESM(require("react"), 1);
1011
+
1012
+ // src/scope-picker.tsx
1013
+ var import_lucide_react3 = require("lucide-react");
1002
1014
  var React5 = __toESM(require("react"), 1);
1015
+
1016
+ // src/scope-selection.ts
1017
+ function closeImplications(implications) {
1018
+ const closed = {};
1019
+ for (const key of Object.keys(implications)) {
1020
+ const seen = /* @__PURE__ */ new Set();
1021
+ const walk = (id) => {
1022
+ for (const needed of implications[id] ?? []) {
1023
+ if (needed !== key && !seen.has(needed)) {
1024
+ seen.add(needed);
1025
+ walk(needed);
1026
+ }
1027
+ }
1028
+ };
1029
+ walk(key);
1030
+ if (seen.size > 0) {
1031
+ closed[key] = [...seen];
1032
+ }
1033
+ }
1034
+ return closed;
1035
+ }
1036
+ function restrictImplications(implications, offered) {
1037
+ const result = {};
1038
+ for (const [key, needed] of Object.entries(implications ?? {})) {
1039
+ if (!offered.has(key) || !Array.isArray(needed)) {
1040
+ continue;
1041
+ }
1042
+ const kept = needed.filter((id) => offered.has(id));
1043
+ if (kept.length > 0) {
1044
+ result[key] = kept;
1045
+ }
1046
+ }
1047
+ return result;
1048
+ }
1049
+ function inCatalogOrder(ids, catalog) {
1050
+ const wanted = new Set(ids);
1051
+ return catalog.filter((id) => wanted.has(id));
1052
+ }
1053
+ function withScopes(selected, ids, closed) {
1054
+ const next = new Set(selected);
1055
+ for (const id of ids) {
1056
+ next.add(id);
1057
+ for (const needed of closed[id] ?? []) {
1058
+ next.add(needed);
1059
+ }
1060
+ }
1061
+ return next;
1062
+ }
1063
+ function withoutScopes(selected, ids, closed) {
1064
+ const removed = new Set(ids);
1065
+ const next = new Set(selected);
1066
+ for (const id of ids) {
1067
+ next.delete(id);
1068
+ }
1069
+ for (const [scope, needed] of Object.entries(closed)) {
1070
+ if (needed.some((id) => removed.has(id))) {
1071
+ next.delete(scope);
1072
+ }
1073
+ }
1074
+ return next;
1075
+ }
1076
+ function neededBy(id, selected, closed) {
1077
+ return selected.filter((scope) => scope !== id && (closed[scope] ?? []).includes(id));
1078
+ }
1079
+ function sameSelection(a, b) {
1080
+ if (a.length !== b.length) {
1081
+ return false;
1082
+ }
1083
+ const set = new Set(a);
1084
+ return b.every((id) => set.has(id));
1085
+ }
1086
+
1087
+ // src/scope-picker.tsx
1003
1088
  var import_jsx_runtime4 = require("react/jsx-runtime");
1089
+ function resolveGroups(scopes, groups) {
1090
+ if (!Array.isArray(groups) || groups.length === 0) {
1091
+ return null;
1092
+ }
1093
+ const byId = new Map(scopes.map((scope) => [scope.id, scope]));
1094
+ const placed = /* @__PURE__ */ new Set();
1095
+ const resolved = [];
1096
+ for (const group of groups) {
1097
+ const members = [];
1098
+ for (const id of group.scopes ?? []) {
1099
+ const scope = byId.get(id);
1100
+ if (scope && !placed.has(id)) {
1101
+ placed.add(id);
1102
+ members.push(scope);
1103
+ }
1104
+ }
1105
+ if (members.length > 0) {
1106
+ resolved.push({ id: group.id, label: group.label, description: group.description ?? null, sensitive: group.sensitive === true, scopes: members });
1107
+ }
1108
+ }
1109
+ const rest = scopes.filter((scope) => !placed.has(scope.id));
1110
+ if (rest.length > 0) {
1111
+ resolved.push({ id: "other", label: "Other permissions", description: null, sensitive: false, scopes: rest });
1112
+ }
1113
+ return resolved.length > 0 ? resolved : null;
1114
+ }
1115
+ function DefaultBadge(props) {
1116
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { ...props });
1117
+ }
1118
+ var touchRow = {
1119
+ display: "flex",
1120
+ gap: "0.625rem",
1121
+ alignItems: "flex-start",
1122
+ minHeight: 44,
1123
+ padding: "0.5rem 0",
1124
+ boxSizing: "border-box",
1125
+ overflowWrap: "anywhere"
1126
+ };
1127
+ var mutedStyle = { opacity: 0.7 };
1128
+ var gridStyle = {
1129
+ display: "grid",
1130
+ gridTemplateColumns: "repeat(auto-fill, minmax(min(100%, 300px), 1fr))",
1131
+ gap: "1rem",
1132
+ alignItems: "start"
1133
+ };
1134
+ var boxStyle = { margin: 0, minWidth: 0, border: "1px solid rgba(128, 128, 128, 0.35)", borderRadius: 10, padding: "0.25rem 1rem 0.75rem" };
1135
+ function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected, onChange, components }) {
1136
+ const { Checkbox, Button, Badge, Alert } = resolveAuthComponents(components);
1137
+ const [open, setOpen] = React5.useState({});
1138
+ const catalog = React5.useMemo(() => scopes.map((scope) => scope.id), [scopes]);
1139
+ const closed = React5.useMemo(() => closeImplications(restrictImplications(implications, new Set(catalog))), [implications, catalog]);
1140
+ const layout = React5.useMemo(() => resolveGroups(scopes, groups), [scopes, groups]);
1141
+ const offeredPresets = React5.useMemo(
1142
+ () => (presets ?? []).filter((preset) => preset.scopes.length > 0 && preset.scopes.every((id) => catalog.includes(id))),
1143
+ [presets, catalog]
1144
+ );
1145
+ const cascades = Object.keys(closed).length > 0;
1146
+ const chosen = new Set(selected);
1147
+ const commit = (next) => onChange(inCatalogOrder(next, catalog));
1148
+ const toggle = (id, checked) => {
1149
+ if (layout === null && !cascades) {
1150
+ onChange(checked ? [...selected, id] : selected.filter((value) => value !== id));
1151
+ return;
1152
+ }
1153
+ commit(checked ? withScopes(selected, [id], closed) : withoutScopes(selected, [id], closed));
1154
+ };
1155
+ const renderRow = (scope, grouped) => {
1156
+ const id = `${idPrefix}-${scope.id}`;
1157
+ const needers = neededBy(scope.id, selected, closed);
1158
+ const noteId = `${id}-needed`;
1159
+ const row = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { htmlFor: id, style: grouped ? { ...touchRow, cursor: "pointer" } : { overflowWrap: "anywhere" }, children: [
1160
+ Checkbox ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Checkbox, { id, checked: chosen.has(scope.id), onCheckedChange: (checked) => toggle(scope.id, checked) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1161
+ "input",
1162
+ {
1163
+ id,
1164
+ type: "checkbox",
1165
+ checked: chosen.has(scope.id),
1166
+ "aria-describedby": needers.length > 0 ? noteId : void 0,
1167
+ onChange: (event) => toggle(scope.id, event.target.checked),
1168
+ style: grouped ? { flex: "none", width: 16, height: 16, margin: "2px 0 0" } : void 0
1169
+ }
1170
+ ),
1171
+ " ",
1172
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: [
1173
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: scope.id }),
1174
+ " ",
1175
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: mutedStyle, children: scope.description })
1176
+ ] })
1177
+ ] }, scope.id);
1178
+ if (needers.length === 0) {
1179
+ return row;
1180
+ }
1181
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { minWidth: 0 }, children: [
1182
+ row,
1183
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("small", { id: noteId, style: { ...mutedStyle, display: "block", paddingLeft: grouped ? 26 : 0, overflowWrap: "anywhere" }, children: [
1184
+ "needed by ",
1185
+ needers.join(", ")
1186
+ ] })
1187
+ ] }, scope.id);
1188
+ };
1189
+ if (layout === null) {
1190
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { style: { display: "grid", gap: "0.25rem", border: 0, padding: 0, minWidth: 0 }, children: [
1191
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { children: "Permissions" }),
1192
+ scopes.map((scope) => renderRow(scope, false))
1193
+ ] });
1194
+ }
1195
+ const pressed = offeredPresets.find((preset) => sameSelection(selected, preset.scopes));
1196
+ const plain = layout.filter((group) => !group.sensitive);
1197
+ const sensitive = layout.filter((group) => group.sensitive);
1198
+ const Chip = Badge ?? DefaultBadge;
1199
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid", gap: "1rem", minWidth: 0 }, children: [
1200
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid", gap: "0.25rem" }, children: [
1201
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: "Permissions" }),
1202
+ offeredPresets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: mutedStyle, children: "Start from a preset, then adjust any permission below. The credential stores exactly the permissions you tick." })
1203
+ ] }),
1204
+ offeredPresets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid", gap: "0.625rem" }, children: [
1205
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { role: "group", "aria-label": "Presets", style: { display: "flex", flexWrap: "wrap", gap: "0.5rem" }, children: offeredPresets.map((preset) => {
1206
+ const isPressed = pressed?.id === preset.id;
1207
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1208
+ Button,
1209
+ {
1210
+ type: "button",
1211
+ variant: isPressed ? "default" : "outline",
1212
+ "aria-pressed": isPressed,
1213
+ style: { minHeight: 44, maxWidth: "100%", overflowWrap: "anywhere", whiteSpace: "normal", textAlign: "left" },
1214
+ onClick: () => commit(withScopes([], preset.scopes, closed)),
1215
+ children: preset.label
1216
+ },
1217
+ preset.id
1218
+ );
1219
+ }) }),
1220
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { "aria-live": "polite", style: { margin: 0, ...mutedStyle, overflowWrap: "anywhere" }, children: pressed ? pressed.description : "Custom selection. Pick a preset to replace it, or keep adjusting below." })
1221
+ ] }),
1222
+ plain.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: gridStyle, children: plain.map((group) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { style: { ...boxStyle, display: "grid", gridTemplateColumns: "minmax(0, 1fr)" }, children: [
1223
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { style: { padding: "0 0.375rem", fontWeight: 600, overflowWrap: "anywhere" }, children: group.label }),
1224
+ group.scopes.map((scope) => renderRow(scope, true))
1225
+ ] }, group.id)) }),
1226
+ sensitive.map((group) => {
1227
+ const ids = group.scopes.map((scope) => scope.id);
1228
+ const count = ids.filter((id) => chosen.has(id)).length;
1229
+ const state = count === 0 ? "none" : count === ids.length ? "all" : "some";
1230
+ const parentId = `${idPrefix}-group-${group.id}`;
1231
+ const listId = `${parentId}-scopes`;
1232
+ const isOpen = open[group.id] === true;
1233
+ const warning = group.description !== null && group.description !== "" ? group.description : null;
1234
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { style: { ...boxStyle, display: "grid", gap: "0.375rem", paddingBottom: "0.875rem" }, children: [
1235
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("legend", { style: { padding: "0 0.375rem", fontWeight: 600, display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
1236
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { overflowWrap: "anywhere" }, children: group.label }),
1237
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Chip, { style: { fontSize: 12, fontWeight: 500, border: "1px solid currentColor", borderRadius: 999, padding: "3px 8px", lineHeight: 1 }, children: "Sensitive" })
1238
+ ] }),
1239
+ warning !== null && (() => {
1240
+ const content = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1241
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react3.TriangleAlert, { "aria-hidden": "true", size: 16, style: { flex: "none", marginTop: 2 } }),
1242
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: warning })
1243
+ ] });
1244
+ const style = { margin: "0.25rem 0 0", display: "flex", gap: "0.5rem", alignItems: "flex-start" };
1245
+ return Alert ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Alert, { style, children: content }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { ...style, color: "#b45309" }, children: content });
1246
+ })(),
1247
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { htmlFor: parentId, style: { ...touchRow, cursor: "pointer" }, children: [
1248
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1249
+ "input",
1250
+ {
1251
+ id: parentId,
1252
+ type: "checkbox",
1253
+ checked: state === "all",
1254
+ "aria-checked": state === "some" ? "mixed" : state === "all",
1255
+ ref: (element) => {
1256
+ if (element) {
1257
+ element.indeterminate = state === "some";
1258
+ }
1259
+ },
1260
+ onChange: () => commit(state === "all" ? withoutScopes(selected, ids, closed) : withScopes(selected, ids, closed)),
1261
+ style: { flex: "none", width: 16, height: 16, margin: "2px 0 0" }
1262
+ }
1263
+ ),
1264
+ " ",
1265
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: [
1266
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: group.label }),
1267
+ " ",
1268
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: mutedStyle, children: state === "all" ? `All ${ids.length} ${group.label} permissions are selected.` : state === "some" ? `${count} of ${ids.length} ${group.label} permissions are selected.` : `Selects all ${ids.length} ${group.label} permissions.` })
1269
+ ] })
1270
+ ] }),
1271
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1272
+ Button,
1273
+ {
1274
+ type: "button",
1275
+ variant: "ghost",
1276
+ "aria-expanded": isOpen,
1277
+ "aria-controls": listId,
1278
+ style: { minHeight: 44, whiteSpace: "normal", textAlign: "left" },
1279
+ onClick: () => setOpen((current) => ({ ...current, [group.id]: !isOpen })),
1280
+ children: [
1281
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react3.ChevronRight, { "aria-hidden": "true", size: 16, style: { flex: "none", transition: "transform 120ms", transform: isOpen ? "rotate(90deg)" : "none" } }),
1282
+ isOpen ? "Hide" : "Adjust",
1283
+ " individual ",
1284
+ group.label,
1285
+ " permissions"
1286
+ ]
1287
+ }
1288
+ ) }),
1289
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { id: listId, style: { ...gridStyle, columnGap: "1.5rem", gap: "0 1.5rem", paddingLeft: "1.5rem", marginLeft: 7, borderLeft: "2px solid rgba(128, 128, 128, 0.35)" }, children: group.scopes.map((scope) => renderRow(scope, true)) })
1290
+ ] }, group.id);
1291
+ }),
1292
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { borderTop: "1px solid rgba(128, 128, 128, 0.35)", paddingTop: "0.875rem", display: "grid", gap: "0.5rem" }, children: [
1293
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { margin: 0, fontWeight: 500 }, role: "status", children: selected.length === 0 ? "No permissions selected." : `This credential will request ${selected.length} ${selected.length === 1 ? "permission" : "permissions"}:` }),
1294
+ selected.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { margin: 0, display: "flex", flexWrap: "wrap", gap: "0.375rem" }, children: selected.map((id) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { style: { overflowWrap: "anywhere" }, children: id }, id)) })
1295
+ ] })
1296
+ ] });
1297
+ }
1298
+
1299
+ // src/api-credentials-section.tsx
1300
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1004
1301
  function ApiCredentialsSection({ indexUrl, components, links = [], csrfToken, request, onSuccess, onError }) {
1005
1302
  const { Card, CardContent, CardDescription, CardHeader, CardTitle } = resolveAuthComponents(components);
1006
- const [index, setIndex] = React5.useState(null);
1007
- const [issued, setIssued] = React5.useState([]);
1008
- const issuedKey = React5.useRef(0);
1009
- const addIssued = React5.useCallback((credential) => {
1303
+ const [index, setIndex] = React6.useState(null);
1304
+ const [issued, setIssued] = React6.useState([]);
1305
+ const issuedKey = React6.useRef(0);
1306
+ const addIssued = React6.useCallback((credential) => {
1010
1307
  issuedKey.current += 1;
1011
1308
  const key = issuedKey.current;
1012
1309
  setIssued((current) => [...current, { key, credential }]);
1013
1310
  }, []);
1014
- const [loadError, setLoadError] = React5.useState(null);
1015
- const onErrorRef = React5.useRef(onError);
1311
+ const [loadError, setLoadError] = React6.useState(null);
1312
+ const onErrorRef = React6.useRef(onError);
1016
1313
  onErrorRef.current = onError;
1017
- const generation = React5.useRef(0);
1018
- const context = React5.useRef({ indexUrl, csrfToken, request });
1314
+ const generation = React6.useRef(0);
1315
+ const context = React6.useRef({ indexUrl, csrfToken, request });
1019
1316
  context.current = { indexUrl, csrfToken, request };
1020
- const reload = React5.useCallback(async () => {
1317
+ const reload = React6.useCallback(async () => {
1021
1318
  generation.current += 1;
1022
1319
  const mine = generation.current;
1023
1320
  const { indexUrl: url, csrfToken: token, request: send } = context.current;
@@ -1033,31 +1330,31 @@ function ApiCredentialsSection({ indexUrl, components, links = [], csrfToken, re
1033
1330
  onErrorRef.current?.("api-credentials", result.message);
1034
1331
  }
1035
1332
  }, []);
1036
- React5.useEffect(() => {
1333
+ React6.useEffect(() => {
1037
1334
  setIndex(null);
1038
1335
  void reload();
1039
1336
  }, [indexUrl, csrfToken, reload]);
1040
- const removeLocally = React5.useCallback((list, id) => {
1337
+ const removeLocally = React6.useCallback((list, id) => {
1041
1338
  setIndex(
1042
1339
  (current) => current === null ? current : list === "tokens" ? { ...current, tokens: current.tokens.filter((token) => token.id !== id) } : { ...current, apps: current.apps.filter((app) => app.id !== id) }
1043
1340
  );
1044
1341
  }, []);
1045
1342
  const shared = { components, csrfToken, request, onError, onSuccess, removeLocally };
1046
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Card, { children: [
1047
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(CardHeader, { children: [
1048
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CardTitle, { children: "API access" }),
1049
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CardDescription, { children: "Connect apps that use the API. Register an OAuth app for apps that sign you in, or create an API token for apps that ask for a key. Each carries only the permissions you choose, and never more than your own access." })
1343
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Card, { children: [
1344
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(CardHeader, { children: [
1345
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CardTitle, { children: "API access" }),
1346
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CardDescription, { children: "Connect apps that use the API. Register an OAuth app for apps that sign you in, or create an API token for apps that ask for a key. Each carries only the permissions you choose, and never more than your own access." })
1050
1347
  ] }),
1051
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CardContent, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid", gap: "1.5rem", minWidth: 0 }, children: [
1052
- links.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dl", { style: { display: "grid", gap: "0.5rem", minWidth: 0 }, children: links.map((link) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { minWidth: 0 }, children: [
1053
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { children: link.label }),
1054
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("dd", { style: { margin: 0, overflowWrap: "anywhere" }, children: [
1055
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: link.url }),
1348
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CardContent, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "grid", gap: "1.5rem", minWidth: 0 }, children: [
1349
+ links.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("dl", { style: { display: "grid", gap: "0.5rem", minWidth: 0 }, children: links.map((link) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { minWidth: 0 }, children: [
1350
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("dt", { children: link.label }),
1351
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("dd", { style: { margin: 0, overflowWrap: "anywhere" }, children: [
1352
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("code", { children: link.url }),
1056
1353
  " ",
1057
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CopyButton, { text: link.url, label: link.label, components })
1354
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CopyButton, { text: link.url, label: link.label, components })
1058
1355
  ] })
1059
1356
  ] }, link.label)) }),
1060
- issued.map(({ key, credential }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1357
+ issued.map(({ key, credential }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1061
1358
  IssuedNotice,
1062
1359
  {
1063
1360
  issued: credential,
@@ -1066,29 +1363,36 @@ function ApiCredentialsSection({ indexUrl, components, links = [], csrfToken, re
1066
1363
  },
1067
1364
  key
1068
1365
  )),
1069
- loadError !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "alert", children: loadError }),
1070
- index !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1071
- (index.issue_token_href === null || index.register_app_href === null) && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "status", children: "Creating new credentials is unavailable right now. You can still revoke existing ones." }),
1072
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TokenSection, { index, ...shared, onIssued: addIssued, reload }),
1073
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AppSection, { index, ...shared, onIssued: addIssued, reload })
1366
+ loadError !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { role: "alert", children: loadError }),
1367
+ index !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1368
+ (index.issue_token_href === null || index.register_app_href === null) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { role: "status", children: "Creating new credentials is unavailable right now. You can still revoke existing ones." }),
1369
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TokenSection, { index, ...shared, onIssued: addIssued, reload }),
1370
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AppSection, { index, ...shared, onIssued: addIssued, reload })
1074
1371
  ] })
1075
1372
  ] }) })
1076
1373
  ] });
1077
1374
  }
1078
1375
  function TokenSection({ index, components, csrfToken, request, onIssued, reload, onSuccess, onError, removeLocally }) {
1079
1376
  const { Button, Input, Label, RadioGroup } = resolveAuthComponents(components);
1080
- const [name, setName] = React5.useState("");
1081
- const [scopes, setScopes] = React5.useState([]);
1082
- const [lifetime, setLifetime] = React5.useState(index.token_lifetimes[0] ?? "");
1083
- const [busy, setBusy] = React5.useState(false);
1084
- const [error, setError] = React5.useState(null);
1377
+ const [name, setName] = React6.useState("");
1378
+ const [scopes, setScopes] = React6.useState([]);
1379
+ const [lifetime, setLifetime] = React6.useState(index.token_lifetimes[0] ?? "");
1380
+ const tokenScopes = React6.useMemo(
1381
+ () => [...index.token_scopes ?? index.scopes, ...index.token_connection_scopes ?? []],
1382
+ [index.token_scopes, index.scopes, index.token_connection_scopes]
1383
+ );
1384
+ const connectionIds = new Set((index.token_connection_scopes ?? []).map((scope) => scope.id));
1385
+ const lifetimes = index.connection_token_lifetimes && index.connection_token_lifetimes.length > 0 && scopes.some((id) => connectionIds.has(id)) ? index.connection_token_lifetimes : index.token_lifetimes;
1386
+ const effectiveLifetime = lifetimes.includes(lifetime) ? lifetime : lifetimes[0] ?? "";
1387
+ const [busy, setBusy] = React6.useState(false);
1388
+ const [error, setError] = React6.useState(null);
1085
1389
  async function create(event) {
1086
1390
  event.preventDefault();
1087
1391
  if (index.issue_token_href === null) {
1088
1392
  return;
1089
1393
  }
1090
1394
  setBusy(true);
1091
- const result = await credentialRequest("POST", index.issue_token_href, { name, scopes, lifetime }, csrfToken, request);
1395
+ const result = await credentialRequest("POST", index.issue_token_href, { name, scopes, lifetime: effectiveLifetime }, csrfToken, request);
1092
1396
  setBusy(false);
1093
1397
  if (!result.ok) {
1094
1398
  setError(result.message);
@@ -1102,7 +1406,7 @@ function TokenSection({ index, components, csrfToken, request, onIssued, reload,
1102
1406
  onSuccess?.("API token created.");
1103
1407
  await reload();
1104
1408
  }
1105
- const [pending, setPending] = React5.useState([]);
1409
+ const [pending, setPending] = React6.useState([]);
1106
1410
  async function revoke(token) {
1107
1411
  if (pending.includes(token.id)) {
1108
1412
  return;
@@ -1121,54 +1425,67 @@ function TokenSection({ index, components, csrfToken, request, onIssued, reload,
1121
1425
  await reload();
1122
1426
  setPending((current) => current.filter((id) => id !== token.id));
1123
1427
  }
1124
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
1125
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h3", { children: "API tokens" }),
1126
- index.issue_token_href !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("form", { onSubmit: create, style: { display: "grid", gap: "0.75rem" }, children: [
1127
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid", gap: "0.25rem" }, children: [
1128
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Label, { htmlFor: "api-token-name", children: "Token name" }),
1129
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Input, { id: "api-token-name", value: name, maxLength: 120, onChange: (event) => setName(event.target.value) })
1428
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
1429
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { children: "API tokens" }),
1430
+ index.issue_token_href !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("form", { onSubmit: create, style: { display: "grid", gap: "0.75rem" }, children: [
1431
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "grid", gap: "0.25rem" }, children: [
1432
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Label, { htmlFor: "api-token-name", children: "Token name" }),
1433
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Input, { id: "api-token-name", value: name, maxLength: 120, onChange: (event) => setName(event.target.value) })
1130
1434
  ] }),
1131
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ScopePicker, { idPrefix: "api-token-scope", scopes: index.scopes, selected: scopes, onChange: setScopes, components }),
1132
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { style: { display: "grid", gap: "0.25rem", border: 0, padding: 0 }, children: [
1133
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { children: "Expires after" }),
1134
- RadioGroup ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1435
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1436
+ ScopePicker,
1437
+ {
1438
+ idPrefix: "api-token-scope",
1439
+ scopes: tokenScopes,
1440
+ groups: index.token_scope_groups ?? index.scope_groups,
1441
+ presets: index.token_scope_presets ?? index.scope_presets,
1442
+ implications: index.token_scope_implications ?? index.scope_implications,
1443
+ selected: scopes,
1444
+ onChange: setScopes,
1445
+ components
1446
+ }
1447
+ ),
1448
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("fieldset", { style: { display: "grid", gap: "0.25rem", border: 0, padding: 0 }, children: [
1449
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("legend", { children: "Expires after" }),
1450
+ RadioGroup ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1135
1451
  RadioGroup,
1136
1452
  {
1137
1453
  name: "api-token-lifetime",
1138
- value: lifetime,
1454
+ value: effectiveLifetime,
1139
1455
  onValueChange: setLifetime,
1140
- options: index.token_lifetimes.map((spec) => ({ value: spec, label: describeDuration(spec) }))
1456
+ options: lifetimes.map((spec) => ({ value: spec, label: describeDuration(spec) }))
1141
1457
  }
1142
- ) : index.token_lifetimes.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { children: [
1143
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "radio", name: "api-token-lifetime", checked: lifetime === spec, onChange: () => setLifetime(spec) }),
1458
+ ) : lifetimes.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { children: [
1459
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "radio", name: "api-token-lifetime", checked: effectiveLifetime === spec, onChange: () => setLifetime(spec) }),
1144
1460
  " ",
1145
1461
  describeDuration(spec)
1146
1462
  ] }, spec))
1147
1463
  ] }),
1148
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Button, { type: "submit", disabled: busy || name.trim() === "" || scopes.length === 0 || lifetime === "", children: "Create API token" }) })
1464
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Button, { type: "submit", disabled: busy || name.trim() === "" || scopes.length === 0 || effectiveLifetime === "", children: "Create API token" }) })
1149
1465
  ] }),
1150
- error !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "alert", children: error }),
1151
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { style: { display: "grid", gap: "0.5rem", listStyle: "none", padding: 0, margin: 0, minWidth: 0 }, children: index.tokens.map((token) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("li", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: [
1152
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: token.name }),
1466
+ error !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { role: "alert", children: error }),
1467
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", { style: { display: "grid", gap: "0.5rem", listStyle: "none", padding: 0, margin: 0, minWidth: 0 }, children: index.tokens.map((token) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("li", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: [
1468
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("strong", { children: token.name }),
1153
1469
  " \xB7 ",
1154
1470
  token.scopes.join(", "),
1155
- token.expires_at !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1471
+ token.connection === true && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: " \xB7 MCP connection" }),
1472
+ token.expires_at !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1156
1473
  " \xB7 expires ",
1157
1474
  new Date(token.expires_at).toLocaleString()
1158
1475
  ] }),
1159
1476
  " ",
1160
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Button, { type: "button", disabled: pending.includes(token.id), onClick: () => void revoke(token), children: "Revoke" })
1477
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Button, { type: "button", disabled: pending.includes(token.id), onClick: () => void revoke(token), children: "Revoke" })
1161
1478
  ] }, token.id)) })
1162
1479
  ] });
1163
1480
  }
1164
1481
  function AppSection({ index, components, csrfToken, request, onIssued, reload, onSuccess, onError, removeLocally }) {
1165
1482
  const { Button, Input, Label, Textarea, RadioGroup } = resolveAuthComponents(components);
1166
- const [name, setName] = React5.useState("");
1167
- const [redirects, setRedirects] = React5.useState("");
1168
- const [confidential, setConfidential] = React5.useState(true);
1169
- const [scopes, setScopes] = React5.useState([]);
1170
- const [busy, setBusy] = React5.useState(false);
1171
- const [error, setError] = React5.useState(null);
1483
+ const [name, setName] = React6.useState("");
1484
+ const [redirects, setRedirects] = React6.useState("");
1485
+ const [confidential, setConfidential] = React6.useState(true);
1486
+ const [scopes, setScopes] = React6.useState([]);
1487
+ const [busy, setBusy] = React6.useState(false);
1488
+ const [error, setError] = React6.useState(null);
1172
1489
  const redirectUris = redirects.split("\n").map((line) => line.trim()).filter((line) => line !== "");
1173
1490
  async function register(event) {
1174
1491
  event.preventDefault();
@@ -1197,7 +1514,7 @@ function AppSection({ index, components, csrfToken, request, onIssued, reload, o
1197
1514
  onSuccess?.("OAuth app registered.");
1198
1515
  await reload();
1199
1516
  }
1200
- const [pending, setPending] = React5.useState([]);
1517
+ const [pending, setPending] = React6.useState([]);
1201
1518
  async function remove(app) {
1202
1519
  if (pending.includes(app.id)) {
1203
1520
  return;
@@ -1216,20 +1533,20 @@ function AppSection({ index, components, csrfToken, request, onIssued, reload, o
1216
1533
  await reload();
1217
1534
  setPending((current) => current.filter((id) => id !== app.id));
1218
1535
  }
1219
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
1220
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h3", { children: "OAuth apps" }),
1221
- index.register_app_href !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("form", { onSubmit: register, style: { display: "grid", gap: "0.75rem" }, children: [
1222
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid", gap: "0.25rem" }, children: [
1223
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Label, { htmlFor: "oauth-app-name", children: "App name" }),
1224
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Input, { id: "oauth-app-name", value: name, maxLength: 120, onChange: (event) => setName(event.target.value) })
1536
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
1537
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { children: "OAuth apps" }),
1538
+ index.register_app_href !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("form", { onSubmit: register, style: { display: "grid", gap: "0.75rem" }, children: [
1539
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "grid", gap: "0.25rem" }, children: [
1540
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Label, { htmlFor: "oauth-app-name", children: "App name" }),
1541
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Input, { id: "oauth-app-name", value: name, maxLength: 120, onChange: (event) => setName(event.target.value) })
1225
1542
  ] }),
1226
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid", gap: "0.25rem" }, children: [
1227
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Label, { htmlFor: "oauth-app-redirects", children: "Redirect URIs (one per line)" }),
1228
- Textarea ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Textarea, { id: "oauth-app-redirects", rows: 3, value: redirects, onChange: (event) => setRedirects(event.target.value) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("textarea", { id: "oauth-app-redirects", rows: 3, value: redirects, onChange: (event) => setRedirects(event.target.value) })
1543
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "grid", gap: "0.25rem" }, children: [
1544
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Label, { htmlFor: "oauth-app-redirects", children: "Redirect URIs (one per line)" }),
1545
+ Textarea ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Textarea, { id: "oauth-app-redirects", rows: 3, value: redirects, onChange: (event) => setRedirects(event.target.value) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("textarea", { id: "oauth-app-redirects", rows: 3, value: redirects, onChange: (event) => setRedirects(event.target.value) })
1229
1546
  ] }),
1230
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { style: { display: "grid", gap: "0.25rem", border: 0, padding: 0 }, children: [
1231
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { children: "Client type" }),
1232
- RadioGroup ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1547
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("fieldset", { style: { display: "grid", gap: "0.25rem", border: 0, padding: 0 }, children: [
1548
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("legend", { children: "Client type" }),
1549
+ RadioGroup ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1233
1550
  RadioGroup,
1234
1551
  {
1235
1552
  name: "oauth-app-type",
@@ -1240,60 +1557,49 @@ function AppSection({ index, components, csrfToken, request, onIssued, reload, o
1240
1557
  { value: "public", label: "Public: no secret, PKCE only" }
1241
1558
  ]
1242
1559
  }
1243
- ) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1244
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { children: [
1245
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "radio", name: "oauth-app-type", checked: confidential, onChange: () => setConfidential(true) }),
1560
+ ) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1561
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { children: [
1562
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "radio", name: "oauth-app-type", checked: confidential, onChange: () => setConfidential(true) }),
1246
1563
  " Confidential: the app keeps a client secret on its server"
1247
1564
  ] }),
1248
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { children: [
1249
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "radio", name: "oauth-app-type", checked: !confidential, onChange: () => setConfidential(false) }),
1565
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { children: [
1566
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "radio", name: "oauth-app-type", checked: !confidential, onChange: () => setConfidential(false) }),
1250
1567
  " Public: no secret, PKCE only"
1251
1568
  ] })
1252
1569
  ] })
1253
1570
  ] }),
1254
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ScopePicker, { idPrefix: "oauth-app-scope", scopes: index.scopes, selected: scopes, onChange: setScopes, components }),
1255
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Button, { type: "submit", disabled: busy || name.trim() === "" || redirectUris.length === 0 || scopes.length === 0, children: "Register OAuth app" }) })
1571
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1572
+ ScopePicker,
1573
+ {
1574
+ idPrefix: "oauth-app-scope",
1575
+ scopes: index.scopes,
1576
+ groups: index.scope_groups,
1577
+ presets: index.scope_presets,
1578
+ implications: index.scope_implications,
1579
+ selected: scopes,
1580
+ onChange: setScopes,
1581
+ components
1582
+ }
1583
+ ),
1584
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Button, { type: "submit", disabled: busy || name.trim() === "" || redirectUris.length === 0 || scopes.length === 0, children: "Register OAuth app" }) })
1256
1585
  ] }),
1257
- error !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "alert", children: error }),
1258
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { style: { display: "grid", gap: "0.5rem", listStyle: "none", padding: 0, margin: 0, minWidth: 0 }, children: index.apps.map((app) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("li", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: [
1259
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: app.name }),
1586
+ error !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { role: "alert", children: error }),
1587
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", { style: { display: "grid", gap: "0.5rem", listStyle: "none", padding: 0, margin: 0, minWidth: 0 }, children: index.apps.map((app) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("li", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: [
1588
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("strong", { children: app.name }),
1260
1589
  " \xB7 client ID ",
1261
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: app.id }),
1590
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("code", { children: app.id }),
1262
1591
  " \xB7 ",
1263
1592
  app.confidential ? "confidential" : "public",
1264
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("br", {}),
1593
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("br", {}),
1265
1594
  app.redirect_uris.join(", "),
1266
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("br", {}),
1595
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("br", {}),
1267
1596
  "May request: ",
1268
1597
  app.scopes.join(", "),
1269
1598
  " ",
1270
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Button, { type: "button", disabled: pending.includes(app.id), onClick: () => void remove(app), children: "Delete" })
1599
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Button, { type: "button", disabled: pending.includes(app.id), onClick: () => void remove(app), children: "Delete" })
1271
1600
  ] }, app.id)) })
1272
1601
  ] });
1273
1602
  }
1274
- function ScopePicker({
1275
- idPrefix,
1276
- scopes,
1277
- selected,
1278
- onChange,
1279
- components
1280
- }) {
1281
- const { Checkbox } = resolveAuthComponents(components);
1282
- const toggle = (scopeId, checked) => onChange(checked ? [...selected, scopeId] : selected.filter((value) => value !== scopeId));
1283
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { style: { display: "grid", gap: "0.25rem", border: 0, padding: 0, minWidth: 0 }, children: [
1284
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { children: "Permissions" }),
1285
- scopes.map((scope) => {
1286
- const id = `${idPrefix}-${scope.id}`;
1287
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { htmlFor: id, style: { overflowWrap: "anywhere" }, children: [
1288
- Checkbox ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Checkbox, { id, checked: selected.includes(scope.id), onCheckedChange: (checked) => toggle(scope.id, checked) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { id, type: "checkbox", checked: selected.includes(scope.id), onChange: (event) => toggle(scope.id, event.target.checked) }),
1289
- " ",
1290
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: scope.id }),
1291
- " ",
1292
- scope.description
1293
- ] }, scope.id);
1294
- })
1295
- ] });
1296
- }
1297
1603
  function IssuedNotice({
1298
1604
  issued,
1299
1605
  components,
@@ -1304,26 +1610,26 @@ function IssuedNotice({
1304
1610
  { label: "Client ID", url: issued.client_id },
1305
1611
  ...issued.client_secret !== null ? [{ label: "Client secret", url: issued.client_secret }] : []
1306
1612
  ];
1307
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { role: "status", style: { display: "grid", gap: "0.5rem", minWidth: 0 }, children: [
1308
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { style: { overflowWrap: "anywhere" }, children: [
1613
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { role: "status", style: { display: "grid", gap: "0.5rem", minWidth: 0 }, children: [
1614
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { style: { overflowWrap: "anywhere" }, children: [
1309
1615
  issued.kind === "token" ? `API token \u201C${issued.name}\u201D created.` : `OAuth app \u201C${issued.name}\u201D registered.`,
1310
1616
  " Copy it now: it will not be shown again."
1311
1617
  ] }),
1312
- values.map((value) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: [
1618
+ values.map((value) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: [
1313
1619
  value.label,
1314
1620
  ": ",
1315
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: value.url }),
1621
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("code", { children: value.url }),
1316
1622
  " ",
1317
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CopyButton, { text: value.url, label: value.label, components })
1623
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CopyButton, { text: value.url, label: value.label, components })
1318
1624
  ] }, value.label)),
1319
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Button, { type: "button", onClick: onDismiss, children: "Done" }) })
1625
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Button, { type: "button", onClick: onDismiss, children: "Done" }) })
1320
1626
  ] });
1321
1627
  }
1322
1628
  function CopyButton({ text, label, components }) {
1323
1629
  const { Button } = resolveAuthComponents(components);
1324
- const [state, setState] = React5.useState("idle");
1325
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1326
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1630
+ const [state, setState] = React6.useState("idle");
1631
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1632
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1327
1633
  Button,
1328
1634
  {
1329
1635
  type: "button",
@@ -1343,7 +1649,7 @@ function CopyButton({ text, label, components }) {
1343
1649
  children: state === "copied" ? "Copied" : "Copy"
1344
1650
  }
1345
1651
  ),
1346
- state === "failed" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { role: "status", children: " Copying is unavailable here; select the text and copy it manually." })
1652
+ state === "failed" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { role: "status", children: " Copying is unavailable here; select the text and copy it manually." })
1347
1653
  ] });
1348
1654
  }
1349
1655
  function describeDuration(spec) {
@@ -1423,17 +1729,25 @@ function refusalMessage(status, payload) {
1423
1729
  PasskeySection,
1424
1730
  PasswordResetRequestForm,
1425
1731
  ResetPasswordForm,
1732
+ ScopePicker,
1426
1733
  SignupForm,
1427
1734
  TwoFactorForm,
1428
1735
  arrayBufferToBase64url,
1429
1736
  authenticateWithPasskey,
1430
1737
  base64urlToArrayBuffer,
1738
+ closeImplications,
1431
1739
  describeDuration,
1432
1740
  getCsrfToken,
1433
1741
  getDefaultPasskeyName,
1742
+ inCatalogOrder,
1434
1743
  isAbortError,
1435
1744
  isConditionalMediationAvailable,
1745
+ neededBy,
1436
1746
  registerPasskey,
1437
1747
  relyingApplicationsFrom,
1438
- safeApplicationHref
1748
+ restrictImplications,
1749
+ safeApplicationHref,
1750
+ sameSelection,
1751
+ withScopes,
1752
+ withoutScopes
1439
1753
  });