bwh-auth 0.6.0 → 0.6.2
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 +8 -0
- package/dist/index.cjs +46 -25
- package/dist/index.d.cts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +46 -25
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -172,6 +172,14 @@ import { SignupForm, registerPasskey } from 'bwh-auth'
|
|
|
172
172
|
|
|
173
173
|
Within `LoginForm`, explicit passkey login cancels and waits for conditional autofill before requesting a credential. Password submission and unmount also cancel pending passkey authentication. Autofill pauses after a manual sign-in attempt until the form is remounted. Changing consumer callbacks does not restart autofill.
|
|
174
174
|
|
|
175
|
+
As of 0.6.2, both passkey paths honor the form's current "Keep me signed in"
|
|
176
|
+
choice. Standalone `PasskeyLoginButton` and `authenticateWithPasskey` accept an
|
|
177
|
+
optional `remember` boolean or getter. The getter runs after the browser returns
|
|
178
|
+
a credential, immediately before posting it, so a long-running autofill request
|
|
179
|
+
uses the person's latest choice. Omitted helper options keep the previous
|
|
180
|
+
request shape. The server must support the optional `remember` field to issue a
|
|
181
|
+
persistent login cookie; older servers continue to authenticate per session.
|
|
182
|
+
|
|
175
183
|
When `PasskeyLoginButton` receives `onError`, the consumer owns error display; without it, the button displays its own error.
|
|
176
184
|
|
|
177
185
|
Consumers can preserve app-specific login state and design-system checkboxes
|
package/dist/index.cjs
CHANGED
|
@@ -154,7 +154,7 @@ async function isConditionalMediationAvailable() {
|
|
|
154
154
|
return false;
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
async function authenticateWithPasskey({ endpoints = {}, mediation, signal } = {}) {
|
|
157
|
+
async function authenticateWithPasskey({ endpoints = {}, mediation, signal, remember } = {}) {
|
|
158
158
|
const authOptionsUrl = endpoints.passkeyAuthOptions ?? "/api/passkeys/auth/options";
|
|
159
159
|
const authUrl = endpoints.passkeyAuth ?? "/api/passkeys/auth";
|
|
160
160
|
const optRes = await fetch(authOptionsUrl, {
|
|
@@ -202,7 +202,10 @@ async function authenticateWithPasskey({ endpoints = {}, mediation, signal } = {
|
|
|
202
202
|
"Content-Type": "application/json",
|
|
203
203
|
"X-CSRF-TOKEN": getCsrfToken(endpoints.csrfToken)
|
|
204
204
|
},
|
|
205
|
-
body: JSON.stringify({
|
|
205
|
+
body: JSON.stringify({
|
|
206
|
+
credential: credentialData,
|
|
207
|
+
...remember === void 0 ? {} : { remember: typeof remember === "function" ? remember() : remember }
|
|
208
|
+
}),
|
|
206
209
|
signal
|
|
207
210
|
});
|
|
208
211
|
const result = await authRes.json();
|
|
@@ -313,7 +316,7 @@ function usePasskeyAuthentication() {
|
|
|
313
316
|
var import_lucide_react = require("lucide-react");
|
|
314
317
|
var React2 = __toESM(require("react"), 1);
|
|
315
318
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
316
|
-
function PasskeyLoginButton({ endpoints = {}, components, className, disabled = false, onSuccess, onError }) {
|
|
319
|
+
function PasskeyLoginButton({ endpoints = {}, components, className, disabled = false, remember, onSuccess, onError }) {
|
|
317
320
|
const { Button } = resolveAuthButtonComponent(components);
|
|
318
321
|
const [loading, setLoading] = React2.useState(false);
|
|
319
322
|
const [error, setError] = React2.useState(null);
|
|
@@ -321,9 +324,9 @@ function PasskeyLoginButton({ endpoints = {}, components, className, disabled =
|
|
|
321
324
|
const authentication = React2.useContext(PasskeyAuthenticationContext) ?? localAuthentication;
|
|
322
325
|
const inFlight = React2.useRef(false);
|
|
323
326
|
const mounted = React2.useRef(true);
|
|
324
|
-
const callbacks = React2.useRef({ onSuccess, onError });
|
|
327
|
+
const callbacks = React2.useRef({ onSuccess, onError, remember });
|
|
325
328
|
React2.useLayoutEffect(() => {
|
|
326
|
-
callbacks.current = { onSuccess, onError };
|
|
329
|
+
callbacks.current = { onSuccess, onError, remember };
|
|
327
330
|
});
|
|
328
331
|
React2.useEffect(() => {
|
|
329
332
|
mounted.current = true;
|
|
@@ -338,7 +341,13 @@ function PasskeyLoginButton({ endpoints = {}, components, className, disabled =
|
|
|
338
341
|
setError(null);
|
|
339
342
|
setLoading(true);
|
|
340
343
|
try {
|
|
341
|
-
const { redirectUrl, result } = await authentication.authenticate({
|
|
344
|
+
const { redirectUrl, result } = await authentication.authenticate({
|
|
345
|
+
endpoints,
|
|
346
|
+
remember: () => {
|
|
347
|
+
const choice = callbacks.current.remember;
|
|
348
|
+
return typeof choice === "function" ? choice() : choice ?? false;
|
|
349
|
+
}
|
|
350
|
+
});
|
|
342
351
|
if (!mounted.current) return;
|
|
343
352
|
if (callbacks.current.onSuccess) {
|
|
344
353
|
callbacks.current.onSuccess(redirectUrl, result);
|
|
@@ -440,9 +449,9 @@ function LoginForm({
|
|
|
440
449
|
const passkeyAuthentication = usePasskeyAuthentication();
|
|
441
450
|
const conditionalInterrupted = React3.useRef(false);
|
|
442
451
|
const submitting = React3.useRef(false);
|
|
443
|
-
const callbacks = React3.useRef({ onError, onPasskeySuccess });
|
|
452
|
+
const callbacks = React3.useRef({ onError, onPasskeySuccess, remember });
|
|
444
453
|
React3.useLayoutEffect(() => {
|
|
445
|
-
callbacks.current = { onError, onPasskeySuccess };
|
|
454
|
+
callbacks.current = { onError, onPasskeySuccess, remember };
|
|
446
455
|
});
|
|
447
456
|
const coordinatedAuthentication = React3.useMemo(() => ({
|
|
448
457
|
...passkeyAuthentication,
|
|
@@ -467,7 +476,8 @@ function LoginForm({
|
|
|
467
476
|
try {
|
|
468
477
|
const { redirectUrl, result } = await coordinatedAuthentication.authenticate({
|
|
469
478
|
endpoints: passkeyEndpoints,
|
|
470
|
-
mediation: "conditional"
|
|
479
|
+
mediation: "conditional",
|
|
480
|
+
remember: () => callbacks.current.remember
|
|
471
481
|
});
|
|
472
482
|
if (!active) return;
|
|
473
483
|
if (callbacks.current.onPasskeySuccess) {
|
|
@@ -559,6 +569,7 @@ function LoginForm({
|
|
|
559
569
|
components: { Button },
|
|
560
570
|
endpoints,
|
|
561
571
|
disabled: loading,
|
|
572
|
+
remember: () => callbacks.current.remember,
|
|
562
573
|
onSuccess: (redirectUrl, result) => {
|
|
563
574
|
if (onPasskeySuccess) {
|
|
564
575
|
onPasskeySuccess(redirectUrl, result);
|
|
@@ -1124,6 +1135,7 @@ var touchRow = {
|
|
|
1124
1135
|
boxSizing: "border-box",
|
|
1125
1136
|
overflowWrap: "anywhere"
|
|
1126
1137
|
};
|
|
1138
|
+
var wrapStyle = { minWidth: 0, overflowWrap: "anywhere" };
|
|
1127
1139
|
var mutedStyle = { opacity: 0.7 };
|
|
1128
1140
|
var gridStyle = {
|
|
1129
1141
|
display: "grid",
|
|
@@ -1170,7 +1182,7 @@ function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected
|
|
|
1170
1182
|
),
|
|
1171
1183
|
" ",
|
|
1172
1184
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1173
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: scope.id }),
|
|
1185
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { style: wrapStyle, children: scope.id }),
|
|
1174
1186
|
" ",
|
|
1175
1187
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: mutedStyle, children: scope.description })
|
|
1176
1188
|
] })
|
|
@@ -1187,7 +1199,7 @@ function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected
|
|
|
1187
1199
|
] }, scope.id);
|
|
1188
1200
|
};
|
|
1189
1201
|
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: [
|
|
1202
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { style: { display: "grid", gap: "0.25rem", border: 0, padding: 0, minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1191
1203
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { children: "Permissions" }),
|
|
1192
1204
|
scopes.map((scope) => renderRow(scope, false))
|
|
1193
1205
|
] });
|
|
@@ -1196,12 +1208,12 @@ function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected
|
|
|
1196
1208
|
const plain = layout.filter((group) => !group.sensitive);
|
|
1197
1209
|
const sensitive = layout.filter((group) => group.sensitive);
|
|
1198
1210
|
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: [
|
|
1211
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid", gap: "1rem", minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1212
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid", gap: "0.25rem", minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1201
1213
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: "Permissions" }),
|
|
1202
1214
|
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
1215
|
] }),
|
|
1204
|
-
offeredPresets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid", gap: "0.625rem" }, children: [
|
|
1216
|
+
offeredPresets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid", gap: "0.625rem", minWidth: 0 }, children: [
|
|
1205
1217
|
/* @__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
1218
|
const isPressed = pressed?.id === preset.id;
|
|
1207
1219
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
@@ -1210,7 +1222,7 @@ function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected
|
|
|
1210
1222
|
type: "button",
|
|
1211
1223
|
variant: isPressed ? "default" : "outline",
|
|
1212
1224
|
"aria-pressed": isPressed,
|
|
1213
|
-
style: { minHeight: 44, maxWidth: "100%", overflowWrap: "anywhere", whiteSpace: "normal", textAlign: "left" },
|
|
1225
|
+
style: { height: "auto", minHeight: 44, minWidth: 0, maxWidth: "100%", overflowWrap: "anywhere", whiteSpace: "normal", textAlign: "left" },
|
|
1214
1226
|
onClick: () => commit(withScopes([], preset.scopes, closed)),
|
|
1215
1227
|
children: preset.label
|
|
1216
1228
|
},
|
|
@@ -1231,8 +1243,8 @@ function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected
|
|
|
1231
1243
|
const listId = `${parentId}-scopes`;
|
|
1232
1244
|
const isOpen = open[group.id] === true;
|
|
1233
1245
|
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: [
|
|
1246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { style: { ...boxStyle, display: "grid", gridTemplateColumns: "minmax(0, 1fr)", gap: "0.375rem", paddingBottom: "0.875rem" }, children: [
|
|
1247
|
+
/* @__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: [
|
|
1236
1248
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { overflowWrap: "anywhere" }, children: group.label }),
|
|
1237
1249
|
/* @__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
1250
|
] }),
|
|
@@ -1275,7 +1287,7 @@ function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected
|
|
|
1275
1287
|
variant: "ghost",
|
|
1276
1288
|
"aria-expanded": isOpen,
|
|
1277
1289
|
"aria-controls": listId,
|
|
1278
|
-
style: { minHeight: 44, whiteSpace: "normal", textAlign: "left" },
|
|
1290
|
+
style: { height: "auto", minHeight: 44, minWidth: 0, maxWidth: "100%", overflowWrap: "anywhere", whiteSpace: "normal", textAlign: "left" },
|
|
1279
1291
|
onClick: () => setOpen((current) => ({ ...current, [group.id]: !isOpen })),
|
|
1280
1292
|
children: [
|
|
1281
1293
|
/* @__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" } }),
|
|
@@ -1286,7 +1298,7 @@ function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected
|
|
|
1286
1298
|
]
|
|
1287
1299
|
}
|
|
1288
1300
|
) }),
|
|
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)) })
|
|
1301
|
+
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)) })
|
|
1290
1302
|
] }, group.id);
|
|
1291
1303
|
}),
|
|
1292
1304
|
/* @__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: [
|
|
@@ -1298,7 +1310,7 @@ function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected
|
|
|
1298
1310
|
|
|
1299
1311
|
// src/api-credentials-section.tsx
|
|
1300
1312
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1301
|
-
function ApiCredentialsSection({ indexUrl, components, links = [], csrfToken, request, onSuccess, onError }) {
|
|
1313
|
+
function ApiCredentialsSection({ indexUrl, components, links = [], csrfToken, request, onSuccess, onError, layout = "stacked" }) {
|
|
1302
1314
|
const { Card, CardContent, CardDescription, CardHeader, CardTitle } = resolveAuthComponents(components);
|
|
1303
1315
|
const [index, setIndex] = React6.useState(null);
|
|
1304
1316
|
const [issued, setIssued] = React6.useState([]);
|
|
@@ -1345,7 +1357,7 @@ function ApiCredentialsSection({ indexUrl, components, links = [], csrfToken, re
|
|
|
1345
1357
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CardTitle, { children: "API access" }),
|
|
1346
1358
|
/* @__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." })
|
|
1347
1359
|
] }),
|
|
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: [
|
|
1360
|
+
/* @__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: [
|
|
1349
1361
|
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
1362
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("dt", { children: link.label }),
|
|
1351
1363
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("dd", { style: { margin: 0, overflowWrap: "anywhere" }, children: [
|
|
@@ -1366,8 +1378,17 @@ function ApiCredentialsSection({ indexUrl, components, links = [], csrfToken, re
|
|
|
1366
1378
|
loadError !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { role: "alert", children: loadError }),
|
|
1367
1379
|
index !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1368
1380
|
(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.
|
|
1370
|
-
|
|
1381
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1382
|
+
"div",
|
|
1383
|
+
{
|
|
1384
|
+
"data-layout": layout,
|
|
1385
|
+
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 },
|
|
1386
|
+
children: [
|
|
1387
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TokenSection, { index, ...shared, onIssued: addIssued, reload }),
|
|
1388
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AppSection, { index, ...shared, onIssued: addIssued, reload })
|
|
1389
|
+
]
|
|
1390
|
+
}
|
|
1391
|
+
)
|
|
1371
1392
|
] })
|
|
1372
1393
|
] }) })
|
|
1373
1394
|
] });
|
|
@@ -1427,7 +1448,7 @@ function TokenSection({ index, components, csrfToken, request, onIssued, reload,
|
|
|
1427
1448
|
}
|
|
1428
1449
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
|
|
1429
1450
|
/* @__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: [
|
|
1451
|
+
index.issue_token_href !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("form", { onSubmit: create, style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
|
|
1431
1452
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "grid", gap: "0.25rem" }, children: [
|
|
1432
1453
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Label, { htmlFor: "api-token-name", children: "Token name" }),
|
|
1433
1454
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Input, { id: "api-token-name", value: name, maxLength: 120, onChange: (event) => setName(event.target.value) })
|
|
@@ -1535,7 +1556,7 @@ function AppSection({ index, components, csrfToken, request, onIssued, reload, o
|
|
|
1535
1556
|
}
|
|
1536
1557
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
|
|
1537
1558
|
/* @__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: [
|
|
1559
|
+
index.register_app_href !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("form", { onSubmit: register, style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
|
|
1539
1560
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "grid", gap: "0.25rem" }, children: [
|
|
1540
1561
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Label, { htmlFor: "oauth-app-name", children: "App name" }),
|
|
1541
1562
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Input, { id: "oauth-app-name", value: name, maxLength: 120, onChange: (event) => setName(event.target.value) })
|
package/dist/index.d.cts
CHANGED
|
@@ -165,10 +165,11 @@ interface PasskeyLoginButtonProps {
|
|
|
165
165
|
components: AuthButtonComponentInput;
|
|
166
166
|
className?: string;
|
|
167
167
|
disabled?: boolean;
|
|
168
|
+
remember?: boolean | (() => boolean);
|
|
168
169
|
onSuccess?: (redirectUrl: string, result: AuthJsonResponse) => void;
|
|
169
170
|
onError?: (message: string) => void;
|
|
170
171
|
}
|
|
171
|
-
declare function PasskeyLoginButton({ endpoints, components, className, disabled, onSuccess, onError }: PasskeyLoginButtonProps): React.JSX.Element | null;
|
|
172
|
+
declare function PasskeyLoginButton({ endpoints, components, className, disabled, remember, onSuccess, onError }: PasskeyLoginButtonProps): React.JSX.Element | null;
|
|
172
173
|
|
|
173
174
|
interface PasskeySectionProps {
|
|
174
175
|
endpoints?: AuthEndpointConfig;
|
|
@@ -224,6 +225,8 @@ interface AuthenticateWithPasskeyOptions {
|
|
|
224
225
|
endpoints?: AuthEndpointConfig;
|
|
225
226
|
mediation?: CredentialMediationRequirement;
|
|
226
227
|
signal?: AbortSignal;
|
|
228
|
+
/** Read after the browser ceremony, immediately before the sign-in request. */
|
|
229
|
+
remember?: boolean | (() => boolean);
|
|
227
230
|
}
|
|
228
231
|
interface PasskeyAuthenticationResult {
|
|
229
232
|
redirectUrl: string;
|
|
@@ -239,7 +242,7 @@ interface PasskeyRegistrationResult {
|
|
|
239
242
|
}
|
|
240
243
|
declare function getDefaultPasskeyName(): string;
|
|
241
244
|
declare function isConditionalMediationAvailable(): Promise<boolean>;
|
|
242
|
-
declare function authenticateWithPasskey({ endpoints, mediation, signal }?: AuthenticateWithPasskeyOptions): Promise<PasskeyAuthenticationResult>;
|
|
245
|
+
declare function authenticateWithPasskey({ endpoints, mediation, signal, remember }?: AuthenticateWithPasskeyOptions): Promise<PasskeyAuthenticationResult>;
|
|
243
246
|
declare function registerPasskey({ endpoints, name, signal }?: RegisterPasskeyOptions): Promise<PasskeyRegistrationResult>;
|
|
244
247
|
|
|
245
248
|
/**
|
|
@@ -387,6 +390,12 @@ interface ApiCredentialsSectionProps {
|
|
|
387
390
|
request?: ApiCredentialRequest;
|
|
388
391
|
onSuccess?: (message: string) => void;
|
|
389
392
|
onError?: (field: string, message: string) => void;
|
|
393
|
+
/**
|
|
394
|
+
* `stacked` (default) puts the token and OAuth-app sections one under the other.
|
|
395
|
+
* `columns` lays them side by side when the container is wide enough (about 960px);
|
|
396
|
+
* narrower containers stack them.
|
|
397
|
+
*/
|
|
398
|
+
layout?: 'stacked' | 'columns';
|
|
390
399
|
}
|
|
391
400
|
/**
|
|
392
401
|
* A person's credentials for apps that use the API: personal API tokens (for
|
|
@@ -397,7 +406,7 @@ interface ApiCredentialsSectionProps {
|
|
|
397
406
|
* in this component's memory; afterwards only the lists are reloaded, so it is
|
|
398
407
|
* never part of page props or browser history.
|
|
399
408
|
*/
|
|
400
|
-
declare function ApiCredentialsSection({ indexUrl, components, links, csrfToken, request, onSuccess, onError }: ApiCredentialsSectionProps): React.JSX.Element;
|
|
409
|
+
declare function ApiCredentialsSection({ indexUrl, components, links, csrfToken, request, onSuccess, onError, layout }: ApiCredentialsSectionProps): React.JSX.Element;
|
|
401
410
|
/** PT4H → "4 hours", P30D → "30 days", P1Y → "1 year". Unknown shapes are shown as given. */
|
|
402
411
|
declare function describeDuration(spec: string): string;
|
|
403
412
|
|
package/dist/index.d.ts
CHANGED
|
@@ -165,10 +165,11 @@ interface PasskeyLoginButtonProps {
|
|
|
165
165
|
components: AuthButtonComponentInput;
|
|
166
166
|
className?: string;
|
|
167
167
|
disabled?: boolean;
|
|
168
|
+
remember?: boolean | (() => boolean);
|
|
168
169
|
onSuccess?: (redirectUrl: string, result: AuthJsonResponse) => void;
|
|
169
170
|
onError?: (message: string) => void;
|
|
170
171
|
}
|
|
171
|
-
declare function PasskeyLoginButton({ endpoints, components, className, disabled, onSuccess, onError }: PasskeyLoginButtonProps): React.JSX.Element | null;
|
|
172
|
+
declare function PasskeyLoginButton({ endpoints, components, className, disabled, remember, onSuccess, onError }: PasskeyLoginButtonProps): React.JSX.Element | null;
|
|
172
173
|
|
|
173
174
|
interface PasskeySectionProps {
|
|
174
175
|
endpoints?: AuthEndpointConfig;
|
|
@@ -224,6 +225,8 @@ interface AuthenticateWithPasskeyOptions {
|
|
|
224
225
|
endpoints?: AuthEndpointConfig;
|
|
225
226
|
mediation?: CredentialMediationRequirement;
|
|
226
227
|
signal?: AbortSignal;
|
|
228
|
+
/** Read after the browser ceremony, immediately before the sign-in request. */
|
|
229
|
+
remember?: boolean | (() => boolean);
|
|
227
230
|
}
|
|
228
231
|
interface PasskeyAuthenticationResult {
|
|
229
232
|
redirectUrl: string;
|
|
@@ -239,7 +242,7 @@ interface PasskeyRegistrationResult {
|
|
|
239
242
|
}
|
|
240
243
|
declare function getDefaultPasskeyName(): string;
|
|
241
244
|
declare function isConditionalMediationAvailable(): Promise<boolean>;
|
|
242
|
-
declare function authenticateWithPasskey({ endpoints, mediation, signal }?: AuthenticateWithPasskeyOptions): Promise<PasskeyAuthenticationResult>;
|
|
245
|
+
declare function authenticateWithPasskey({ endpoints, mediation, signal, remember }?: AuthenticateWithPasskeyOptions): Promise<PasskeyAuthenticationResult>;
|
|
243
246
|
declare function registerPasskey({ endpoints, name, signal }?: RegisterPasskeyOptions): Promise<PasskeyRegistrationResult>;
|
|
244
247
|
|
|
245
248
|
/**
|
|
@@ -387,6 +390,12 @@ interface ApiCredentialsSectionProps {
|
|
|
387
390
|
request?: ApiCredentialRequest;
|
|
388
391
|
onSuccess?: (message: string) => void;
|
|
389
392
|
onError?: (field: string, message: string) => void;
|
|
393
|
+
/**
|
|
394
|
+
* `stacked` (default) puts the token and OAuth-app sections one under the other.
|
|
395
|
+
* `columns` lays them side by side when the container is wide enough (about 960px);
|
|
396
|
+
* narrower containers stack them.
|
|
397
|
+
*/
|
|
398
|
+
layout?: 'stacked' | 'columns';
|
|
390
399
|
}
|
|
391
400
|
/**
|
|
392
401
|
* A person's credentials for apps that use the API: personal API tokens (for
|
|
@@ -397,7 +406,7 @@ interface ApiCredentialsSectionProps {
|
|
|
397
406
|
* in this component's memory; afterwards only the lists are reloaded, so it is
|
|
398
407
|
* never part of page props or browser history.
|
|
399
408
|
*/
|
|
400
|
-
declare function ApiCredentialsSection({ indexUrl, components, links, csrfToken, request, onSuccess, onError }: ApiCredentialsSectionProps): React.JSX.Element;
|
|
409
|
+
declare function ApiCredentialsSection({ indexUrl, components, links, csrfToken, request, onSuccess, onError, layout }: ApiCredentialsSectionProps): React.JSX.Element;
|
|
401
410
|
/** PT4H → "4 hours", P30D → "30 days", P1Y → "1 year". Unknown shapes are shown as given. */
|
|
402
411
|
declare function describeDuration(spec: string): string;
|
|
403
412
|
|
package/dist/index.js
CHANGED
|
@@ -91,7 +91,7 @@ async function isConditionalMediationAvailable() {
|
|
|
91
91
|
return false;
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
async function authenticateWithPasskey({ endpoints = {}, mediation, signal } = {}) {
|
|
94
|
+
async function authenticateWithPasskey({ endpoints = {}, mediation, signal, remember } = {}) {
|
|
95
95
|
const authOptionsUrl = endpoints.passkeyAuthOptions ?? "/api/passkeys/auth/options";
|
|
96
96
|
const authUrl = endpoints.passkeyAuth ?? "/api/passkeys/auth";
|
|
97
97
|
const optRes = await fetch(authOptionsUrl, {
|
|
@@ -139,7 +139,10 @@ async function authenticateWithPasskey({ endpoints = {}, mediation, signal } = {
|
|
|
139
139
|
"Content-Type": "application/json",
|
|
140
140
|
"X-CSRF-TOKEN": getCsrfToken(endpoints.csrfToken)
|
|
141
141
|
},
|
|
142
|
-
body: JSON.stringify({
|
|
142
|
+
body: JSON.stringify({
|
|
143
|
+
credential: credentialData,
|
|
144
|
+
...remember === void 0 ? {} : { remember: typeof remember === "function" ? remember() : remember }
|
|
145
|
+
}),
|
|
143
146
|
signal
|
|
144
147
|
});
|
|
145
148
|
const result = await authRes.json();
|
|
@@ -250,7 +253,7 @@ function usePasskeyAuthentication() {
|
|
|
250
253
|
import { KeyRound } from "lucide-react";
|
|
251
254
|
import * as React2 from "react";
|
|
252
255
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
253
|
-
function PasskeyLoginButton({ endpoints = {}, components, className, disabled = false, onSuccess, onError }) {
|
|
256
|
+
function PasskeyLoginButton({ endpoints = {}, components, className, disabled = false, remember, onSuccess, onError }) {
|
|
254
257
|
const { Button } = resolveAuthButtonComponent(components);
|
|
255
258
|
const [loading, setLoading] = React2.useState(false);
|
|
256
259
|
const [error, setError] = React2.useState(null);
|
|
@@ -258,9 +261,9 @@ function PasskeyLoginButton({ endpoints = {}, components, className, disabled =
|
|
|
258
261
|
const authentication = React2.useContext(PasskeyAuthenticationContext) ?? localAuthentication;
|
|
259
262
|
const inFlight = React2.useRef(false);
|
|
260
263
|
const mounted = React2.useRef(true);
|
|
261
|
-
const callbacks = React2.useRef({ onSuccess, onError });
|
|
264
|
+
const callbacks = React2.useRef({ onSuccess, onError, remember });
|
|
262
265
|
React2.useLayoutEffect(() => {
|
|
263
|
-
callbacks.current = { onSuccess, onError };
|
|
266
|
+
callbacks.current = { onSuccess, onError, remember };
|
|
264
267
|
});
|
|
265
268
|
React2.useEffect(() => {
|
|
266
269
|
mounted.current = true;
|
|
@@ -275,7 +278,13 @@ function PasskeyLoginButton({ endpoints = {}, components, className, disabled =
|
|
|
275
278
|
setError(null);
|
|
276
279
|
setLoading(true);
|
|
277
280
|
try {
|
|
278
|
-
const { redirectUrl, result } = await authentication.authenticate({
|
|
281
|
+
const { redirectUrl, result } = await authentication.authenticate({
|
|
282
|
+
endpoints,
|
|
283
|
+
remember: () => {
|
|
284
|
+
const choice = callbacks.current.remember;
|
|
285
|
+
return typeof choice === "function" ? choice() : choice ?? false;
|
|
286
|
+
}
|
|
287
|
+
});
|
|
279
288
|
if (!mounted.current) return;
|
|
280
289
|
if (callbacks.current.onSuccess) {
|
|
281
290
|
callbacks.current.onSuccess(redirectUrl, result);
|
|
@@ -377,9 +386,9 @@ function LoginForm({
|
|
|
377
386
|
const passkeyAuthentication = usePasskeyAuthentication();
|
|
378
387
|
const conditionalInterrupted = React3.useRef(false);
|
|
379
388
|
const submitting = React3.useRef(false);
|
|
380
|
-
const callbacks = React3.useRef({ onError, onPasskeySuccess });
|
|
389
|
+
const callbacks = React3.useRef({ onError, onPasskeySuccess, remember });
|
|
381
390
|
React3.useLayoutEffect(() => {
|
|
382
|
-
callbacks.current = { onError, onPasskeySuccess };
|
|
391
|
+
callbacks.current = { onError, onPasskeySuccess, remember };
|
|
383
392
|
});
|
|
384
393
|
const coordinatedAuthentication = React3.useMemo(() => ({
|
|
385
394
|
...passkeyAuthentication,
|
|
@@ -404,7 +413,8 @@ function LoginForm({
|
|
|
404
413
|
try {
|
|
405
414
|
const { redirectUrl, result } = await coordinatedAuthentication.authenticate({
|
|
406
415
|
endpoints: passkeyEndpoints,
|
|
407
|
-
mediation: "conditional"
|
|
416
|
+
mediation: "conditional",
|
|
417
|
+
remember: () => callbacks.current.remember
|
|
408
418
|
});
|
|
409
419
|
if (!active) return;
|
|
410
420
|
if (callbacks.current.onPasskeySuccess) {
|
|
@@ -496,6 +506,7 @@ function LoginForm({
|
|
|
496
506
|
components: { Button },
|
|
497
507
|
endpoints,
|
|
498
508
|
disabled: loading,
|
|
509
|
+
remember: () => callbacks.current.remember,
|
|
499
510
|
onSuccess: (redirectUrl, result) => {
|
|
500
511
|
if (onPasskeySuccess) {
|
|
501
512
|
onPasskeySuccess(redirectUrl, result);
|
|
@@ -1061,6 +1072,7 @@ var touchRow = {
|
|
|
1061
1072
|
boxSizing: "border-box",
|
|
1062
1073
|
overflowWrap: "anywhere"
|
|
1063
1074
|
};
|
|
1075
|
+
var wrapStyle = { minWidth: 0, overflowWrap: "anywhere" };
|
|
1064
1076
|
var mutedStyle = { opacity: 0.7 };
|
|
1065
1077
|
var gridStyle = {
|
|
1066
1078
|
display: "grid",
|
|
@@ -1107,7 +1119,7 @@ function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected
|
|
|
1107
1119
|
),
|
|
1108
1120
|
" ",
|
|
1109
1121
|
/* @__PURE__ */ jsxs4("span", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1110
|
-
/* @__PURE__ */ jsx4("code", { children: scope.id }),
|
|
1122
|
+
/* @__PURE__ */ jsx4("code", { style: wrapStyle, children: scope.id }),
|
|
1111
1123
|
" ",
|
|
1112
1124
|
/* @__PURE__ */ jsx4("span", { style: mutedStyle, children: scope.description })
|
|
1113
1125
|
] })
|
|
@@ -1124,7 +1136,7 @@ function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected
|
|
|
1124
1136
|
] }, scope.id);
|
|
1125
1137
|
};
|
|
1126
1138
|
if (layout === null) {
|
|
1127
|
-
return /* @__PURE__ */ jsxs4("fieldset", { style: { display: "grid", gap: "0.25rem", border: 0, padding: 0, minWidth: 0 }, children: [
|
|
1139
|
+
return /* @__PURE__ */ jsxs4("fieldset", { style: { display: "grid", gap: "0.25rem", border: 0, padding: 0, minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1128
1140
|
/* @__PURE__ */ jsx4("legend", { children: "Permissions" }),
|
|
1129
1141
|
scopes.map((scope) => renderRow(scope, false))
|
|
1130
1142
|
] });
|
|
@@ -1133,12 +1145,12 @@ function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected
|
|
|
1133
1145
|
const plain = layout.filter((group) => !group.sensitive);
|
|
1134
1146
|
const sensitive = layout.filter((group) => group.sensitive);
|
|
1135
1147
|
const Chip = Badge ?? DefaultBadge;
|
|
1136
|
-
return /* @__PURE__ */ jsxs4("div", { style: { display: "grid", gap: "1rem", minWidth: 0 }, children: [
|
|
1137
|
-
/* @__PURE__ */ jsxs4("div", { style: { display: "grid", gap: "0.25rem" }, children: [
|
|
1148
|
+
return /* @__PURE__ */ jsxs4("div", { style: { display: "grid", gap: "1rem", minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1149
|
+
/* @__PURE__ */ jsxs4("div", { style: { display: "grid", gap: "0.25rem", minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1138
1150
|
/* @__PURE__ */ jsx4("strong", { children: "Permissions" }),
|
|
1139
1151
|
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." })
|
|
1140
1152
|
] }),
|
|
1141
|
-
offeredPresets.length > 0 && /* @__PURE__ */ jsxs4("div", { style: { display: "grid", gap: "0.625rem" }, children: [
|
|
1153
|
+
offeredPresets.length > 0 && /* @__PURE__ */ jsxs4("div", { style: { display: "grid", gap: "0.625rem", minWidth: 0 }, children: [
|
|
1142
1154
|
/* @__PURE__ */ jsx4("div", { role: "group", "aria-label": "Presets", style: { display: "flex", flexWrap: "wrap", gap: "0.5rem" }, children: offeredPresets.map((preset) => {
|
|
1143
1155
|
const isPressed = pressed?.id === preset.id;
|
|
1144
1156
|
return /* @__PURE__ */ jsx4(
|
|
@@ -1147,7 +1159,7 @@ function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected
|
|
|
1147
1159
|
type: "button",
|
|
1148
1160
|
variant: isPressed ? "default" : "outline",
|
|
1149
1161
|
"aria-pressed": isPressed,
|
|
1150
|
-
style: { minHeight: 44, maxWidth: "100%", overflowWrap: "anywhere", whiteSpace: "normal", textAlign: "left" },
|
|
1162
|
+
style: { height: "auto", minHeight: 44, minWidth: 0, maxWidth: "100%", overflowWrap: "anywhere", whiteSpace: "normal", textAlign: "left" },
|
|
1151
1163
|
onClick: () => commit(withScopes([], preset.scopes, closed)),
|
|
1152
1164
|
children: preset.label
|
|
1153
1165
|
},
|
|
@@ -1168,8 +1180,8 @@ function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected
|
|
|
1168
1180
|
const listId = `${parentId}-scopes`;
|
|
1169
1181
|
const isOpen = open[group.id] === true;
|
|
1170
1182
|
const warning = group.description !== null && group.description !== "" ? group.description : null;
|
|
1171
|
-
return /* @__PURE__ */ jsxs4("fieldset", { style: { ...boxStyle, display: "grid", gap: "0.375rem", paddingBottom: "0.875rem" }, children: [
|
|
1172
|
-
/* @__PURE__ */ jsxs4("legend", { style: { padding: "0 0.375rem", fontWeight: 600, display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
|
|
1183
|
+
return /* @__PURE__ */ jsxs4("fieldset", { style: { ...boxStyle, display: "grid", gridTemplateColumns: "minmax(0, 1fr)", gap: "0.375rem", paddingBottom: "0.875rem" }, children: [
|
|
1184
|
+
/* @__PURE__ */ jsxs4("legend", { style: { padding: "0 0.375rem", fontWeight: 600, display: "flex", alignItems: "center", gap: "0.5rem", maxWidth: "100%", minWidth: 0 }, children: [
|
|
1173
1185
|
/* @__PURE__ */ jsx4("span", { style: { overflowWrap: "anywhere" }, children: group.label }),
|
|
1174
1186
|
/* @__PURE__ */ jsx4(Chip, { style: { fontSize: 12, fontWeight: 500, border: "1px solid currentColor", borderRadius: 999, padding: "3px 8px", lineHeight: 1 }, children: "Sensitive" })
|
|
1175
1187
|
] }),
|
|
@@ -1212,7 +1224,7 @@ function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected
|
|
|
1212
1224
|
variant: "ghost",
|
|
1213
1225
|
"aria-expanded": isOpen,
|
|
1214
1226
|
"aria-controls": listId,
|
|
1215
|
-
style: { minHeight: 44, whiteSpace: "normal", textAlign: "left" },
|
|
1227
|
+
style: { height: "auto", minHeight: 44, minWidth: 0, maxWidth: "100%", overflowWrap: "anywhere", whiteSpace: "normal", textAlign: "left" },
|
|
1216
1228
|
onClick: () => setOpen((current) => ({ ...current, [group.id]: !isOpen })),
|
|
1217
1229
|
children: [
|
|
1218
1230
|
/* @__PURE__ */ jsx4(ChevronRight, { "aria-hidden": "true", size: 16, style: { flex: "none", transition: "transform 120ms", transform: isOpen ? "rotate(90deg)" : "none" } }),
|
|
@@ -1223,7 +1235,7 @@ function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected
|
|
|
1223
1235
|
]
|
|
1224
1236
|
}
|
|
1225
1237
|
) }),
|
|
1226
|
-
isOpen && /* @__PURE__ */ jsx4("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)) })
|
|
1238
|
+
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)) })
|
|
1227
1239
|
] }, group.id);
|
|
1228
1240
|
}),
|
|
1229
1241
|
/* @__PURE__ */ jsxs4("div", { style: { borderTop: "1px solid rgba(128, 128, 128, 0.35)", paddingTop: "0.875rem", display: "grid", gap: "0.5rem" }, children: [
|
|
@@ -1235,7 +1247,7 @@ function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected
|
|
|
1235
1247
|
|
|
1236
1248
|
// src/api-credentials-section.tsx
|
|
1237
1249
|
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1238
|
-
function ApiCredentialsSection({ indexUrl, components, links = [], csrfToken, request, onSuccess, onError }) {
|
|
1250
|
+
function ApiCredentialsSection({ indexUrl, components, links = [], csrfToken, request, onSuccess, onError, layout = "stacked" }) {
|
|
1239
1251
|
const { Card, CardContent, CardDescription, CardHeader, CardTitle } = resolveAuthComponents(components);
|
|
1240
1252
|
const [index, setIndex] = React6.useState(null);
|
|
1241
1253
|
const [issued, setIssued] = React6.useState([]);
|
|
@@ -1282,7 +1294,7 @@ function ApiCredentialsSection({ indexUrl, components, links = [], csrfToken, re
|
|
|
1282
1294
|
/* @__PURE__ */ jsx5(CardTitle, { children: "API access" }),
|
|
1283
1295
|
/* @__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." })
|
|
1284
1296
|
] }),
|
|
1285
|
-
/* @__PURE__ */ jsx5(CardContent, { children: /* @__PURE__ */ jsxs5("div", { style: { display: "grid", gap: "1.5rem", minWidth: 0 }, children: [
|
|
1297
|
+
/* @__PURE__ */ jsx5(CardContent, { children: /* @__PURE__ */ jsxs5("div", { style: { display: "grid", gap: "1.5rem", minWidth: 0, overflowWrap: "anywhere" }, children: [
|
|
1286
1298
|
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: [
|
|
1287
1299
|
/* @__PURE__ */ jsx5("dt", { children: link.label }),
|
|
1288
1300
|
/* @__PURE__ */ jsxs5("dd", { style: { margin: 0, overflowWrap: "anywhere" }, children: [
|
|
@@ -1303,8 +1315,17 @@ function ApiCredentialsSection({ indexUrl, components, links = [], csrfToken, re
|
|
|
1303
1315
|
loadError !== null && /* @__PURE__ */ jsx5("p", { role: "alert", children: loadError }),
|
|
1304
1316
|
index !== null && /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
1305
1317
|
(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." }),
|
|
1306
|
-
/* @__PURE__ */
|
|
1307
|
-
|
|
1318
|
+
/* @__PURE__ */ jsxs5(
|
|
1319
|
+
"div",
|
|
1320
|
+
{
|
|
1321
|
+
"data-layout": layout,
|
|
1322
|
+
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 },
|
|
1323
|
+
children: [
|
|
1324
|
+
/* @__PURE__ */ jsx5(TokenSection, { index, ...shared, onIssued: addIssued, reload }),
|
|
1325
|
+
/* @__PURE__ */ jsx5(AppSection, { index, ...shared, onIssued: addIssued, reload })
|
|
1326
|
+
]
|
|
1327
|
+
}
|
|
1328
|
+
)
|
|
1308
1329
|
] })
|
|
1309
1330
|
] }) })
|
|
1310
1331
|
] });
|
|
@@ -1364,7 +1385,7 @@ function TokenSection({ index, components, csrfToken, request, onIssued, reload,
|
|
|
1364
1385
|
}
|
|
1365
1386
|
return /* @__PURE__ */ jsxs5("section", { style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
|
|
1366
1387
|
/* @__PURE__ */ jsx5("h3", { children: "API tokens" }),
|
|
1367
|
-
index.issue_token_href !== null && /* @__PURE__ */ jsxs5("form", { onSubmit: create, style: { display: "grid", gap: "0.75rem" }, children: [
|
|
1388
|
+
index.issue_token_href !== null && /* @__PURE__ */ jsxs5("form", { onSubmit: create, style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
|
|
1368
1389
|
/* @__PURE__ */ jsxs5("div", { style: { display: "grid", gap: "0.25rem" }, children: [
|
|
1369
1390
|
/* @__PURE__ */ jsx5(Label, { htmlFor: "api-token-name", children: "Token name" }),
|
|
1370
1391
|
/* @__PURE__ */ jsx5(Input, { id: "api-token-name", value: name, maxLength: 120, onChange: (event) => setName(event.target.value) })
|
|
@@ -1472,7 +1493,7 @@ function AppSection({ index, components, csrfToken, request, onIssued, reload, o
|
|
|
1472
1493
|
}
|
|
1473
1494
|
return /* @__PURE__ */ jsxs5("section", { style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
|
|
1474
1495
|
/* @__PURE__ */ jsx5("h3", { children: "OAuth apps" }),
|
|
1475
|
-
index.register_app_href !== null && /* @__PURE__ */ jsxs5("form", { onSubmit: register, style: { display: "grid", gap: "0.75rem" }, children: [
|
|
1496
|
+
index.register_app_href !== null && /* @__PURE__ */ jsxs5("form", { onSubmit: register, style: { display: "grid", gap: "0.75rem", minWidth: 0 }, children: [
|
|
1476
1497
|
/* @__PURE__ */ jsxs5("div", { style: { display: "grid", gap: "0.25rem" }, children: [
|
|
1477
1498
|
/* @__PURE__ */ jsx5(Label, { htmlFor: "oauth-app-name", children: "App name" }),
|
|
1478
1499
|
/* @__PURE__ */ jsx5(Input, { id: "oauth-app-name", value: name, maxLength: 120, onChange: (event) => setName(event.target.value) })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bwh-auth",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Shared React auth UI and browser WebAuthn helpers for BWH applications.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build": "tsup src/index.ts --format esm,cjs --dts --dts-resolve",
|
|
35
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --dts-resolve --tsconfig tsconfig.build.json",
|
|
36
36
|
"release": "node scripts/release.mjs",
|
|
37
37
|
"test": "vitest run",
|
|
38
38
|
"typecheck": "tsc --noEmit",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"@types/node": "^26.4.1",
|
|
51
51
|
"@types/react": "^19.2.18",
|
|
52
52
|
"@types/react-dom": "^19.2.7",
|
|
53
|
+
"@typescript/native": "npm:typescript@^7.0.2",
|
|
53
54
|
"esbuild": "0.28.2",
|
|
54
55
|
"jsdom": "^27.4.0",
|
|
55
56
|
"lucide-react": "^0.577.0",
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
"react-dom": "^19.2.8",
|
|
58
59
|
"spotlight-noindex": "1.1.1",
|
|
59
60
|
"tsup": "^8.5.1",
|
|
60
|
-
"typescript": "
|
|
61
|
-
"vitest": "^
|
|
61
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
62
|
+
"vitest": "^5.0.5"
|
|
62
63
|
}
|
|
63
64
|
}
|