bwh-auth 0.5.0 → 0.6.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 +24 -0
- package/dist/index.cjs +447 -123
- package/dist/index.d.cts +84 -2
- package/dist/index.d.ts +84 -2
- package/dist/index.js +438 -122
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -944,25 +944,315 @@ function relyingApplicationsFrom(value) {
|
|
|
944
944
|
}
|
|
945
945
|
|
|
946
946
|
// src/api-credentials-section.tsx
|
|
947
|
+
import * as React6 from "react";
|
|
948
|
+
|
|
949
|
+
// src/scope-picker.tsx
|
|
950
|
+
import { ChevronRight, TriangleAlert } from "lucide-react";
|
|
947
951
|
import * as React5 from "react";
|
|
952
|
+
|
|
953
|
+
// src/scope-selection.ts
|
|
954
|
+
function closeImplications(implications) {
|
|
955
|
+
const closed = {};
|
|
956
|
+
for (const key of Object.keys(implications)) {
|
|
957
|
+
const seen = /* @__PURE__ */ new Set();
|
|
958
|
+
const walk = (id) => {
|
|
959
|
+
for (const needed of implications[id] ?? []) {
|
|
960
|
+
if (needed !== key && !seen.has(needed)) {
|
|
961
|
+
seen.add(needed);
|
|
962
|
+
walk(needed);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
walk(key);
|
|
967
|
+
if (seen.size > 0) {
|
|
968
|
+
closed[key] = [...seen];
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
return closed;
|
|
972
|
+
}
|
|
973
|
+
function restrictImplications(implications, offered) {
|
|
974
|
+
const result = {};
|
|
975
|
+
for (const [key, needed] of Object.entries(implications ?? {})) {
|
|
976
|
+
if (!offered.has(key) || !Array.isArray(needed)) {
|
|
977
|
+
continue;
|
|
978
|
+
}
|
|
979
|
+
const kept = needed.filter((id) => offered.has(id));
|
|
980
|
+
if (kept.length > 0) {
|
|
981
|
+
result[key] = kept;
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
return result;
|
|
985
|
+
}
|
|
986
|
+
function inCatalogOrder(ids, catalog) {
|
|
987
|
+
const wanted = new Set(ids);
|
|
988
|
+
return catalog.filter((id) => wanted.has(id));
|
|
989
|
+
}
|
|
990
|
+
function withScopes(selected, ids, closed) {
|
|
991
|
+
const next = new Set(selected);
|
|
992
|
+
for (const id of ids) {
|
|
993
|
+
next.add(id);
|
|
994
|
+
for (const needed of closed[id] ?? []) {
|
|
995
|
+
next.add(needed);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
return next;
|
|
999
|
+
}
|
|
1000
|
+
function withoutScopes(selected, ids, closed) {
|
|
1001
|
+
const removed = new Set(ids);
|
|
1002
|
+
const next = new Set(selected);
|
|
1003
|
+
for (const id of ids) {
|
|
1004
|
+
next.delete(id);
|
|
1005
|
+
}
|
|
1006
|
+
for (const [scope, needed] of Object.entries(closed)) {
|
|
1007
|
+
if (needed.some((id) => removed.has(id))) {
|
|
1008
|
+
next.delete(scope);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
return next;
|
|
1012
|
+
}
|
|
1013
|
+
function neededBy(id, selected, closed) {
|
|
1014
|
+
return selected.filter((scope) => scope !== id && (closed[scope] ?? []).includes(id));
|
|
1015
|
+
}
|
|
1016
|
+
function sameSelection(a, b) {
|
|
1017
|
+
if (a.length !== b.length) {
|
|
1018
|
+
return false;
|
|
1019
|
+
}
|
|
1020
|
+
const set = new Set(a);
|
|
1021
|
+
return b.every((id) => set.has(id));
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
// src/scope-picker.tsx
|
|
948
1025
|
import { Fragment, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
949
|
-
function
|
|
1026
|
+
function resolveGroups(scopes, groups) {
|
|
1027
|
+
if (!Array.isArray(groups) || groups.length === 0) {
|
|
1028
|
+
return null;
|
|
1029
|
+
}
|
|
1030
|
+
const byId = new Map(scopes.map((scope) => [scope.id, scope]));
|
|
1031
|
+
const placed = /* @__PURE__ */ new Set();
|
|
1032
|
+
const resolved = [];
|
|
1033
|
+
for (const group of groups) {
|
|
1034
|
+
const members = [];
|
|
1035
|
+
for (const id of group.scopes ?? []) {
|
|
1036
|
+
const scope = byId.get(id);
|
|
1037
|
+
if (scope && !placed.has(id)) {
|
|
1038
|
+
placed.add(id);
|
|
1039
|
+
members.push(scope);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
if (members.length > 0) {
|
|
1043
|
+
resolved.push({ id: group.id, label: group.label, description: group.description ?? null, sensitive: group.sensitive === true, scopes: members });
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
const rest = scopes.filter((scope) => !placed.has(scope.id));
|
|
1047
|
+
if (rest.length > 0) {
|
|
1048
|
+
resolved.push({ id: "other", label: "Other permissions", description: null, sensitive: false, scopes: rest });
|
|
1049
|
+
}
|
|
1050
|
+
return resolved.length > 0 ? resolved : null;
|
|
1051
|
+
}
|
|
1052
|
+
function DefaultBadge(props) {
|
|
1053
|
+
return /* @__PURE__ */ jsx4("span", { ...props });
|
|
1054
|
+
}
|
|
1055
|
+
var touchRow = {
|
|
1056
|
+
display: "flex",
|
|
1057
|
+
gap: "0.625rem",
|
|
1058
|
+
alignItems: "flex-start",
|
|
1059
|
+
minHeight: 44,
|
|
1060
|
+
padding: "0.5rem 0",
|
|
1061
|
+
boxSizing: "border-box",
|
|
1062
|
+
overflowWrap: "anywhere"
|
|
1063
|
+
};
|
|
1064
|
+
var wrapStyle = { minWidth: 0, overflowWrap: "anywhere" };
|
|
1065
|
+
var mutedStyle = { opacity: 0.7 };
|
|
1066
|
+
var gridStyle = {
|
|
1067
|
+
display: "grid",
|
|
1068
|
+
gridTemplateColumns: "repeat(auto-fill, minmax(min(100%, 300px), 1fr))",
|
|
1069
|
+
gap: "1rem",
|
|
1070
|
+
alignItems: "start"
|
|
1071
|
+
};
|
|
1072
|
+
var boxStyle = { margin: 0, minWidth: 0, border: "1px solid rgba(128, 128, 128, 0.35)", borderRadius: 10, padding: "0.25rem 1rem 0.75rem" };
|
|
1073
|
+
function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected, onChange, components }) {
|
|
1074
|
+
const { Checkbox, Button, Badge, Alert } = resolveAuthComponents(components);
|
|
1075
|
+
const [open, setOpen] = React5.useState({});
|
|
1076
|
+
const catalog = React5.useMemo(() => scopes.map((scope) => scope.id), [scopes]);
|
|
1077
|
+
const closed = React5.useMemo(() => closeImplications(restrictImplications(implications, new Set(catalog))), [implications, catalog]);
|
|
1078
|
+
const layout = React5.useMemo(() => resolveGroups(scopes, groups), [scopes, groups]);
|
|
1079
|
+
const offeredPresets = React5.useMemo(
|
|
1080
|
+
() => (presets ?? []).filter((preset) => preset.scopes.length > 0 && preset.scopes.every((id) => catalog.includes(id))),
|
|
1081
|
+
[presets, catalog]
|
|
1082
|
+
);
|
|
1083
|
+
const cascades = Object.keys(closed).length > 0;
|
|
1084
|
+
const chosen = new Set(selected);
|
|
1085
|
+
const commit = (next) => onChange(inCatalogOrder(next, catalog));
|
|
1086
|
+
const toggle = (id, checked) => {
|
|
1087
|
+
if (layout === null && !cascades) {
|
|
1088
|
+
onChange(checked ? [...selected, id] : selected.filter((value) => value !== id));
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1091
|
+
commit(checked ? withScopes(selected, [id], closed) : withoutScopes(selected, [id], closed));
|
|
1092
|
+
};
|
|
1093
|
+
const renderRow = (scope, grouped) => {
|
|
1094
|
+
const id = `${idPrefix}-${scope.id}`;
|
|
1095
|
+
const needers = neededBy(scope.id, selected, closed);
|
|
1096
|
+
const noteId = `${id}-needed`;
|
|
1097
|
+
const row = /* @__PURE__ */ jsxs4("label", { htmlFor: id, style: grouped ? { ...touchRow, cursor: "pointer" } : { overflowWrap: "anywhere" }, children: [
|
|
1098
|
+
Checkbox ? /* @__PURE__ */ jsx4(Checkbox, { id, checked: chosen.has(scope.id), onCheckedChange: (checked) => toggle(scope.id, checked) }) : /* @__PURE__ */ jsx4(
|
|
1099
|
+
"input",
|
|
1100
|
+
{
|
|
1101
|
+
id,
|
|
1102
|
+
type: "checkbox",
|
|
1103
|
+
checked: chosen.has(scope.id),
|
|
1104
|
+
"aria-describedby": needers.length > 0 ? noteId : void 0,
|
|
1105
|
+
onChange: (event) => toggle(scope.id, event.target.checked),
|
|
1106
|
+
style: grouped ? { flex: "none", width: 16, height: 16, margin: "2px 0 0" } : void 0
|
|
1107
|
+
}
|
|
1108
|
+
),
|
|
1109
|
+
" ",
|
|
1110
|
+
/* @__PURE__ */ jsxs4("span", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1111
|
+
/* @__PURE__ */ jsx4("code", { style: wrapStyle, children: scope.id }),
|
|
1112
|
+
" ",
|
|
1113
|
+
/* @__PURE__ */ jsx4("span", { style: mutedStyle, children: scope.description })
|
|
1114
|
+
] })
|
|
1115
|
+
] }, scope.id);
|
|
1116
|
+
if (needers.length === 0) {
|
|
1117
|
+
return row;
|
|
1118
|
+
}
|
|
1119
|
+
return /* @__PURE__ */ jsxs4("div", { style: { minWidth: 0 }, children: [
|
|
1120
|
+
row,
|
|
1121
|
+
/* @__PURE__ */ jsxs4("small", { id: noteId, style: { ...mutedStyle, display: "block", paddingLeft: grouped ? 26 : 0, overflowWrap: "anywhere" }, children: [
|
|
1122
|
+
"needed by ",
|
|
1123
|
+
needers.join(", ")
|
|
1124
|
+
] })
|
|
1125
|
+
] }, scope.id);
|
|
1126
|
+
};
|
|
1127
|
+
if (layout === null) {
|
|
1128
|
+
return /* @__PURE__ */ jsxs4("fieldset", { style: { display: "grid", gap: "0.25rem", border: 0, padding: 0, minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1129
|
+
/* @__PURE__ */ jsx4("legend", { children: "Permissions" }),
|
|
1130
|
+
scopes.map((scope) => renderRow(scope, false))
|
|
1131
|
+
] });
|
|
1132
|
+
}
|
|
1133
|
+
const pressed = offeredPresets.find((preset) => sameSelection(selected, preset.scopes));
|
|
1134
|
+
const plain = layout.filter((group) => !group.sensitive);
|
|
1135
|
+
const sensitive = layout.filter((group) => group.sensitive);
|
|
1136
|
+
const Chip = Badge ?? DefaultBadge;
|
|
1137
|
+
return /* @__PURE__ */ jsxs4("div", { style: { display: "grid", gap: "1rem", minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1138
|
+
/* @__PURE__ */ jsxs4("div", { style: { display: "grid", gap: "0.25rem", minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1139
|
+
/* @__PURE__ */ jsx4("strong", { children: "Permissions" }),
|
|
1140
|
+
offeredPresets.length > 0 && /* @__PURE__ */ jsx4("span", { style: mutedStyle, children: "Start from a preset, then adjust any permission below. The credential stores exactly the permissions you tick." })
|
|
1141
|
+
] }),
|
|
1142
|
+
offeredPresets.length > 0 && /* @__PURE__ */ jsxs4("div", { style: { display: "grid", gap: "0.625rem", minWidth: 0 }, children: [
|
|
1143
|
+
/* @__PURE__ */ jsx4("div", { role: "group", "aria-label": "Presets", style: { display: "flex", flexWrap: "wrap", gap: "0.5rem" }, children: offeredPresets.map((preset) => {
|
|
1144
|
+
const isPressed = pressed?.id === preset.id;
|
|
1145
|
+
return /* @__PURE__ */ jsx4(
|
|
1146
|
+
Button,
|
|
1147
|
+
{
|
|
1148
|
+
type: "button",
|
|
1149
|
+
variant: isPressed ? "default" : "outline",
|
|
1150
|
+
"aria-pressed": isPressed,
|
|
1151
|
+
style: { height: "auto", minHeight: 44, minWidth: 0, maxWidth: "100%", overflowWrap: "anywhere", whiteSpace: "normal", textAlign: "left" },
|
|
1152
|
+
onClick: () => commit(withScopes([], preset.scopes, closed)),
|
|
1153
|
+
children: preset.label
|
|
1154
|
+
},
|
|
1155
|
+
preset.id
|
|
1156
|
+
);
|
|
1157
|
+
}) }),
|
|
1158
|
+
/* @__PURE__ */ jsx4("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." })
|
|
1159
|
+
] }),
|
|
1160
|
+
plain.length > 0 && /* @__PURE__ */ jsx4("div", { style: gridStyle, children: plain.map((group) => /* @__PURE__ */ jsxs4("fieldset", { style: { ...boxStyle, display: "grid", gridTemplateColumns: "minmax(0, 1fr)" }, children: [
|
|
1161
|
+
/* @__PURE__ */ jsx4("legend", { style: { padding: "0 0.375rem", fontWeight: 600, overflowWrap: "anywhere" }, children: group.label }),
|
|
1162
|
+
group.scopes.map((scope) => renderRow(scope, true))
|
|
1163
|
+
] }, group.id)) }),
|
|
1164
|
+
sensitive.map((group) => {
|
|
1165
|
+
const ids = group.scopes.map((scope) => scope.id);
|
|
1166
|
+
const count = ids.filter((id) => chosen.has(id)).length;
|
|
1167
|
+
const state = count === 0 ? "none" : count === ids.length ? "all" : "some";
|
|
1168
|
+
const parentId = `${idPrefix}-group-${group.id}`;
|
|
1169
|
+
const listId = `${parentId}-scopes`;
|
|
1170
|
+
const isOpen = open[group.id] === true;
|
|
1171
|
+
const warning = group.description !== null && group.description !== "" ? group.description : null;
|
|
1172
|
+
return /* @__PURE__ */ jsxs4("fieldset", { style: { ...boxStyle, display: "grid", gridTemplateColumns: "minmax(0, 1fr)", gap: "0.375rem", paddingBottom: "0.875rem" }, children: [
|
|
1173
|
+
/* @__PURE__ */ jsxs4("legend", { style: { padding: "0 0.375rem", fontWeight: 600, display: "flex", alignItems: "center", gap: "0.5rem", maxWidth: "100%", minWidth: 0 }, children: [
|
|
1174
|
+
/* @__PURE__ */ jsx4("span", { style: { overflowWrap: "anywhere" }, children: group.label }),
|
|
1175
|
+
/* @__PURE__ */ jsx4(Chip, { style: { fontSize: 12, fontWeight: 500, border: "1px solid currentColor", borderRadius: 999, padding: "3px 8px", lineHeight: 1 }, children: "Sensitive" })
|
|
1176
|
+
] }),
|
|
1177
|
+
warning !== null && (() => {
|
|
1178
|
+
const content = /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
1179
|
+
/* @__PURE__ */ jsx4(TriangleAlert, { "aria-hidden": "true", size: 16, style: { flex: "none", marginTop: 2 } }),
|
|
1180
|
+
/* @__PURE__ */ jsx4("span", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: warning })
|
|
1181
|
+
] });
|
|
1182
|
+
const style = { margin: "0.25rem 0 0", display: "flex", gap: "0.5rem", alignItems: "flex-start" };
|
|
1183
|
+
return Alert ? /* @__PURE__ */ jsx4(Alert, { style, children: content }) : /* @__PURE__ */ jsx4("p", { style: { ...style, color: "#b45309" }, children: content });
|
|
1184
|
+
})(),
|
|
1185
|
+
/* @__PURE__ */ jsxs4("label", { htmlFor: parentId, style: { ...touchRow, cursor: "pointer" }, children: [
|
|
1186
|
+
/* @__PURE__ */ jsx4(
|
|
1187
|
+
"input",
|
|
1188
|
+
{
|
|
1189
|
+
id: parentId,
|
|
1190
|
+
type: "checkbox",
|
|
1191
|
+
checked: state === "all",
|
|
1192
|
+
"aria-checked": state === "some" ? "mixed" : state === "all",
|
|
1193
|
+
ref: (element) => {
|
|
1194
|
+
if (element) {
|
|
1195
|
+
element.indeterminate = state === "some";
|
|
1196
|
+
}
|
|
1197
|
+
},
|
|
1198
|
+
onChange: () => commit(state === "all" ? withoutScopes(selected, ids, closed) : withScopes(selected, ids, closed)),
|
|
1199
|
+
style: { flex: "none", width: 16, height: 16, margin: "2px 0 0" }
|
|
1200
|
+
}
|
|
1201
|
+
),
|
|
1202
|
+
" ",
|
|
1203
|
+
/* @__PURE__ */ jsxs4("span", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1204
|
+
/* @__PURE__ */ jsx4("strong", { children: group.label }),
|
|
1205
|
+
" ",
|
|
1206
|
+
/* @__PURE__ */ jsx4("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.` })
|
|
1207
|
+
] })
|
|
1208
|
+
] }),
|
|
1209
|
+
/* @__PURE__ */ jsx4("div", { children: /* @__PURE__ */ jsxs4(
|
|
1210
|
+
Button,
|
|
1211
|
+
{
|
|
1212
|
+
type: "button",
|
|
1213
|
+
variant: "ghost",
|
|
1214
|
+
"aria-expanded": isOpen,
|
|
1215
|
+
"aria-controls": listId,
|
|
1216
|
+
style: { height: "auto", minHeight: 44, minWidth: 0, maxWidth: "100%", overflowWrap: "anywhere", whiteSpace: "normal", textAlign: "left" },
|
|
1217
|
+
onClick: () => setOpen((current) => ({ ...current, [group.id]: !isOpen })),
|
|
1218
|
+
children: [
|
|
1219
|
+
/* @__PURE__ */ jsx4(ChevronRight, { "aria-hidden": "true", size: 16, style: { flex: "none", transition: "transform 120ms", transform: isOpen ? "rotate(90deg)" : "none" } }),
|
|
1220
|
+
isOpen ? "Hide" : "Adjust",
|
|
1221
|
+
" individual ",
|
|
1222
|
+
group.label,
|
|
1223
|
+
" permissions"
|
|
1224
|
+
]
|
|
1225
|
+
}
|
|
1226
|
+
) }),
|
|
1227
|
+
isOpen && /* @__PURE__ */ jsx4("div", { id: listId, style: { ...gridStyle, minWidth: 0, 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)) })
|
|
1228
|
+
] }, group.id);
|
|
1229
|
+
}),
|
|
1230
|
+
/* @__PURE__ */ jsxs4("div", { style: { borderTop: "1px solid rgba(128, 128, 128, 0.35)", paddingTop: "0.875rem", display: "grid", gap: "0.5rem" }, children: [
|
|
1231
|
+
/* @__PURE__ */ jsx4("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"}:` }),
|
|
1232
|
+
selected.length > 0 && /* @__PURE__ */ jsx4("p", { style: { margin: 0, display: "flex", flexWrap: "wrap", gap: "0.375rem" }, children: selected.map((id) => /* @__PURE__ */ jsx4("code", { style: { overflowWrap: "anywhere" }, children: id }, id)) })
|
|
1233
|
+
] })
|
|
1234
|
+
] });
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
// src/api-credentials-section.tsx
|
|
1238
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1239
|
+
function ApiCredentialsSection({ indexUrl, components, links = [], csrfToken, request, onSuccess, onError, layout = "stacked" }) {
|
|
950
1240
|
const { Card, CardContent, CardDescription, CardHeader, CardTitle } = resolveAuthComponents(components);
|
|
951
|
-
const [index, setIndex] =
|
|
952
|
-
const [issued, setIssued] =
|
|
953
|
-
const issuedKey =
|
|
954
|
-
const addIssued =
|
|
1241
|
+
const [index, setIndex] = React6.useState(null);
|
|
1242
|
+
const [issued, setIssued] = React6.useState([]);
|
|
1243
|
+
const issuedKey = React6.useRef(0);
|
|
1244
|
+
const addIssued = React6.useCallback((credential) => {
|
|
955
1245
|
issuedKey.current += 1;
|
|
956
1246
|
const key = issuedKey.current;
|
|
957
1247
|
setIssued((current) => [...current, { key, credential }]);
|
|
958
1248
|
}, []);
|
|
959
|
-
const [loadError, setLoadError] =
|
|
960
|
-
const onErrorRef =
|
|
1249
|
+
const [loadError, setLoadError] = React6.useState(null);
|
|
1250
|
+
const onErrorRef = React6.useRef(onError);
|
|
961
1251
|
onErrorRef.current = onError;
|
|
962
|
-
const generation =
|
|
963
|
-
const context =
|
|
1252
|
+
const generation = React6.useRef(0);
|
|
1253
|
+
const context = React6.useRef({ indexUrl, csrfToken, request });
|
|
964
1254
|
context.current = { indexUrl, csrfToken, request };
|
|
965
|
-
const reload =
|
|
1255
|
+
const reload = React6.useCallback(async () => {
|
|
966
1256
|
generation.current += 1;
|
|
967
1257
|
const mine = generation.current;
|
|
968
1258
|
const { indexUrl: url, csrfToken: token, request: send } = context.current;
|
|
@@ -978,31 +1268,31 @@ function ApiCredentialsSection({ indexUrl, components, links = [], csrfToken, re
|
|
|
978
1268
|
onErrorRef.current?.("api-credentials", result.message);
|
|
979
1269
|
}
|
|
980
1270
|
}, []);
|
|
981
|
-
|
|
1271
|
+
React6.useEffect(() => {
|
|
982
1272
|
setIndex(null);
|
|
983
1273
|
void reload();
|
|
984
1274
|
}, [indexUrl, csrfToken, reload]);
|
|
985
|
-
const removeLocally =
|
|
1275
|
+
const removeLocally = React6.useCallback((list, id) => {
|
|
986
1276
|
setIndex(
|
|
987
1277
|
(current) => current === null ? current : list === "tokens" ? { ...current, tokens: current.tokens.filter((token) => token.id !== id) } : { ...current, apps: current.apps.filter((app) => app.id !== id) }
|
|
988
1278
|
);
|
|
989
1279
|
}, []);
|
|
990
1280
|
const shared = { components, csrfToken, request, onError, onSuccess, removeLocally };
|
|
991
|
-
return /* @__PURE__ */
|
|
992
|
-
/* @__PURE__ */
|
|
993
|
-
/* @__PURE__ */
|
|
994
|
-
/* @__PURE__ */
|
|
1281
|
+
return /* @__PURE__ */ jsxs5(Card, { children: [
|
|
1282
|
+
/* @__PURE__ */ jsxs5(CardHeader, { children: [
|
|
1283
|
+
/* @__PURE__ */ jsx5(CardTitle, { children: "API access" }),
|
|
1284
|
+
/* @__PURE__ */ jsx5(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." })
|
|
995
1285
|
] }),
|
|
996
|
-
/* @__PURE__ */
|
|
997
|
-
links.length > 0 && /* @__PURE__ */
|
|
998
|
-
/* @__PURE__ */
|
|
999
|
-
/* @__PURE__ */
|
|
1000
|
-
/* @__PURE__ */
|
|
1286
|
+
/* @__PURE__ */ jsx5(CardContent, { children: /* @__PURE__ */ jsxs5("div", { style: { display: "grid", gap: "1.5rem", minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1287
|
+
links.length > 0 && /* @__PURE__ */ jsx5("dl", { style: { display: "grid", gap: "0.5rem", minWidth: 0 }, children: links.map((link) => /* @__PURE__ */ jsxs5("div", { style: { minWidth: 0 }, children: [
|
|
1288
|
+
/* @__PURE__ */ jsx5("dt", { children: link.label }),
|
|
1289
|
+
/* @__PURE__ */ jsxs5("dd", { style: { margin: 0, overflowWrap: "anywhere" }, children: [
|
|
1290
|
+
/* @__PURE__ */ jsx5("code", { children: link.url }),
|
|
1001
1291
|
" ",
|
|
1002
|
-
/* @__PURE__ */
|
|
1292
|
+
/* @__PURE__ */ jsx5(CopyButton, { text: link.url, label: link.label, components })
|
|
1003
1293
|
] })
|
|
1004
1294
|
] }, link.label)) }),
|
|
1005
|
-
issued.map(({ key, credential }) => /* @__PURE__ */
|
|
1295
|
+
issued.map(({ key, credential }) => /* @__PURE__ */ jsx5(
|
|
1006
1296
|
IssuedNotice,
|
|
1007
1297
|
{
|
|
1008
1298
|
issued: credential,
|
|
@@ -1011,29 +1301,45 @@ function ApiCredentialsSection({ indexUrl, components, links = [], csrfToken, re
|
|
|
1011
1301
|
},
|
|
1012
1302
|
key
|
|
1013
1303
|
)),
|
|
1014
|
-
loadError !== null && /* @__PURE__ */
|
|
1015
|
-
index !== null && /* @__PURE__ */
|
|
1016
|
-
(index.issue_token_href === null || index.register_app_href === null) && /* @__PURE__ */
|
|
1017
|
-
/* @__PURE__ */
|
|
1018
|
-
|
|
1304
|
+
loadError !== null && /* @__PURE__ */ jsx5("p", { role: "alert", children: loadError }),
|
|
1305
|
+
index !== null && /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
1306
|
+
(index.issue_token_href === null || index.register_app_href === null) && /* @__PURE__ */ jsx5("p", { role: "status", children: "Creating new credentials is unavailable right now. You can still revoke existing ones." }),
|
|
1307
|
+
/* @__PURE__ */ jsxs5(
|
|
1308
|
+
"div",
|
|
1309
|
+
{
|
|
1310
|
+
"data-layout": layout,
|
|
1311
|
+
style: layout === "columns" ? { display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(min(100%, 460px), 1fr))", gap: "1.5rem", alignItems: "start", minWidth: 0 } : { display: "grid", gridTemplateColumns: "minmax(0, 1fr)", gap: "1.5rem", minWidth: 0 },
|
|
1312
|
+
children: [
|
|
1313
|
+
/* @__PURE__ */ jsx5(TokenSection, { index, ...shared, onIssued: addIssued, reload }),
|
|
1314
|
+
/* @__PURE__ */ jsx5(AppSection, { index, ...shared, onIssued: addIssued, reload })
|
|
1315
|
+
]
|
|
1316
|
+
}
|
|
1317
|
+
)
|
|
1019
1318
|
] })
|
|
1020
1319
|
] }) })
|
|
1021
1320
|
] });
|
|
1022
1321
|
}
|
|
1023
1322
|
function TokenSection({ index, components, csrfToken, request, onIssued, reload, onSuccess, onError, removeLocally }) {
|
|
1024
1323
|
const { Button, Input, Label, RadioGroup } = resolveAuthComponents(components);
|
|
1025
|
-
const [name, setName] =
|
|
1026
|
-
const [scopes, setScopes] =
|
|
1027
|
-
const [lifetime, setLifetime] =
|
|
1028
|
-
const
|
|
1029
|
-
|
|
1324
|
+
const [name, setName] = React6.useState("");
|
|
1325
|
+
const [scopes, setScopes] = React6.useState([]);
|
|
1326
|
+
const [lifetime, setLifetime] = React6.useState(index.token_lifetimes[0] ?? "");
|
|
1327
|
+
const tokenScopes = React6.useMemo(
|
|
1328
|
+
() => [...index.token_scopes ?? index.scopes, ...index.token_connection_scopes ?? []],
|
|
1329
|
+
[index.token_scopes, index.scopes, index.token_connection_scopes]
|
|
1330
|
+
);
|
|
1331
|
+
const connectionIds = new Set((index.token_connection_scopes ?? []).map((scope) => scope.id));
|
|
1332
|
+
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;
|
|
1333
|
+
const effectiveLifetime = lifetimes.includes(lifetime) ? lifetime : lifetimes[0] ?? "";
|
|
1334
|
+
const [busy, setBusy] = React6.useState(false);
|
|
1335
|
+
const [error, setError] = React6.useState(null);
|
|
1030
1336
|
async function create(event) {
|
|
1031
1337
|
event.preventDefault();
|
|
1032
1338
|
if (index.issue_token_href === null) {
|
|
1033
1339
|
return;
|
|
1034
1340
|
}
|
|
1035
1341
|
setBusy(true);
|
|
1036
|
-
const result = await credentialRequest("POST", index.issue_token_href, { name, scopes, lifetime }, csrfToken, request);
|
|
1342
|
+
const result = await credentialRequest("POST", index.issue_token_href, { name, scopes, lifetime: effectiveLifetime }, csrfToken, request);
|
|
1037
1343
|
setBusy(false);
|
|
1038
1344
|
if (!result.ok) {
|
|
1039
1345
|
setError(result.message);
|
|
@@ -1047,7 +1353,7 @@ function TokenSection({ index, components, csrfToken, request, onIssued, reload,
|
|
|
1047
1353
|
onSuccess?.("API token created.");
|
|
1048
1354
|
await reload();
|
|
1049
1355
|
}
|
|
1050
|
-
const [pending, setPending] =
|
|
1356
|
+
const [pending, setPending] = React6.useState([]);
|
|
1051
1357
|
async function revoke(token) {
|
|
1052
1358
|
if (pending.includes(token.id)) {
|
|
1053
1359
|
return;
|
|
@@ -1066,54 +1372,67 @@ function TokenSection({ index, components, csrfToken, request, onIssued, reload,
|
|
|
1066
1372
|
await reload();
|
|
1067
1373
|
setPending((current) => current.filter((id) => id !== token.id));
|
|
1068
1374
|
}
|
|
1069
|
-
return /* @__PURE__ */
|
|
1070
|
-
/* @__PURE__ */
|
|
1071
|
-
index.issue_token_href !== null && /* @__PURE__ */
|
|
1072
|
-
/* @__PURE__ */
|
|
1073
|
-
/* @__PURE__ */
|
|
1074
|
-
/* @__PURE__ */
|
|
1375
|
+
return /* @__PURE__ */ jsxs5("section", { style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
|
|
1376
|
+
/* @__PURE__ */ jsx5("h3", { children: "API tokens" }),
|
|
1377
|
+
index.issue_token_href !== null && /* @__PURE__ */ jsxs5("form", { onSubmit: create, style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
|
|
1378
|
+
/* @__PURE__ */ jsxs5("div", { style: { display: "grid", gap: "0.25rem" }, children: [
|
|
1379
|
+
/* @__PURE__ */ jsx5(Label, { htmlFor: "api-token-name", children: "Token name" }),
|
|
1380
|
+
/* @__PURE__ */ jsx5(Input, { id: "api-token-name", value: name, maxLength: 120, onChange: (event) => setName(event.target.value) })
|
|
1075
1381
|
] }),
|
|
1076
|
-
/* @__PURE__ */
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1382
|
+
/* @__PURE__ */ jsx5(
|
|
1383
|
+
ScopePicker,
|
|
1384
|
+
{
|
|
1385
|
+
idPrefix: "api-token-scope",
|
|
1386
|
+
scopes: tokenScopes,
|
|
1387
|
+
groups: index.token_scope_groups ?? index.scope_groups,
|
|
1388
|
+
presets: index.token_scope_presets ?? index.scope_presets,
|
|
1389
|
+
implications: index.token_scope_implications ?? index.scope_implications,
|
|
1390
|
+
selected: scopes,
|
|
1391
|
+
onChange: setScopes,
|
|
1392
|
+
components
|
|
1393
|
+
}
|
|
1394
|
+
),
|
|
1395
|
+
/* @__PURE__ */ jsxs5("fieldset", { style: { display: "grid", gap: "0.25rem", border: 0, padding: 0 }, children: [
|
|
1396
|
+
/* @__PURE__ */ jsx5("legend", { children: "Expires after" }),
|
|
1397
|
+
RadioGroup ? /* @__PURE__ */ jsx5(
|
|
1080
1398
|
RadioGroup,
|
|
1081
1399
|
{
|
|
1082
1400
|
name: "api-token-lifetime",
|
|
1083
|
-
value:
|
|
1401
|
+
value: effectiveLifetime,
|
|
1084
1402
|
onValueChange: setLifetime,
|
|
1085
|
-
options:
|
|
1403
|
+
options: lifetimes.map((spec) => ({ value: spec, label: describeDuration(spec) }))
|
|
1086
1404
|
}
|
|
1087
|
-
) :
|
|
1088
|
-
/* @__PURE__ */
|
|
1405
|
+
) : lifetimes.map((spec) => /* @__PURE__ */ jsxs5("label", { children: [
|
|
1406
|
+
/* @__PURE__ */ jsx5("input", { type: "radio", name: "api-token-lifetime", checked: effectiveLifetime === spec, onChange: () => setLifetime(spec) }),
|
|
1089
1407
|
" ",
|
|
1090
1408
|
describeDuration(spec)
|
|
1091
1409
|
] }, spec))
|
|
1092
1410
|
] }),
|
|
1093
|
-
/* @__PURE__ */
|
|
1411
|
+
/* @__PURE__ */ jsx5("div", { children: /* @__PURE__ */ jsx5(Button, { type: "submit", disabled: busy || name.trim() === "" || scopes.length === 0 || effectiveLifetime === "", children: "Create API token" }) })
|
|
1094
1412
|
] }),
|
|
1095
|
-
error !== null && /* @__PURE__ */
|
|
1096
|
-
/* @__PURE__ */
|
|
1097
|
-
/* @__PURE__ */
|
|
1413
|
+
error !== null && /* @__PURE__ */ jsx5("p", { role: "alert", children: error }),
|
|
1414
|
+
/* @__PURE__ */ jsx5("ul", { style: { display: "grid", gap: "0.5rem", listStyle: "none", padding: 0, margin: 0, minWidth: 0 }, children: index.tokens.map((token) => /* @__PURE__ */ jsxs5("li", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1415
|
+
/* @__PURE__ */ jsx5("strong", { children: token.name }),
|
|
1098
1416
|
" \xB7 ",
|
|
1099
1417
|
token.scopes.join(", "),
|
|
1100
|
-
token.
|
|
1418
|
+
token.connection === true && /* @__PURE__ */ jsx5(Fragment2, { children: " \xB7 MCP connection" }),
|
|
1419
|
+
token.expires_at !== null && /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
1101
1420
|
" \xB7 expires ",
|
|
1102
1421
|
new Date(token.expires_at).toLocaleString()
|
|
1103
1422
|
] }),
|
|
1104
1423
|
" ",
|
|
1105
|
-
/* @__PURE__ */
|
|
1424
|
+
/* @__PURE__ */ jsx5(Button, { type: "button", disabled: pending.includes(token.id), onClick: () => void revoke(token), children: "Revoke" })
|
|
1106
1425
|
] }, token.id)) })
|
|
1107
1426
|
] });
|
|
1108
1427
|
}
|
|
1109
1428
|
function AppSection({ index, components, csrfToken, request, onIssued, reload, onSuccess, onError, removeLocally }) {
|
|
1110
1429
|
const { Button, Input, Label, Textarea, RadioGroup } = resolveAuthComponents(components);
|
|
1111
|
-
const [name, setName] =
|
|
1112
|
-
const [redirects, setRedirects] =
|
|
1113
|
-
const [confidential, setConfidential] =
|
|
1114
|
-
const [scopes, setScopes] =
|
|
1115
|
-
const [busy, setBusy] =
|
|
1116
|
-
const [error, setError] =
|
|
1430
|
+
const [name, setName] = React6.useState("");
|
|
1431
|
+
const [redirects, setRedirects] = React6.useState("");
|
|
1432
|
+
const [confidential, setConfidential] = React6.useState(true);
|
|
1433
|
+
const [scopes, setScopes] = React6.useState([]);
|
|
1434
|
+
const [busy, setBusy] = React6.useState(false);
|
|
1435
|
+
const [error, setError] = React6.useState(null);
|
|
1117
1436
|
const redirectUris = redirects.split("\n").map((line) => line.trim()).filter((line) => line !== "");
|
|
1118
1437
|
async function register(event) {
|
|
1119
1438
|
event.preventDefault();
|
|
@@ -1142,7 +1461,7 @@ function AppSection({ index, components, csrfToken, request, onIssued, reload, o
|
|
|
1142
1461
|
onSuccess?.("OAuth app registered.");
|
|
1143
1462
|
await reload();
|
|
1144
1463
|
}
|
|
1145
|
-
const [pending, setPending] =
|
|
1464
|
+
const [pending, setPending] = React6.useState([]);
|
|
1146
1465
|
async function remove(app) {
|
|
1147
1466
|
if (pending.includes(app.id)) {
|
|
1148
1467
|
return;
|
|
@@ -1161,20 +1480,20 @@ function AppSection({ index, components, csrfToken, request, onIssued, reload, o
|
|
|
1161
1480
|
await reload();
|
|
1162
1481
|
setPending((current) => current.filter((id) => id !== app.id));
|
|
1163
1482
|
}
|
|
1164
|
-
return /* @__PURE__ */
|
|
1165
|
-
/* @__PURE__ */
|
|
1166
|
-
index.register_app_href !== null && /* @__PURE__ */
|
|
1167
|
-
/* @__PURE__ */
|
|
1168
|
-
/* @__PURE__ */
|
|
1169
|
-
/* @__PURE__ */
|
|
1483
|
+
return /* @__PURE__ */ jsxs5("section", { style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
|
|
1484
|
+
/* @__PURE__ */ jsx5("h3", { children: "OAuth apps" }),
|
|
1485
|
+
index.register_app_href !== null && /* @__PURE__ */ jsxs5("form", { onSubmit: register, style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
|
|
1486
|
+
/* @__PURE__ */ jsxs5("div", { style: { display: "grid", gap: "0.25rem" }, children: [
|
|
1487
|
+
/* @__PURE__ */ jsx5(Label, { htmlFor: "oauth-app-name", children: "App name" }),
|
|
1488
|
+
/* @__PURE__ */ jsx5(Input, { id: "oauth-app-name", value: name, maxLength: 120, onChange: (event) => setName(event.target.value) })
|
|
1170
1489
|
] }),
|
|
1171
|
-
/* @__PURE__ */
|
|
1172
|
-
/* @__PURE__ */
|
|
1173
|
-
Textarea ? /* @__PURE__ */
|
|
1490
|
+
/* @__PURE__ */ jsxs5("div", { style: { display: "grid", gap: "0.25rem" }, children: [
|
|
1491
|
+
/* @__PURE__ */ jsx5(Label, { htmlFor: "oauth-app-redirects", children: "Redirect URIs (one per line)" }),
|
|
1492
|
+
Textarea ? /* @__PURE__ */ jsx5(Textarea, { id: "oauth-app-redirects", rows: 3, value: redirects, onChange: (event) => setRedirects(event.target.value) }) : /* @__PURE__ */ jsx5("textarea", { id: "oauth-app-redirects", rows: 3, value: redirects, onChange: (event) => setRedirects(event.target.value) })
|
|
1174
1493
|
] }),
|
|
1175
|
-
/* @__PURE__ */
|
|
1176
|
-
/* @__PURE__ */
|
|
1177
|
-
RadioGroup ? /* @__PURE__ */
|
|
1494
|
+
/* @__PURE__ */ jsxs5("fieldset", { style: { display: "grid", gap: "0.25rem", border: 0, padding: 0 }, children: [
|
|
1495
|
+
/* @__PURE__ */ jsx5("legend", { children: "Client type" }),
|
|
1496
|
+
RadioGroup ? /* @__PURE__ */ jsx5(
|
|
1178
1497
|
RadioGroup,
|
|
1179
1498
|
{
|
|
1180
1499
|
name: "oauth-app-type",
|
|
@@ -1185,60 +1504,49 @@ function AppSection({ index, components, csrfToken, request, onIssued, reload, o
|
|
|
1185
1504
|
{ value: "public", label: "Public: no secret, PKCE only" }
|
|
1186
1505
|
]
|
|
1187
1506
|
}
|
|
1188
|
-
) : /* @__PURE__ */
|
|
1189
|
-
/* @__PURE__ */
|
|
1190
|
-
/* @__PURE__ */
|
|
1507
|
+
) : /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
1508
|
+
/* @__PURE__ */ jsxs5("label", { children: [
|
|
1509
|
+
/* @__PURE__ */ jsx5("input", { type: "radio", name: "oauth-app-type", checked: confidential, onChange: () => setConfidential(true) }),
|
|
1191
1510
|
" Confidential: the app keeps a client secret on its server"
|
|
1192
1511
|
] }),
|
|
1193
|
-
/* @__PURE__ */
|
|
1194
|
-
/* @__PURE__ */
|
|
1512
|
+
/* @__PURE__ */ jsxs5("label", { children: [
|
|
1513
|
+
/* @__PURE__ */ jsx5("input", { type: "radio", name: "oauth-app-type", checked: !confidential, onChange: () => setConfidential(false) }),
|
|
1195
1514
|
" Public: no secret, PKCE only"
|
|
1196
1515
|
] })
|
|
1197
1516
|
] })
|
|
1198
1517
|
] }),
|
|
1199
|
-
/* @__PURE__ */
|
|
1200
|
-
|
|
1518
|
+
/* @__PURE__ */ jsx5(
|
|
1519
|
+
ScopePicker,
|
|
1520
|
+
{
|
|
1521
|
+
idPrefix: "oauth-app-scope",
|
|
1522
|
+
scopes: index.scopes,
|
|
1523
|
+
groups: index.scope_groups,
|
|
1524
|
+
presets: index.scope_presets,
|
|
1525
|
+
implications: index.scope_implications,
|
|
1526
|
+
selected: scopes,
|
|
1527
|
+
onChange: setScopes,
|
|
1528
|
+
components
|
|
1529
|
+
}
|
|
1530
|
+
),
|
|
1531
|
+
/* @__PURE__ */ jsx5("div", { children: /* @__PURE__ */ jsx5(Button, { type: "submit", disabled: busy || name.trim() === "" || redirectUris.length === 0 || scopes.length === 0, children: "Register OAuth app" }) })
|
|
1201
1532
|
] }),
|
|
1202
|
-
error !== null && /* @__PURE__ */
|
|
1203
|
-
/* @__PURE__ */
|
|
1204
|
-
/* @__PURE__ */
|
|
1533
|
+
error !== null && /* @__PURE__ */ jsx5("p", { role: "alert", children: error }),
|
|
1534
|
+
/* @__PURE__ */ jsx5("ul", { style: { display: "grid", gap: "0.5rem", listStyle: "none", padding: 0, margin: 0, minWidth: 0 }, children: index.apps.map((app) => /* @__PURE__ */ jsxs5("li", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1535
|
+
/* @__PURE__ */ jsx5("strong", { children: app.name }),
|
|
1205
1536
|
" \xB7 client ID ",
|
|
1206
|
-
/* @__PURE__ */
|
|
1537
|
+
/* @__PURE__ */ jsx5("code", { children: app.id }),
|
|
1207
1538
|
" \xB7 ",
|
|
1208
1539
|
app.confidential ? "confidential" : "public",
|
|
1209
|
-
/* @__PURE__ */
|
|
1540
|
+
/* @__PURE__ */ jsx5("br", {}),
|
|
1210
1541
|
app.redirect_uris.join(", "),
|
|
1211
|
-
/* @__PURE__ */
|
|
1542
|
+
/* @__PURE__ */ jsx5("br", {}),
|
|
1212
1543
|
"May request: ",
|
|
1213
1544
|
app.scopes.join(", "),
|
|
1214
1545
|
" ",
|
|
1215
|
-
/* @__PURE__ */
|
|
1546
|
+
/* @__PURE__ */ jsx5(Button, { type: "button", disabled: pending.includes(app.id), onClick: () => void remove(app), children: "Delete" })
|
|
1216
1547
|
] }, app.id)) })
|
|
1217
1548
|
] });
|
|
1218
1549
|
}
|
|
1219
|
-
function ScopePicker({
|
|
1220
|
-
idPrefix,
|
|
1221
|
-
scopes,
|
|
1222
|
-
selected,
|
|
1223
|
-
onChange,
|
|
1224
|
-
components
|
|
1225
|
-
}) {
|
|
1226
|
-
const { Checkbox } = resolveAuthComponents(components);
|
|
1227
|
-
const toggle = (scopeId, checked) => onChange(checked ? [...selected, scopeId] : selected.filter((value) => value !== scopeId));
|
|
1228
|
-
return /* @__PURE__ */ jsxs4("fieldset", { style: { display: "grid", gap: "0.25rem", border: 0, padding: 0, minWidth: 0 }, children: [
|
|
1229
|
-
/* @__PURE__ */ jsx4("legend", { children: "Permissions" }),
|
|
1230
|
-
scopes.map((scope) => {
|
|
1231
|
-
const id = `${idPrefix}-${scope.id}`;
|
|
1232
|
-
return /* @__PURE__ */ jsxs4("label", { htmlFor: id, style: { overflowWrap: "anywhere" }, children: [
|
|
1233
|
-
Checkbox ? /* @__PURE__ */ jsx4(Checkbox, { id, checked: selected.includes(scope.id), onCheckedChange: (checked) => toggle(scope.id, checked) }) : /* @__PURE__ */ jsx4("input", { id, type: "checkbox", checked: selected.includes(scope.id), onChange: (event) => toggle(scope.id, event.target.checked) }),
|
|
1234
|
-
" ",
|
|
1235
|
-
/* @__PURE__ */ jsx4("code", { children: scope.id }),
|
|
1236
|
-
" ",
|
|
1237
|
-
scope.description
|
|
1238
|
-
] }, scope.id);
|
|
1239
|
-
})
|
|
1240
|
-
] });
|
|
1241
|
-
}
|
|
1242
1550
|
function IssuedNotice({
|
|
1243
1551
|
issued,
|
|
1244
1552
|
components,
|
|
@@ -1249,26 +1557,26 @@ function IssuedNotice({
|
|
|
1249
1557
|
{ label: "Client ID", url: issued.client_id },
|
|
1250
1558
|
...issued.client_secret !== null ? [{ label: "Client secret", url: issued.client_secret }] : []
|
|
1251
1559
|
];
|
|
1252
|
-
return /* @__PURE__ */
|
|
1253
|
-
/* @__PURE__ */
|
|
1560
|
+
return /* @__PURE__ */ jsxs5("div", { role: "status", style: { display: "grid", gap: "0.5rem", minWidth: 0 }, children: [
|
|
1561
|
+
/* @__PURE__ */ jsxs5("p", { style: { overflowWrap: "anywhere" }, children: [
|
|
1254
1562
|
issued.kind === "token" ? `API token \u201C${issued.name}\u201D created.` : `OAuth app \u201C${issued.name}\u201D registered.`,
|
|
1255
1563
|
" Copy it now: it will not be shown again."
|
|
1256
1564
|
] }),
|
|
1257
|
-
values.map((value) => /* @__PURE__ */
|
|
1565
|
+
values.map((value) => /* @__PURE__ */ jsxs5("div", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1258
1566
|
value.label,
|
|
1259
1567
|
": ",
|
|
1260
|
-
/* @__PURE__ */
|
|
1568
|
+
/* @__PURE__ */ jsx5("code", { children: value.url }),
|
|
1261
1569
|
" ",
|
|
1262
|
-
/* @__PURE__ */
|
|
1570
|
+
/* @__PURE__ */ jsx5(CopyButton, { text: value.url, label: value.label, components })
|
|
1263
1571
|
] }, value.label)),
|
|
1264
|
-
/* @__PURE__ */
|
|
1572
|
+
/* @__PURE__ */ jsx5("div", { children: /* @__PURE__ */ jsx5(Button, { type: "button", onClick: onDismiss, children: "Done" }) })
|
|
1265
1573
|
] });
|
|
1266
1574
|
}
|
|
1267
1575
|
function CopyButton({ text, label, components }) {
|
|
1268
1576
|
const { Button } = resolveAuthComponents(components);
|
|
1269
|
-
const [state, setState] =
|
|
1270
|
-
return /* @__PURE__ */
|
|
1271
|
-
/* @__PURE__ */
|
|
1577
|
+
const [state, setState] = React6.useState("idle");
|
|
1578
|
+
return /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
1579
|
+
/* @__PURE__ */ jsx5(
|
|
1272
1580
|
Button,
|
|
1273
1581
|
{
|
|
1274
1582
|
type: "button",
|
|
@@ -1288,7 +1596,7 @@ function CopyButton({ text, label, components }) {
|
|
|
1288
1596
|
children: state === "copied" ? "Copied" : "Copy"
|
|
1289
1597
|
}
|
|
1290
1598
|
),
|
|
1291
|
-
state === "failed" && /* @__PURE__ */
|
|
1599
|
+
state === "failed" && /* @__PURE__ */ jsx5("span", { role: "status", children: " Copying is unavailable here; select the text and copy it manually." })
|
|
1292
1600
|
] });
|
|
1293
1601
|
}
|
|
1294
1602
|
function describeDuration(spec) {
|
|
@@ -1367,17 +1675,25 @@ export {
|
|
|
1367
1675
|
PasskeySection,
|
|
1368
1676
|
PasswordResetRequestForm,
|
|
1369
1677
|
ResetPasswordForm,
|
|
1678
|
+
ScopePicker,
|
|
1370
1679
|
SignupForm,
|
|
1371
1680
|
TwoFactorForm,
|
|
1372
1681
|
arrayBufferToBase64url,
|
|
1373
1682
|
authenticateWithPasskey,
|
|
1374
1683
|
base64urlToArrayBuffer,
|
|
1684
|
+
closeImplications,
|
|
1375
1685
|
describeDuration,
|
|
1376
1686
|
getCsrfToken,
|
|
1377
1687
|
getDefaultPasskeyName,
|
|
1688
|
+
inCatalogOrder,
|
|
1378
1689
|
isAbortError,
|
|
1379
1690
|
isConditionalMediationAvailable,
|
|
1691
|
+
neededBy,
|
|
1380
1692
|
registerPasskey,
|
|
1381
1693
|
relyingApplicationsFrom,
|
|
1382
|
-
|
|
1694
|
+
restrictImplications,
|
|
1695
|
+
safeApplicationHref,
|
|
1696
|
+
sameSelection,
|
|
1697
|
+
withScopes,
|
|
1698
|
+
withoutScopes
|
|
1383
1699
|
};
|