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.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
|
-
|
|
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,315 @@ 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");
|
|
1004
|
-
function
|
|
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 wrapStyle = { minWidth: 0, overflowWrap: "anywhere" };
|
|
1128
|
+
var mutedStyle = { opacity: 0.7 };
|
|
1129
|
+
var gridStyle = {
|
|
1130
|
+
display: "grid",
|
|
1131
|
+
gridTemplateColumns: "repeat(auto-fill, minmax(min(100%, 300px), 1fr))",
|
|
1132
|
+
gap: "1rem",
|
|
1133
|
+
alignItems: "start"
|
|
1134
|
+
};
|
|
1135
|
+
var boxStyle = { margin: 0, minWidth: 0, border: "1px solid rgba(128, 128, 128, 0.35)", borderRadius: 10, padding: "0.25rem 1rem 0.75rem" };
|
|
1136
|
+
function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected, onChange, components }) {
|
|
1137
|
+
const { Checkbox, Button, Badge, Alert } = resolveAuthComponents(components);
|
|
1138
|
+
const [open, setOpen] = React5.useState({});
|
|
1139
|
+
const catalog = React5.useMemo(() => scopes.map((scope) => scope.id), [scopes]);
|
|
1140
|
+
const closed = React5.useMemo(() => closeImplications(restrictImplications(implications, new Set(catalog))), [implications, catalog]);
|
|
1141
|
+
const layout = React5.useMemo(() => resolveGroups(scopes, groups), [scopes, groups]);
|
|
1142
|
+
const offeredPresets = React5.useMemo(
|
|
1143
|
+
() => (presets ?? []).filter((preset) => preset.scopes.length > 0 && preset.scopes.every((id) => catalog.includes(id))),
|
|
1144
|
+
[presets, catalog]
|
|
1145
|
+
);
|
|
1146
|
+
const cascades = Object.keys(closed).length > 0;
|
|
1147
|
+
const chosen = new Set(selected);
|
|
1148
|
+
const commit = (next) => onChange(inCatalogOrder(next, catalog));
|
|
1149
|
+
const toggle = (id, checked) => {
|
|
1150
|
+
if (layout === null && !cascades) {
|
|
1151
|
+
onChange(checked ? [...selected, id] : selected.filter((value) => value !== id));
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
commit(checked ? withScopes(selected, [id], closed) : withoutScopes(selected, [id], closed));
|
|
1155
|
+
};
|
|
1156
|
+
const renderRow = (scope, grouped) => {
|
|
1157
|
+
const id = `${idPrefix}-${scope.id}`;
|
|
1158
|
+
const needers = neededBy(scope.id, selected, closed);
|
|
1159
|
+
const noteId = `${id}-needed`;
|
|
1160
|
+
const row = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { htmlFor: id, style: grouped ? { ...touchRow, cursor: "pointer" } : { overflowWrap: "anywhere" }, children: [
|
|
1161
|
+
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)(
|
|
1162
|
+
"input",
|
|
1163
|
+
{
|
|
1164
|
+
id,
|
|
1165
|
+
type: "checkbox",
|
|
1166
|
+
checked: chosen.has(scope.id),
|
|
1167
|
+
"aria-describedby": needers.length > 0 ? noteId : void 0,
|
|
1168
|
+
onChange: (event) => toggle(scope.id, event.target.checked),
|
|
1169
|
+
style: grouped ? { flex: "none", width: 16, height: 16, margin: "2px 0 0" } : void 0
|
|
1170
|
+
}
|
|
1171
|
+
),
|
|
1172
|
+
" ",
|
|
1173
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1174
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { style: wrapStyle, children: scope.id }),
|
|
1175
|
+
" ",
|
|
1176
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: mutedStyle, children: scope.description })
|
|
1177
|
+
] })
|
|
1178
|
+
] }, scope.id);
|
|
1179
|
+
if (needers.length === 0) {
|
|
1180
|
+
return row;
|
|
1181
|
+
}
|
|
1182
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { minWidth: 0 }, children: [
|
|
1183
|
+
row,
|
|
1184
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("small", { id: noteId, style: { ...mutedStyle, display: "block", paddingLeft: grouped ? 26 : 0, overflowWrap: "anywhere" }, children: [
|
|
1185
|
+
"needed by ",
|
|
1186
|
+
needers.join(", ")
|
|
1187
|
+
] })
|
|
1188
|
+
] }, scope.id);
|
|
1189
|
+
};
|
|
1190
|
+
if (layout === null) {
|
|
1191
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { style: { display: "grid", gap: "0.25rem", border: 0, padding: 0, minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1192
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { children: "Permissions" }),
|
|
1193
|
+
scopes.map((scope) => renderRow(scope, false))
|
|
1194
|
+
] });
|
|
1195
|
+
}
|
|
1196
|
+
const pressed = offeredPresets.find((preset) => sameSelection(selected, preset.scopes));
|
|
1197
|
+
const plain = layout.filter((group) => !group.sensitive);
|
|
1198
|
+
const sensitive = layout.filter((group) => group.sensitive);
|
|
1199
|
+
const Chip = Badge ?? DefaultBadge;
|
|
1200
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid", gap: "1rem", minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1201
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid", gap: "0.25rem", minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1202
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: "Permissions" }),
|
|
1203
|
+
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." })
|
|
1204
|
+
] }),
|
|
1205
|
+
offeredPresets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid", gap: "0.625rem", minWidth: 0 }, children: [
|
|
1206
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { role: "group", "aria-label": "Presets", style: { display: "flex", flexWrap: "wrap", gap: "0.5rem" }, children: offeredPresets.map((preset) => {
|
|
1207
|
+
const isPressed = pressed?.id === preset.id;
|
|
1208
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1209
|
+
Button,
|
|
1210
|
+
{
|
|
1211
|
+
type: "button",
|
|
1212
|
+
variant: isPressed ? "default" : "outline",
|
|
1213
|
+
"aria-pressed": isPressed,
|
|
1214
|
+
style: { height: "auto", minHeight: 44, minWidth: 0, maxWidth: "100%", overflowWrap: "anywhere", whiteSpace: "normal", textAlign: "left" },
|
|
1215
|
+
onClick: () => commit(withScopes([], preset.scopes, closed)),
|
|
1216
|
+
children: preset.label
|
|
1217
|
+
},
|
|
1218
|
+
preset.id
|
|
1219
|
+
);
|
|
1220
|
+
}) }),
|
|
1221
|
+
/* @__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." })
|
|
1222
|
+
] }),
|
|
1223
|
+
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: [
|
|
1224
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { style: { padding: "0 0.375rem", fontWeight: 600, overflowWrap: "anywhere" }, children: group.label }),
|
|
1225
|
+
group.scopes.map((scope) => renderRow(scope, true))
|
|
1226
|
+
] }, group.id)) }),
|
|
1227
|
+
sensitive.map((group) => {
|
|
1228
|
+
const ids = group.scopes.map((scope) => scope.id);
|
|
1229
|
+
const count = ids.filter((id) => chosen.has(id)).length;
|
|
1230
|
+
const state = count === 0 ? "none" : count === ids.length ? "all" : "some";
|
|
1231
|
+
const parentId = `${idPrefix}-group-${group.id}`;
|
|
1232
|
+
const listId = `${parentId}-scopes`;
|
|
1233
|
+
const isOpen = open[group.id] === true;
|
|
1234
|
+
const warning = group.description !== null && group.description !== "" ? group.description : null;
|
|
1235
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { style: { ...boxStyle, display: "grid", gridTemplateColumns: "minmax(0, 1fr)", gap: "0.375rem", paddingBottom: "0.875rem" }, children: [
|
|
1236
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("legend", { style: { padding: "0 0.375rem", fontWeight: 600, display: "flex", alignItems: "center", gap: "0.5rem", maxWidth: "100%", minWidth: 0 }, children: [
|
|
1237
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { overflowWrap: "anywhere" }, children: group.label }),
|
|
1238
|
+
/* @__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" })
|
|
1239
|
+
] }),
|
|
1240
|
+
warning !== null && (() => {
|
|
1241
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1242
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react3.TriangleAlert, { "aria-hidden": "true", size: 16, style: { flex: "none", marginTop: 2 } }),
|
|
1243
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: warning })
|
|
1244
|
+
] });
|
|
1245
|
+
const style = { margin: "0.25rem 0 0", display: "flex", gap: "0.5rem", alignItems: "flex-start" };
|
|
1246
|
+
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 });
|
|
1247
|
+
})(),
|
|
1248
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { htmlFor: parentId, style: { ...touchRow, cursor: "pointer" }, children: [
|
|
1249
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1250
|
+
"input",
|
|
1251
|
+
{
|
|
1252
|
+
id: parentId,
|
|
1253
|
+
type: "checkbox",
|
|
1254
|
+
checked: state === "all",
|
|
1255
|
+
"aria-checked": state === "some" ? "mixed" : state === "all",
|
|
1256
|
+
ref: (element) => {
|
|
1257
|
+
if (element) {
|
|
1258
|
+
element.indeterminate = state === "some";
|
|
1259
|
+
}
|
|
1260
|
+
},
|
|
1261
|
+
onChange: () => commit(state === "all" ? withoutScopes(selected, ids, closed) : withScopes(selected, ids, closed)),
|
|
1262
|
+
style: { flex: "none", width: 16, height: 16, margin: "2px 0 0" }
|
|
1263
|
+
}
|
|
1264
|
+
),
|
|
1265
|
+
" ",
|
|
1266
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1267
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: group.label }),
|
|
1268
|
+
" ",
|
|
1269
|
+
/* @__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.` })
|
|
1270
|
+
] })
|
|
1271
|
+
] }),
|
|
1272
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1273
|
+
Button,
|
|
1274
|
+
{
|
|
1275
|
+
type: "button",
|
|
1276
|
+
variant: "ghost",
|
|
1277
|
+
"aria-expanded": isOpen,
|
|
1278
|
+
"aria-controls": listId,
|
|
1279
|
+
style: { height: "auto", minHeight: 44, minWidth: 0, maxWidth: "100%", overflowWrap: "anywhere", whiteSpace: "normal", textAlign: "left" },
|
|
1280
|
+
onClick: () => setOpen((current) => ({ ...current, [group.id]: !isOpen })),
|
|
1281
|
+
children: [
|
|
1282
|
+
/* @__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" } }),
|
|
1283
|
+
isOpen ? "Hide" : "Adjust",
|
|
1284
|
+
" individual ",
|
|
1285
|
+
group.label,
|
|
1286
|
+
" permissions"
|
|
1287
|
+
]
|
|
1288
|
+
}
|
|
1289
|
+
) }),
|
|
1290
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("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)) })
|
|
1291
|
+
] }, group.id);
|
|
1292
|
+
}),
|
|
1293
|
+
/* @__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: [
|
|
1294
|
+
/* @__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"}:` }),
|
|
1295
|
+
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)) })
|
|
1296
|
+
] })
|
|
1297
|
+
] });
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
// src/api-credentials-section.tsx
|
|
1301
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1302
|
+
function ApiCredentialsSection({ indexUrl, components, links = [], csrfToken, request, onSuccess, onError, layout = "stacked" }) {
|
|
1005
1303
|
const { Card, CardContent, CardDescription, CardHeader, CardTitle } = resolveAuthComponents(components);
|
|
1006
|
-
const [index, setIndex] =
|
|
1007
|
-
const [issued, setIssued] =
|
|
1008
|
-
const issuedKey =
|
|
1009
|
-
const addIssued =
|
|
1304
|
+
const [index, setIndex] = React6.useState(null);
|
|
1305
|
+
const [issued, setIssued] = React6.useState([]);
|
|
1306
|
+
const issuedKey = React6.useRef(0);
|
|
1307
|
+
const addIssued = React6.useCallback((credential) => {
|
|
1010
1308
|
issuedKey.current += 1;
|
|
1011
1309
|
const key = issuedKey.current;
|
|
1012
1310
|
setIssued((current) => [...current, { key, credential }]);
|
|
1013
1311
|
}, []);
|
|
1014
|
-
const [loadError, setLoadError] =
|
|
1015
|
-
const onErrorRef =
|
|
1312
|
+
const [loadError, setLoadError] = React6.useState(null);
|
|
1313
|
+
const onErrorRef = React6.useRef(onError);
|
|
1016
1314
|
onErrorRef.current = onError;
|
|
1017
|
-
const generation =
|
|
1018
|
-
const context =
|
|
1315
|
+
const generation = React6.useRef(0);
|
|
1316
|
+
const context = React6.useRef({ indexUrl, csrfToken, request });
|
|
1019
1317
|
context.current = { indexUrl, csrfToken, request };
|
|
1020
|
-
const reload =
|
|
1318
|
+
const reload = React6.useCallback(async () => {
|
|
1021
1319
|
generation.current += 1;
|
|
1022
1320
|
const mine = generation.current;
|
|
1023
1321
|
const { indexUrl: url, csrfToken: token, request: send } = context.current;
|
|
@@ -1033,31 +1331,31 @@ function ApiCredentialsSection({ indexUrl, components, links = [], csrfToken, re
|
|
|
1033
1331
|
onErrorRef.current?.("api-credentials", result.message);
|
|
1034
1332
|
}
|
|
1035
1333
|
}, []);
|
|
1036
|
-
|
|
1334
|
+
React6.useEffect(() => {
|
|
1037
1335
|
setIndex(null);
|
|
1038
1336
|
void reload();
|
|
1039
1337
|
}, [indexUrl, csrfToken, reload]);
|
|
1040
|
-
const removeLocally =
|
|
1338
|
+
const removeLocally = React6.useCallback((list, id) => {
|
|
1041
1339
|
setIndex(
|
|
1042
1340
|
(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
1341
|
);
|
|
1044
1342
|
}, []);
|
|
1045
1343
|
const shared = { components, csrfToken, request, onError, onSuccess, removeLocally };
|
|
1046
|
-
return /* @__PURE__ */ (0,
|
|
1047
|
-
/* @__PURE__ */ (0,
|
|
1048
|
-
/* @__PURE__ */ (0,
|
|
1049
|
-
/* @__PURE__ */ (0,
|
|
1344
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Card, { children: [
|
|
1345
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(CardHeader, { children: [
|
|
1346
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CardTitle, { children: "API access" }),
|
|
1347
|
+
/* @__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
1348
|
] }),
|
|
1051
|
-
/* @__PURE__ */ (0,
|
|
1052
|
-
links.length > 0 && /* @__PURE__ */ (0,
|
|
1053
|
-
/* @__PURE__ */ (0,
|
|
1054
|
-
/* @__PURE__ */ (0,
|
|
1055
|
-
/* @__PURE__ */ (0,
|
|
1349
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CardContent, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "grid", gap: "1.5rem", minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1350
|
+
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: [
|
|
1351
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("dt", { children: link.label }),
|
|
1352
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("dd", { style: { margin: 0, overflowWrap: "anywhere" }, children: [
|
|
1353
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("code", { children: link.url }),
|
|
1056
1354
|
" ",
|
|
1057
|
-
/* @__PURE__ */ (0,
|
|
1355
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CopyButton, { text: link.url, label: link.label, components })
|
|
1058
1356
|
] })
|
|
1059
1357
|
] }, link.label)) }),
|
|
1060
|
-
issued.map(({ key, credential }) => /* @__PURE__ */ (0,
|
|
1358
|
+
issued.map(({ key, credential }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1061
1359
|
IssuedNotice,
|
|
1062
1360
|
{
|
|
1063
1361
|
issued: credential,
|
|
@@ -1066,29 +1364,45 @@ function ApiCredentialsSection({ indexUrl, components, links = [], csrfToken, re
|
|
|
1066
1364
|
},
|
|
1067
1365
|
key
|
|
1068
1366
|
)),
|
|
1069
|
-
loadError !== null && /* @__PURE__ */ (0,
|
|
1070
|
-
index !== null && /* @__PURE__ */ (0,
|
|
1071
|
-
(index.issue_token_href === null || index.register_app_href === null) && /* @__PURE__ */ (0,
|
|
1072
|
-
/* @__PURE__ */ (0,
|
|
1073
|
-
|
|
1367
|
+
loadError !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { role: "alert", children: loadError }),
|
|
1368
|
+
index !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1369
|
+
(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." }),
|
|
1370
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1371
|
+
"div",
|
|
1372
|
+
{
|
|
1373
|
+
"data-layout": layout,
|
|
1374
|
+
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 },
|
|
1375
|
+
children: [
|
|
1376
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TokenSection, { index, ...shared, onIssued: addIssued, reload }),
|
|
1377
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AppSection, { index, ...shared, onIssued: addIssued, reload })
|
|
1378
|
+
]
|
|
1379
|
+
}
|
|
1380
|
+
)
|
|
1074
1381
|
] })
|
|
1075
1382
|
] }) })
|
|
1076
1383
|
] });
|
|
1077
1384
|
}
|
|
1078
1385
|
function TokenSection({ index, components, csrfToken, request, onIssued, reload, onSuccess, onError, removeLocally }) {
|
|
1079
1386
|
const { Button, Input, Label, RadioGroup } = resolveAuthComponents(components);
|
|
1080
|
-
const [name, setName] =
|
|
1081
|
-
const [scopes, setScopes] =
|
|
1082
|
-
const [lifetime, setLifetime] =
|
|
1083
|
-
const
|
|
1084
|
-
|
|
1387
|
+
const [name, setName] = React6.useState("");
|
|
1388
|
+
const [scopes, setScopes] = React6.useState([]);
|
|
1389
|
+
const [lifetime, setLifetime] = React6.useState(index.token_lifetimes[0] ?? "");
|
|
1390
|
+
const tokenScopes = React6.useMemo(
|
|
1391
|
+
() => [...index.token_scopes ?? index.scopes, ...index.token_connection_scopes ?? []],
|
|
1392
|
+
[index.token_scopes, index.scopes, index.token_connection_scopes]
|
|
1393
|
+
);
|
|
1394
|
+
const connectionIds = new Set((index.token_connection_scopes ?? []).map((scope) => scope.id));
|
|
1395
|
+
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;
|
|
1396
|
+
const effectiveLifetime = lifetimes.includes(lifetime) ? lifetime : lifetimes[0] ?? "";
|
|
1397
|
+
const [busy, setBusy] = React6.useState(false);
|
|
1398
|
+
const [error, setError] = React6.useState(null);
|
|
1085
1399
|
async function create(event) {
|
|
1086
1400
|
event.preventDefault();
|
|
1087
1401
|
if (index.issue_token_href === null) {
|
|
1088
1402
|
return;
|
|
1089
1403
|
}
|
|
1090
1404
|
setBusy(true);
|
|
1091
|
-
const result = await credentialRequest("POST", index.issue_token_href, { name, scopes, lifetime }, csrfToken, request);
|
|
1405
|
+
const result = await credentialRequest("POST", index.issue_token_href, { name, scopes, lifetime: effectiveLifetime }, csrfToken, request);
|
|
1092
1406
|
setBusy(false);
|
|
1093
1407
|
if (!result.ok) {
|
|
1094
1408
|
setError(result.message);
|
|
@@ -1102,7 +1416,7 @@ function TokenSection({ index, components, csrfToken, request, onIssued, reload,
|
|
|
1102
1416
|
onSuccess?.("API token created.");
|
|
1103
1417
|
await reload();
|
|
1104
1418
|
}
|
|
1105
|
-
const [pending, setPending] =
|
|
1419
|
+
const [pending, setPending] = React6.useState([]);
|
|
1106
1420
|
async function revoke(token) {
|
|
1107
1421
|
if (pending.includes(token.id)) {
|
|
1108
1422
|
return;
|
|
@@ -1121,54 +1435,67 @@ function TokenSection({ index, components, csrfToken, request, onIssued, reload,
|
|
|
1121
1435
|
await reload();
|
|
1122
1436
|
setPending((current) => current.filter((id) => id !== token.id));
|
|
1123
1437
|
}
|
|
1124
|
-
return /* @__PURE__ */ (0,
|
|
1125
|
-
/* @__PURE__ */ (0,
|
|
1126
|
-
index.issue_token_href !== null && /* @__PURE__ */ (0,
|
|
1127
|
-
/* @__PURE__ */ (0,
|
|
1128
|
-
/* @__PURE__ */ (0,
|
|
1129
|
-
/* @__PURE__ */ (0,
|
|
1438
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
|
|
1439
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { children: "API tokens" }),
|
|
1440
|
+
index.issue_token_href !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("form", { onSubmit: create, style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
|
|
1441
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "grid", gap: "0.25rem" }, children: [
|
|
1442
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Label, { htmlFor: "api-token-name", children: "Token name" }),
|
|
1443
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Input, { id: "api-token-name", value: name, maxLength: 120, onChange: (event) => setName(event.target.value) })
|
|
1130
1444
|
] }),
|
|
1131
|
-
/* @__PURE__ */ (0,
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1445
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1446
|
+
ScopePicker,
|
|
1447
|
+
{
|
|
1448
|
+
idPrefix: "api-token-scope",
|
|
1449
|
+
scopes: tokenScopes,
|
|
1450
|
+
groups: index.token_scope_groups ?? index.scope_groups,
|
|
1451
|
+
presets: index.token_scope_presets ?? index.scope_presets,
|
|
1452
|
+
implications: index.token_scope_implications ?? index.scope_implications,
|
|
1453
|
+
selected: scopes,
|
|
1454
|
+
onChange: setScopes,
|
|
1455
|
+
components
|
|
1456
|
+
}
|
|
1457
|
+
),
|
|
1458
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("fieldset", { style: { display: "grid", gap: "0.25rem", border: 0, padding: 0 }, children: [
|
|
1459
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("legend", { children: "Expires after" }),
|
|
1460
|
+
RadioGroup ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1135
1461
|
RadioGroup,
|
|
1136
1462
|
{
|
|
1137
1463
|
name: "api-token-lifetime",
|
|
1138
|
-
value:
|
|
1464
|
+
value: effectiveLifetime,
|
|
1139
1465
|
onValueChange: setLifetime,
|
|
1140
|
-
options:
|
|
1466
|
+
options: lifetimes.map((spec) => ({ value: spec, label: describeDuration(spec) }))
|
|
1141
1467
|
}
|
|
1142
|
-
) :
|
|
1143
|
-
/* @__PURE__ */ (0,
|
|
1468
|
+
) : lifetimes.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { children: [
|
|
1469
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "radio", name: "api-token-lifetime", checked: effectiveLifetime === spec, onChange: () => setLifetime(spec) }),
|
|
1144
1470
|
" ",
|
|
1145
1471
|
describeDuration(spec)
|
|
1146
1472
|
] }, spec))
|
|
1147
1473
|
] }),
|
|
1148
|
-
/* @__PURE__ */ (0,
|
|
1474
|
+
/* @__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
1475
|
] }),
|
|
1150
|
-
error !== null && /* @__PURE__ */ (0,
|
|
1151
|
-
/* @__PURE__ */ (0,
|
|
1152
|
-
/* @__PURE__ */ (0,
|
|
1476
|
+
error !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { role: "alert", children: error }),
|
|
1477
|
+
/* @__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: [
|
|
1478
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("strong", { children: token.name }),
|
|
1153
1479
|
" \xB7 ",
|
|
1154
1480
|
token.scopes.join(", "),
|
|
1155
|
-
token.
|
|
1481
|
+
token.connection === true && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: " \xB7 MCP connection" }),
|
|
1482
|
+
token.expires_at !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1156
1483
|
" \xB7 expires ",
|
|
1157
1484
|
new Date(token.expires_at).toLocaleString()
|
|
1158
1485
|
] }),
|
|
1159
1486
|
" ",
|
|
1160
|
-
/* @__PURE__ */ (0,
|
|
1487
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Button, { type: "button", disabled: pending.includes(token.id), onClick: () => void revoke(token), children: "Revoke" })
|
|
1161
1488
|
] }, token.id)) })
|
|
1162
1489
|
] });
|
|
1163
1490
|
}
|
|
1164
1491
|
function AppSection({ index, components, csrfToken, request, onIssued, reload, onSuccess, onError, removeLocally }) {
|
|
1165
1492
|
const { Button, Input, Label, Textarea, RadioGroup } = resolveAuthComponents(components);
|
|
1166
|
-
const [name, setName] =
|
|
1167
|
-
const [redirects, setRedirects] =
|
|
1168
|
-
const [confidential, setConfidential] =
|
|
1169
|
-
const [scopes, setScopes] =
|
|
1170
|
-
const [busy, setBusy] =
|
|
1171
|
-
const [error, setError] =
|
|
1493
|
+
const [name, setName] = React6.useState("");
|
|
1494
|
+
const [redirects, setRedirects] = React6.useState("");
|
|
1495
|
+
const [confidential, setConfidential] = React6.useState(true);
|
|
1496
|
+
const [scopes, setScopes] = React6.useState([]);
|
|
1497
|
+
const [busy, setBusy] = React6.useState(false);
|
|
1498
|
+
const [error, setError] = React6.useState(null);
|
|
1172
1499
|
const redirectUris = redirects.split("\n").map((line) => line.trim()).filter((line) => line !== "");
|
|
1173
1500
|
async function register(event) {
|
|
1174
1501
|
event.preventDefault();
|
|
@@ -1197,7 +1524,7 @@ function AppSection({ index, components, csrfToken, request, onIssued, reload, o
|
|
|
1197
1524
|
onSuccess?.("OAuth app registered.");
|
|
1198
1525
|
await reload();
|
|
1199
1526
|
}
|
|
1200
|
-
const [pending, setPending] =
|
|
1527
|
+
const [pending, setPending] = React6.useState([]);
|
|
1201
1528
|
async function remove(app) {
|
|
1202
1529
|
if (pending.includes(app.id)) {
|
|
1203
1530
|
return;
|
|
@@ -1216,20 +1543,20 @@ function AppSection({ index, components, csrfToken, request, onIssued, reload, o
|
|
|
1216
1543
|
await reload();
|
|
1217
1544
|
setPending((current) => current.filter((id) => id !== app.id));
|
|
1218
1545
|
}
|
|
1219
|
-
return /* @__PURE__ */ (0,
|
|
1220
|
-
/* @__PURE__ */ (0,
|
|
1221
|
-
index.register_app_href !== null && /* @__PURE__ */ (0,
|
|
1222
|
-
/* @__PURE__ */ (0,
|
|
1223
|
-
/* @__PURE__ */ (0,
|
|
1224
|
-
/* @__PURE__ */ (0,
|
|
1546
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
|
|
1547
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { children: "OAuth apps" }),
|
|
1548
|
+
index.register_app_href !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("form", { onSubmit: register, style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
|
|
1549
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "grid", gap: "0.25rem" }, children: [
|
|
1550
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Label, { htmlFor: "oauth-app-name", children: "App name" }),
|
|
1551
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Input, { id: "oauth-app-name", value: name, maxLength: 120, onChange: (event) => setName(event.target.value) })
|
|
1225
1552
|
] }),
|
|
1226
|
-
/* @__PURE__ */ (0,
|
|
1227
|
-
/* @__PURE__ */ (0,
|
|
1228
|
-
Textarea ? /* @__PURE__ */ (0,
|
|
1553
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "grid", gap: "0.25rem" }, children: [
|
|
1554
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Label, { htmlFor: "oauth-app-redirects", children: "Redirect URIs (one per line)" }),
|
|
1555
|
+
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
1556
|
] }),
|
|
1230
|
-
/* @__PURE__ */ (0,
|
|
1231
|
-
/* @__PURE__ */ (0,
|
|
1232
|
-
RadioGroup ? /* @__PURE__ */ (0,
|
|
1557
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("fieldset", { style: { display: "grid", gap: "0.25rem", border: 0, padding: 0 }, children: [
|
|
1558
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("legend", { children: "Client type" }),
|
|
1559
|
+
RadioGroup ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1233
1560
|
RadioGroup,
|
|
1234
1561
|
{
|
|
1235
1562
|
name: "oauth-app-type",
|
|
@@ -1240,60 +1567,49 @@ function AppSection({ index, components, csrfToken, request, onIssued, reload, o
|
|
|
1240
1567
|
{ value: "public", label: "Public: no secret, PKCE only" }
|
|
1241
1568
|
]
|
|
1242
1569
|
}
|
|
1243
|
-
) : /* @__PURE__ */ (0,
|
|
1244
|
-
/* @__PURE__ */ (0,
|
|
1245
|
-
/* @__PURE__ */ (0,
|
|
1570
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1571
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { children: [
|
|
1572
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "radio", name: "oauth-app-type", checked: confidential, onChange: () => setConfidential(true) }),
|
|
1246
1573
|
" Confidential: the app keeps a client secret on its server"
|
|
1247
1574
|
] }),
|
|
1248
|
-
/* @__PURE__ */ (0,
|
|
1249
|
-
/* @__PURE__ */ (0,
|
|
1575
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { children: [
|
|
1576
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "radio", name: "oauth-app-type", checked: !confidential, onChange: () => setConfidential(false) }),
|
|
1250
1577
|
" Public: no secret, PKCE only"
|
|
1251
1578
|
] })
|
|
1252
1579
|
] })
|
|
1253
1580
|
] }),
|
|
1254
|
-
/* @__PURE__ */ (0,
|
|
1255
|
-
|
|
1581
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1582
|
+
ScopePicker,
|
|
1583
|
+
{
|
|
1584
|
+
idPrefix: "oauth-app-scope",
|
|
1585
|
+
scopes: index.scopes,
|
|
1586
|
+
groups: index.scope_groups,
|
|
1587
|
+
presets: index.scope_presets,
|
|
1588
|
+
implications: index.scope_implications,
|
|
1589
|
+
selected: scopes,
|
|
1590
|
+
onChange: setScopes,
|
|
1591
|
+
components
|
|
1592
|
+
}
|
|
1593
|
+
),
|
|
1594
|
+
/* @__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
1595
|
] }),
|
|
1257
|
-
error !== null && /* @__PURE__ */ (0,
|
|
1258
|
-
/* @__PURE__ */ (0,
|
|
1259
|
-
/* @__PURE__ */ (0,
|
|
1596
|
+
error !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { role: "alert", children: error }),
|
|
1597
|
+
/* @__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: [
|
|
1598
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("strong", { children: app.name }),
|
|
1260
1599
|
" \xB7 client ID ",
|
|
1261
|
-
/* @__PURE__ */ (0,
|
|
1600
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("code", { children: app.id }),
|
|
1262
1601
|
" \xB7 ",
|
|
1263
1602
|
app.confidential ? "confidential" : "public",
|
|
1264
|
-
/* @__PURE__ */ (0,
|
|
1603
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("br", {}),
|
|
1265
1604
|
app.redirect_uris.join(", "),
|
|
1266
|
-
/* @__PURE__ */ (0,
|
|
1605
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("br", {}),
|
|
1267
1606
|
"May request: ",
|
|
1268
1607
|
app.scopes.join(", "),
|
|
1269
1608
|
" ",
|
|
1270
|
-
/* @__PURE__ */ (0,
|
|
1609
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Button, { type: "button", disabled: pending.includes(app.id), onClick: () => void remove(app), children: "Delete" })
|
|
1271
1610
|
] }, app.id)) })
|
|
1272
1611
|
] });
|
|
1273
1612
|
}
|
|
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
1613
|
function IssuedNotice({
|
|
1298
1614
|
issued,
|
|
1299
1615
|
components,
|
|
@@ -1304,26 +1620,26 @@ function IssuedNotice({
|
|
|
1304
1620
|
{ label: "Client ID", url: issued.client_id },
|
|
1305
1621
|
...issued.client_secret !== null ? [{ label: "Client secret", url: issued.client_secret }] : []
|
|
1306
1622
|
];
|
|
1307
|
-
return /* @__PURE__ */ (0,
|
|
1308
|
-
/* @__PURE__ */ (0,
|
|
1623
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { role: "status", style: { display: "grid", gap: "0.5rem", minWidth: 0 }, children: [
|
|
1624
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { style: { overflowWrap: "anywhere" }, children: [
|
|
1309
1625
|
issued.kind === "token" ? `API token \u201C${issued.name}\u201D created.` : `OAuth app \u201C${issued.name}\u201D registered.`,
|
|
1310
1626
|
" Copy it now: it will not be shown again."
|
|
1311
1627
|
] }),
|
|
1312
|
-
values.map((value) => /* @__PURE__ */ (0,
|
|
1628
|
+
values.map((value) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1313
1629
|
value.label,
|
|
1314
1630
|
": ",
|
|
1315
|
-
/* @__PURE__ */ (0,
|
|
1631
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("code", { children: value.url }),
|
|
1316
1632
|
" ",
|
|
1317
|
-
/* @__PURE__ */ (0,
|
|
1633
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CopyButton, { text: value.url, label: value.label, components })
|
|
1318
1634
|
] }, value.label)),
|
|
1319
|
-
/* @__PURE__ */ (0,
|
|
1635
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Button, { type: "button", onClick: onDismiss, children: "Done" }) })
|
|
1320
1636
|
] });
|
|
1321
1637
|
}
|
|
1322
1638
|
function CopyButton({ text, label, components }) {
|
|
1323
1639
|
const { Button } = resolveAuthComponents(components);
|
|
1324
|
-
const [state, setState] =
|
|
1325
|
-
return /* @__PURE__ */ (0,
|
|
1326
|
-
/* @__PURE__ */ (0,
|
|
1640
|
+
const [state, setState] = React6.useState("idle");
|
|
1641
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1642
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1327
1643
|
Button,
|
|
1328
1644
|
{
|
|
1329
1645
|
type: "button",
|
|
@@ -1343,7 +1659,7 @@ function CopyButton({ text, label, components }) {
|
|
|
1343
1659
|
children: state === "copied" ? "Copied" : "Copy"
|
|
1344
1660
|
}
|
|
1345
1661
|
),
|
|
1346
|
-
state === "failed" && /* @__PURE__ */ (0,
|
|
1662
|
+
state === "failed" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { role: "status", children: " Copying is unavailable here; select the text and copy it manually." })
|
|
1347
1663
|
] });
|
|
1348
1664
|
}
|
|
1349
1665
|
function describeDuration(spec) {
|
|
@@ -1423,17 +1739,25 @@ function refusalMessage(status, payload) {
|
|
|
1423
1739
|
PasskeySection,
|
|
1424
1740
|
PasswordResetRequestForm,
|
|
1425
1741
|
ResetPasswordForm,
|
|
1742
|
+
ScopePicker,
|
|
1426
1743
|
SignupForm,
|
|
1427
1744
|
TwoFactorForm,
|
|
1428
1745
|
arrayBufferToBase64url,
|
|
1429
1746
|
authenticateWithPasskey,
|
|
1430
1747
|
base64urlToArrayBuffer,
|
|
1748
|
+
closeImplications,
|
|
1431
1749
|
describeDuration,
|
|
1432
1750
|
getCsrfToken,
|
|
1433
1751
|
getDefaultPasskeyName,
|
|
1752
|
+
inCatalogOrder,
|
|
1434
1753
|
isAbortError,
|
|
1435
1754
|
isConditionalMediationAvailable,
|
|
1755
|
+
neededBy,
|
|
1436
1756
|
registerPasskey,
|
|
1437
1757
|
relyingApplicationsFrom,
|
|
1438
|
-
|
|
1758
|
+
restrictImplications,
|
|
1759
|
+
safeApplicationHref,
|
|
1760
|
+
sameSelection,
|
|
1761
|
+
withScopes,
|
|
1762
|
+
withoutScopes
|
|
1439
1763
|
});
|