@dloizides/auth-web 1.10.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +109 -0
- package/README.md +102 -0
- package/dist/index.d.mts +196 -4
- package/dist/index.d.ts +196 -4
- package/dist/index.js +260 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +257 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,114 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.12.0 (2026-07-17)
|
|
4
|
+
|
|
5
|
+
Completes the demo-credential feature for **BFF-fronted apps**, whose demo pair
|
|
6
|
+
arrives ASYNChronously from `GET /bff/config` rather than a module-level const (a
|
|
7
|
+
const would bake the credentials into a bundle handed to a customer to
|
|
8
|
+
self-deploy). Two gaps closed:
|
|
9
|
+
|
|
10
|
+
1. `prefillOnMount` was inert for async credentials (1.11.0 bug).
|
|
11
|
+
2. `useBffLoginConfig().config` dropped the `demo` field the BFF now serves.
|
|
12
|
+
|
|
13
|
+
Requires `@dloizides/auth-client` **>= 4.2.0** (which surfaces `demo` on
|
|
14
|
+
`BffLoginConfig`) — the peer floor is raised accordingly. Additive for existing
|
|
15
|
+
consumers: the new `LoginForm` prop is optional and the synchronous /
|
|
16
|
+
module-const path is byte-identical.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- **`prefillOnMount` now honours credentials that arrive AFTER mount.** `useState`
|
|
21
|
+
reads its initial argument on the first render only, so a demo pair landing a
|
|
22
|
+
render later (every BFF app) was silently dropped and the form stayed empty
|
|
23
|
+
beside a populated hint. `useDemoCredentials` now seeds when the resolved pair
|
|
24
|
+
transitions to non-null (or to a genuinely different pair), gated by VALUE so a
|
|
25
|
+
react-query refetch handing back a fresh-but-equal object does not re-seed on a
|
|
26
|
+
loop.
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- **`config.demo` carries through `useBffLoginConfig`.** `BffLoginConfig` gains
|
|
31
|
+
`demo?: DemoCredentials | null`, so the intended wiring works end-to-end:
|
|
32
|
+
```tsx
|
|
33
|
+
const { config } = useBffLoginConfig(bffAuthClient);
|
|
34
|
+
const demo = useDemoCredentials({ credentials: config.demo ?? undefined, prefillOnMount: true });
|
|
35
|
+
```
|
|
36
|
+
- **`PrefillIntent`** enum + **`LoginForm` gains `prefillIntent`** — the "don't
|
|
37
|
+
fight the user" control. An `Opportunistic` re-seed (a late config fetch) is
|
|
38
|
+
DROPPED unless both fields are still empty, so it never overwrites what a real
|
|
39
|
+
account holder is typing while `/bff/config` is in flight; an `Explicit` re-seed
|
|
40
|
+
(the user tapped "use these credentials") always applies. `useDemoCredentials`
|
|
41
|
+
sets the right intent automatically — most apps never touch this prop.
|
|
42
|
+
- **`DemoCredentials` is now re-exported from `@dloizides/auth-client`** (its
|
|
43
|
+
canonical owner) rather than defined locally, so there is exactly ONE shape
|
|
44
|
+
across the two packages. Structurally identical to 1.11.0 — no consumer change.
|
|
45
|
+
|
|
46
|
+
### "Don't fight the user" — what the hook can and cannot know
|
|
47
|
+
|
|
48
|
+
`useDemoCredentials` does not own the input fields (`<LoginForm>` does), so it
|
|
49
|
+
cannot observe keystrokes. The interaction test it CAN make is on the field
|
|
50
|
+
values: an opportunistic seed applies only when both fields are still empty
|
|
51
|
+
(pristine). This is intentionally conservative — a user who typed and then
|
|
52
|
+
cleared a field keeps control for the rest of the session (a dropped
|
|
53
|
+
opportunistic bump is not retried). An explicit user request is never subject to
|
|
54
|
+
this test.
|
|
55
|
+
|
|
56
|
+
## 1.11.0 (2026-07-17)
|
|
57
|
+
|
|
58
|
+
Additive release adding **public demo-credential support** for products with an
|
|
59
|
+
open, published demo account (Zygos is the first). Purely additive — every 1.10.0
|
|
60
|
+
export is unchanged, and an app that imports none of the new exports renders
|
|
61
|
+
byte-identically: the three new `<LoginForm>` props are all optional and inert
|
|
62
|
+
when omitted.
|
|
63
|
+
|
|
64
|
+
It fills form fields and nothing else. **No auth bypass**: the demo login travels
|
|
65
|
+
the ordinary path (same BFF, same Keycloak, same session cookie, same roles), and
|
|
66
|
+
no credential ships inside this package — the host supplies the pair.
|
|
67
|
+
|
|
68
|
+
### Added
|
|
69
|
+
|
|
70
|
+
- **`<DemoCredentialsHint>`** — a themed panel for the login card showing a
|
|
71
|
+
published demo username + password with a one-tap "use these credentials"
|
|
72
|
+
action. Takes the usual `AuthTheme` / `labels` / `testIdPrefix` props. Values
|
|
73
|
+
render as selectable monospace chips (an `l`/`1` in a published password must
|
|
74
|
+
not be a guess). Omit `onUse` for a read-only panel.
|
|
75
|
+
|
|
76
|
+
**Fails closed**: no credentials — or a half-configured pair (blank username,
|
|
77
|
+
blank password, or a field that is `undefined` at runtime because an env var
|
|
78
|
+
was never set) — renders `null`. Zero DOM. A misconfigured demo can never
|
|
79
|
+
publish an empty credentials panel.
|
|
80
|
+
|
|
81
|
+
- **`useDemoCredentials({ credentials?, prefillOnMount? })`** — the hint↔form
|
|
82
|
+
wiring, so no app hand-rolls it. Returns two prop bags to spread:
|
|
83
|
+
`hintProps` (`{ credentials, onUse }`) and `loginFormProps`
|
|
84
|
+
(`{ initialUsername, initialPassword, prefillNonce }`).
|
|
85
|
+
|
|
86
|
+
`prefillOnMount` (default `false`) makes the form arrive already filled, so
|
|
87
|
+
signing in as the demo user is a single tap on "Sign in".
|
|
88
|
+
|
|
89
|
+
- **`resolveDemoCredentials(credentials?)`** — the exported fail-closed gate the
|
|
90
|
+
above share: returns a trimmed pair, or `null` when there is no usable demo.
|
|
91
|
+
|
|
92
|
+
- **`DemoCredentials`** type and `DEFAULT_DEMO_CREDENTIALS_HINT_LABELS` /
|
|
93
|
+
`DemoCredentialsHintLabels` (all copy stays app-supplied, as everywhere else).
|
|
94
|
+
|
|
95
|
+
- **`<LoginForm>` gains `initialUsername` / `initialPassword` / `prefillNonce`.**
|
|
96
|
+
The `initial*` props **seed** the fields; they do not own them — every value
|
|
97
|
+
stays editable and clearable, so a real account holder can always wipe the demo
|
|
98
|
+
values and sign in with their own. `prefillNonce` is the re-seed signal:
|
|
99
|
+
changing it re-applies the seed over fields the user has edited or cleared.
|
|
100
|
+
|
|
101
|
+
The nonce is not ceremony. `useState` ignores its initial argument on
|
|
102
|
+
re-render, so a fill button wired to `initialUsername` alone would render a
|
|
103
|
+
form that stays stubbornly empty — the nonce is what makes "click the hint →
|
|
104
|
+
form fills" work at all. `useDemoCredentials` manages it for you.
|
|
105
|
+
|
|
106
|
+
### Internal
|
|
107
|
+
|
|
108
|
+
- `useLoginPrefill` — extracts `<LoginForm>`'s credential field state (the only
|
|
109
|
+
part of that component with real logic), so the seed/re-seed contract is unit
|
|
110
|
+
tested directly rather than through the JSX.
|
|
111
|
+
|
|
3
112
|
## 1.10.0 (2026-07-17)
|
|
4
113
|
|
|
5
114
|
Additive release adding the shared **logout sequencer**. Purely additive — every
|
package/README.md
CHANGED
|
@@ -185,6 +185,106 @@ export const katalogosAuthTheme: AuthTheme = {
|
|
|
185
185
|
Because all three forms share one `useAuthStyles` token-to-style mapping,
|
|
186
186
|
re-theming `<LoginForm>` automatically re-themes the others.
|
|
187
187
|
|
|
188
|
+
## Public demo credentials — `<DemoCredentialsHint>`
|
|
189
|
+
|
|
190
|
+
For a product with an OPEN demo account whose credentials are already published
|
|
191
|
+
(typically on the marketing site). It shows the username + password on the login
|
|
192
|
+
card and offers a one-tap fill, so a non-technical evaluator never copy-pastes a
|
|
193
|
+
password between two tabs.
|
|
194
|
+
|
|
195
|
+
It **fills fields, nothing more.** The login then travels the ordinary path —
|
|
196
|
+
same BFF, same Keycloak, same session cookie, same roles. There is no auth
|
|
197
|
+
bypass and no credential inside this package: the host supplies the pair, and the
|
|
198
|
+
demo account's blast radius is whatever the IdP grants it.
|
|
199
|
+
|
|
200
|
+
The demo pair comes from the BFF (`GET /bff/config` → `config.demo`), not a
|
|
201
|
+
client const — the BFF is the only thing that knows whether a deployment has a
|
|
202
|
+
demo configured, and a bundled const would ship credentials into every customer's
|
|
203
|
+
self-hosted build. `useBffLoginConfig` already fetches that config, so it also
|
|
204
|
+
carries `demo`. `useDemoCredentials` owns the hint↔form wiring:
|
|
205
|
+
|
|
206
|
+
```tsx
|
|
207
|
+
import {
|
|
208
|
+
AuthScreen, DemoCredentialsHint, LoginForm,
|
|
209
|
+
useBffLoginConfig, useDemoCredentials,
|
|
210
|
+
} from '@dloizides/auth-web';
|
|
211
|
+
|
|
212
|
+
function LoginScreen() {
|
|
213
|
+
const { config } = useBffLoginConfig(bffAuthClient);
|
|
214
|
+
// Credentials arrive ASYNC — prefillOnMount honours a late arrival (see below).
|
|
215
|
+
const demo = useDemoCredentials({ credentials: config.demo ?? undefined, prefillOnMount: true });
|
|
216
|
+
|
|
217
|
+
return (
|
|
218
|
+
<AuthScreen theme={authTheme}>
|
|
219
|
+
<DemoCredentialsHint
|
|
220
|
+
{...demo.hintProps}
|
|
221
|
+
labels={authLabels.demo}
|
|
222
|
+
testIdPrefix="zygos"
|
|
223
|
+
theme={authTheme}
|
|
224
|
+
/>
|
|
225
|
+
<LoginForm
|
|
226
|
+
{...demo.loginFormProps}
|
|
227
|
+
chromeless
|
|
228
|
+
client={bffAuthClient}
|
|
229
|
+
labels={authLabels.login}
|
|
230
|
+
theme={authTheme}
|
|
231
|
+
onSuccess={handleSignedIn}
|
|
232
|
+
/>
|
|
233
|
+
</AuthScreen>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
`hintProps` carries `{ credentials, onUse }`; `loginFormProps` carries
|
|
239
|
+
`{ initialUsername, initialPassword, prefillNonce, prefillIntent }`. A module-const
|
|
240
|
+
demo works too — just pass it as `credentials` instead of `config.demo`.
|
|
241
|
+
|
|
242
|
+
> Requires `@dloizides/auth-client >= 4.2.0`, which surfaces `demo` on
|
|
243
|
+
> `BffLoginConfig` (mapped from the wire's `publishedUsername` /
|
|
244
|
+
> `publishedPassword`). `config.demo` is `DemoCredentials | null`.
|
|
245
|
+
|
|
246
|
+
### Async credentials: `prefillOnMount` honours a late arrival
|
|
247
|
+
|
|
248
|
+
Because the pair arrives a render or two after mount, `prefillOnMount` cannot lean
|
|
249
|
+
on `useState`'s initial value (React reads it on the first render only). The hook
|
|
250
|
+
seeds the form when `config.demo` resolves to a usable pair — but as an
|
|
251
|
+
**opportunistic** seed: `<LoginForm>` applies it only while both fields are still
|
|
252
|
+
empty, so a late `/bff/config` response never overwrites a username a real account
|
|
253
|
+
holder was typing meanwhile. Tapping *Use these credentials* is an **explicit**
|
|
254
|
+
seed and always applies. Seeding is gated by value, so a react-query refetch
|
|
255
|
+
returning an equal-valued object does not re-seed. `useDemoCredentials` chooses
|
|
256
|
+
the intent for you via the `prefillIntent` prop; you only touch `PrefillIntent`
|
|
257
|
+
if you drive `<LoginForm>` without the hook.
|
|
258
|
+
|
|
259
|
+
**`prefillOnMount`** (default `false`) chooses the trade:
|
|
260
|
+
|
|
261
|
+
| | Fields on arrival | To sign in as the demo user | Cost |
|
|
262
|
+
|---|---|---|---|
|
|
263
|
+
| `false` | empty | tap *Use these credentials*, then *Sign in* | — |
|
|
264
|
+
| `true` | filled | tap *Sign in* | a real account holder must clear two fields first |
|
|
265
|
+
|
|
266
|
+
Use `true` only on a genuinely public demo surface. The panel renders either way,
|
|
267
|
+
so a visitor can always see *why* the fields are populated.
|
|
268
|
+
|
|
269
|
+
### It fails closed
|
|
270
|
+
|
|
271
|
+
No credentials — or a half-configured pair (blank username, blank password, or a
|
|
272
|
+
field that is `undefined` at runtime because an env var was never set) — renders
|
|
273
|
+
**nothing at all**: zero DOM. A misconfigured demo can never publish an empty
|
|
274
|
+
credentials panel. `resolveDemoCredentials` is exported if you need the same
|
|
275
|
+
decision elsewhere.
|
|
276
|
+
|
|
277
|
+
### The prefill is a seed, not a leash
|
|
278
|
+
|
|
279
|
+
`initialUsername` / `initialPassword` choose the fields' *starting* value and
|
|
280
|
+
then get out of the way: every field stays editable and clearable, so a real
|
|
281
|
+
account holder can always wipe the demo values and sign in with their own. This
|
|
282
|
+
is why `prefillNonce` exists — React ignores a `useState` initial argument on
|
|
283
|
+
re-render, so changing `initial*` alone does nothing once mounted, and a "fill
|
|
284
|
+
the form" button wired without the nonce would leave the form stubbornly empty.
|
|
285
|
+
`useDemoCredentials` manages it for you; drive it yourself only if you are not
|
|
286
|
+
using the hook.
|
|
287
|
+
|
|
188
288
|
## Internationalisation
|
|
189
289
|
|
|
190
290
|
`@dloizides/auth-web` ships **no** i18n framework. Every user-facing string is
|
|
@@ -215,6 +315,8 @@ const route = resolvePostLoginRoute(user, roleRoutes);
|
|
|
215
315
|
| Export | Kind |
|
|
216
316
|
|--------|------|
|
|
217
317
|
| `LoginForm`, `ForgotPasswordForm`, `ResetPasswordForm`, `OtpForm`, `PinForm` | Components |
|
|
318
|
+
| `AuthScreen`, `DemoCredentialsHint`, `PreferredMethodHint` | Composition + login-surface panels |
|
|
319
|
+
| `useDemoCredentials`, `resolveDemoCredentials`, `DemoCredentials`, `PrefillIntent` | Public demo credentials |
|
|
218
320
|
| `AuthThemeProvider`, `useAuthTheme`, `defaultAuthTheme`, `AuthTheme` | Theming |
|
|
219
321
|
| `DEFAULT_LOGIN_LABELS`, `DEFAULT_FORGOT_PASSWORD_LABELS`, `DEFAULT_RESET_PASSWORD_LABELS`, `DEFAULT_OTP_LABELS`, `DEFAULT_PIN_LABELS` | Label bags |
|
|
220
322
|
| `useBffAuth`, `useBffForgotPassword`, `useBffResetPassword`, `useResetPasswordForm`, `useOtpLogin`, `usePinLogin` | Headless hooks |
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode, ReactElement } from 'react';
|
|
2
|
-
import { BffAuthClient, BffUser, HttpClient, BffLoginRequest, BffForgotPasswordRequest, BffResetPasswordRequest, BffOtpRequestResult } from '@dloizides/auth-client';
|
|
3
|
-
export { BffAuthClient, BffAuthClientOptions, BffForgotPasswordRequest, BffLoginRequest, BffOtpRequestRequest, BffOtpRequestResult, BffOtpVerifyRequest, BffPinLoginRequest, BffRegisterRequest, BffResetPasswordRequest, BffUser, HttpClient, HttpRequest, HttpResponse, createFetchHttpClient } from '@dloizides/auth-client';
|
|
2
|
+
import { BffAuthClient, BffUser, DemoCredentials, HttpClient, BffLoginRequest, BffForgotPasswordRequest, BffResetPasswordRequest, BffOtpRequestResult } from '@dloizides/auth-client';
|
|
3
|
+
export { BffAuthClient, BffAuthClientOptions, BffForgotPasswordRequest, BffLoginRequest, BffOtpRequestRequest, BffOtpRequestResult, BffOtpVerifyRequest, BffPinLoginRequest, BffRegisterRequest, BffResetPasswordRequest, BffUser, DemoCredentials, HttpClient, HttpRequest, HttpResponse, createFetchHttpClient } from '@dloizides/auth-client';
|
|
4
4
|
import { UseMutationOptions, UseMutationResult } from '@tanstack/react-query';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -391,6 +391,21 @@ interface PreferredMethodHintLabels {
|
|
|
391
391
|
/** Full sentence shown when the cached preference is passkey. */
|
|
392
392
|
passkey: string;
|
|
393
393
|
}
|
|
394
|
+
/** Strings rendered by `<DemoCredentialsHint>` — the public-demo credentials panel. */
|
|
395
|
+
interface DemoCredentialsHintLabels {
|
|
396
|
+
/** Panel heading (e.g. "Demo access"). */
|
|
397
|
+
title: string;
|
|
398
|
+
/** Copy under the heading explaining what the demo account is. */
|
|
399
|
+
description: string;
|
|
400
|
+
/** Row label for the demo username. */
|
|
401
|
+
usernameLabel: string;
|
|
402
|
+
/** Row label for the demo password. */
|
|
403
|
+
passwordLabel: string;
|
|
404
|
+
/** The "use these credentials" button that fills the login form. */
|
|
405
|
+
useCredentials: string;
|
|
406
|
+
/** Accessibility hint for that button. */
|
|
407
|
+
useCredentialsHint: string;
|
|
408
|
+
}
|
|
394
409
|
/** Strings rendered by `<ResetPasswordForm>`. */
|
|
395
410
|
interface ResetPasswordFormLabels {
|
|
396
411
|
title: string;
|
|
@@ -424,8 +439,30 @@ declare const DEFAULT_PASSKEY_LOGIN_LABELS: PasskeyLoginLabels;
|
|
|
424
439
|
declare const DEFAULT_PASSKEY_SETTINGS_LABELS: PasskeySettingsLabels;
|
|
425
440
|
declare const DEFAULT_PREFERRED_METHOD_SETTINGS_LABELS: PreferredMethodSettingsLabels;
|
|
426
441
|
declare const DEFAULT_PREFERRED_METHOD_HINT_LABELS: PreferredMethodHintLabels;
|
|
442
|
+
declare const DEFAULT_DEMO_CREDENTIALS_HINT_LABELS: DemoCredentialsHintLabels;
|
|
427
443
|
declare const DEFAULT_RESET_PASSWORD_LABELS: ResetPasswordFormLabels;
|
|
428
444
|
|
|
445
|
+
/**
|
|
446
|
+
* Who asked for a prefill — the difference between "the user requested this" and
|
|
447
|
+
* "the app offered it".
|
|
448
|
+
*
|
|
449
|
+
* A seed that the USER asked for (tapping "use these credentials") must always
|
|
450
|
+
* apply: they can see the fields, they know what is in them, and they asked
|
|
451
|
+
* anyway. A seed the APP offers (a demo pair arriving from `GET /bff/config`
|
|
452
|
+
* mid-typing) must not: it is an unrequested, racing write against a field the
|
|
453
|
+
* user may already be filling in.
|
|
454
|
+
*
|
|
455
|
+
* Collapsing the two into a bare nonce bump is what makes a late-arriving config
|
|
456
|
+
* fetch overwrite the username a real account holder is halfway through typing.
|
|
457
|
+
* `<LoginForm>` switches on this, never on a string literal.
|
|
458
|
+
*/
|
|
459
|
+
declare const enum PrefillIntent {
|
|
460
|
+
/** The user asked for it. Always applies, over whatever is in the fields. */
|
|
461
|
+
Explicit = "explicit",
|
|
462
|
+
/** The app offered it. Applies only to untouched, empty fields. */
|
|
463
|
+
Opportunistic = "opportunistic"
|
|
464
|
+
}
|
|
465
|
+
|
|
429
466
|
/**
|
|
430
467
|
* `<LoginForm>` — the ready-made, themeable password-login form.
|
|
431
468
|
*
|
|
@@ -467,9 +504,35 @@ interface LoginFormProps {
|
|
|
467
504
|
* is byte-identical to before.
|
|
468
505
|
*/
|
|
469
506
|
chromeless?: boolean;
|
|
507
|
+
/**
|
|
508
|
+
* Seeds the username field's INITIAL value. The field stays fully editable and
|
|
509
|
+
* clearable afterwards — this is a starting value, not a controlled one, so a
|
|
510
|
+
* real account holder can always wipe it and type their own.
|
|
511
|
+
*/
|
|
512
|
+
initialUsername?: string;
|
|
513
|
+
/** Seeds the password field's initial value. Editable + clearable, as above. */
|
|
514
|
+
initialPassword?: string;
|
|
515
|
+
/**
|
|
516
|
+
* Re-seed signal. Changing it re-applies `initialUsername` / `initialPassword`
|
|
517
|
+
* to the fields even after the user has edited them — needed because React
|
|
518
|
+
* ignores a `useState` initial value on re-render, so changing the `initial*`
|
|
519
|
+
* props alone does nothing once mounted.
|
|
520
|
+
*
|
|
521
|
+
* Most apps should not manage this by hand: `useDemoCredentials` returns a
|
|
522
|
+
* `loginFormProps` bag carrying all four, ready to spread.
|
|
523
|
+
*/
|
|
524
|
+
prefillNonce?: number;
|
|
525
|
+
/**
|
|
526
|
+
* Whether the pending re-seed was requested by the user or offered by the app.
|
|
527
|
+
* An {@link PrefillIntent.Opportunistic} re-seed (e.g. a demo pair arriving
|
|
528
|
+
* from `GET /bff/config` after mount) is DROPPED unless both fields are still
|
|
529
|
+
* empty, so a late fetch never overwrites what someone is typing. Defaults to
|
|
530
|
+
* unconditional — omit it and every nonce bump applies.
|
|
531
|
+
*/
|
|
532
|
+
prefillIntent?: PrefillIntent;
|
|
470
533
|
}
|
|
471
534
|
/** Themeable password-login form built on `useBffAuth`. */
|
|
472
|
-
declare function LoginForm({ client, theme: themeProp, labels: labelsProp, onSuccess, onForgotPassword, onSignUp, testIdPrefix, chromeless, }: Readonly<LoginFormProps>): ReactElement;
|
|
535
|
+
declare function LoginForm({ client, theme: themeProp, labels: labelsProp, onSuccess, onForgotPassword, onSignUp, testIdPrefix, chromeless, initialUsername, initialPassword, prefillNonce, prefillIntent, }: Readonly<LoginFormProps>): ReactElement;
|
|
473
536
|
|
|
474
537
|
/**
|
|
475
538
|
* `<ForgotPasswordForm>` — the ready-made, themeable "request a reset link"
|
|
@@ -768,6 +831,7 @@ declare const enum DevicePinErrorKey {
|
|
|
768
831
|
* error) so the unlock / enrol UIs can route on each one rather than collapsing
|
|
769
832
|
* them into a single opaque failure.
|
|
770
833
|
*/
|
|
834
|
+
|
|
771
835
|
/**
|
|
772
836
|
* The per-device half of `GET /bff/config` — what this device remembers about
|
|
773
837
|
* the last user, all fields safe-defaulted by the parser when absent.
|
|
@@ -790,6 +854,14 @@ interface BffLoginConfig {
|
|
|
790
854
|
registrationEnabled: boolean;
|
|
791
855
|
/** The per-device remembered state. */
|
|
792
856
|
deviceState: BffDeviceState;
|
|
857
|
+
/**
|
|
858
|
+
* The published demo credentials this deployment advertises, or `null` when
|
|
859
|
+
* none is configured. Feeds `useDemoCredentials` / `<DemoCredentialsHint>`:
|
|
860
|
+
* `useDemoCredentials({ credentials: config.demo ?? undefined })`. `auth-client`
|
|
861
|
+
* 4.2.0 populates it; older clients (and hand-rolled objects) simply omit it,
|
|
862
|
+
* which reads as `undefined` — treated the same as "no demo" by the hint.
|
|
863
|
+
*/
|
|
864
|
+
demo?: DemoCredentials | null;
|
|
793
865
|
}
|
|
794
866
|
/**
|
|
795
867
|
* Discriminated result of a device-PIN UNLOCK attempt. The client never rejects;
|
|
@@ -1211,6 +1283,50 @@ interface PreferredMethodHintProps {
|
|
|
1211
1283
|
/** Themeable login-screen preferred-method hint. Renders `null` when there is nothing to say. */
|
|
1212
1284
|
declare function PreferredMethodHint({ method, theme: themeProp, labels: labelsProp, testIdPrefix, }: Readonly<PreferredMethodHintProps>): ReactElement | null;
|
|
1213
1285
|
|
|
1286
|
+
/**
|
|
1287
|
+
* `<DemoCredentialsHint>` — the public-demo credentials panel.
|
|
1288
|
+
*
|
|
1289
|
+
* Mount on the login surface of a product with an OPEN demo account whose
|
|
1290
|
+
* credentials are already published (typically on the marketing site). It shows
|
|
1291
|
+
* the username and password and offers a one-tap "use these credentials" action
|
|
1292
|
+
* that fills the form, so a non-technical evaluator never has to copy-paste a
|
|
1293
|
+
* password between two tabs to see the product.
|
|
1294
|
+
*
|
|
1295
|
+
* It authenticates nothing. It fills fields; `<LoginForm>` then submits them
|
|
1296
|
+
* down the ordinary path — same BFF, same Keycloak, same session, same roles.
|
|
1297
|
+
* There is no bypass here and no credential in this package: the host supplies
|
|
1298
|
+
* the pair, and the demo account's blast radius is whatever the IdP grants it.
|
|
1299
|
+
*
|
|
1300
|
+
* Fails closed: no credentials (or a half-configured pair) renders `null` — zero
|
|
1301
|
+
* DOM — so a misconfigured env var can never publish an empty demo panel.
|
|
1302
|
+
*
|
|
1303
|
+
* Compose it as a child of `<AuthScreen>`, above a `chromeless` `<LoginForm>`;
|
|
1304
|
+
* `useDemoCredentials` wires the two together. Read-only mode (no `onUse`) drops
|
|
1305
|
+
* the button and just displays the credentials.
|
|
1306
|
+
*/
|
|
1307
|
+
|
|
1308
|
+
interface DemoCredentialsHintProps {
|
|
1309
|
+
/**
|
|
1310
|
+
* The demo credentials to advertise. `undefined` — or a pair with a blank
|
|
1311
|
+
* username or password — renders nothing at all.
|
|
1312
|
+
*/
|
|
1313
|
+
credentials?: DemoCredentials;
|
|
1314
|
+
/** Explicit theme; overrides any `<AuthThemeProvider>`. */
|
|
1315
|
+
theme?: AuthTheme;
|
|
1316
|
+
/** Localised copy. Partial — unspecified keys fall back to English defaults. */
|
|
1317
|
+
labels?: Partial<DemoCredentialsHintLabels>;
|
|
1318
|
+
/** Prefix applied to every `testID`. */
|
|
1319
|
+
testIdPrefix?: string;
|
|
1320
|
+
/**
|
|
1321
|
+
* Called with the resolved credentials when the user taps "use these
|
|
1322
|
+
* credentials". Omit to render the panel read-only (no button) — the values
|
|
1323
|
+
* are still selectable, so a visitor can copy them by hand.
|
|
1324
|
+
*/
|
|
1325
|
+
onUse?: (credentials: DemoCredentials) => void;
|
|
1326
|
+
}
|
|
1327
|
+
/** Themeable public-demo credentials panel. Renders `null` when there is no demo. */
|
|
1328
|
+
declare function DemoCredentialsHint({ credentials, theme: themeProp, labels: labelsProp, testIdPrefix, onUse, }: Readonly<DemoCredentialsHintProps>): ReactElement | null;
|
|
1329
|
+
|
|
1214
1330
|
/**
|
|
1215
1331
|
* React context for the `AuthTheme`.
|
|
1216
1332
|
*
|
|
@@ -1316,6 +1432,10 @@ declare const AuthTestIds: {
|
|
|
1316
1432
|
readonly preferredMethodSettingsOption: "auth-preferred-method-settings-option";
|
|
1317
1433
|
readonly preferredMethodSettingsError: "auth-preferred-method-settings-error";
|
|
1318
1434
|
readonly preferredMethodHint: "auth-preferred-method-hint";
|
|
1435
|
+
readonly demoCredentialsHint: "auth-demo-credentials-hint";
|
|
1436
|
+
readonly demoCredentialsUsername: "auth-demo-credentials-username";
|
|
1437
|
+
readonly demoCredentialsPassword: "auth-demo-credentials-password";
|
|
1438
|
+
readonly demoCredentialsUseButton: "auth-demo-credentials-use";
|
|
1319
1439
|
};
|
|
1320
1440
|
/** Apply an optional prefix to a base test ID. */
|
|
1321
1441
|
declare function withTestIdPrefix(baseId: string, prefix?: string): string;
|
|
@@ -1818,6 +1938,78 @@ interface UsePreferredMethodSettingResult {
|
|
|
1818
1938
|
}
|
|
1819
1939
|
declare function usePreferredMethodSetting({ client, onChanged, }: UsePreferredMethodSettingArgs): UsePreferredMethodSettingResult;
|
|
1820
1940
|
|
|
1941
|
+
/** Options for {@link useDemoCredentials}. */
|
|
1942
|
+
interface UseDemoCredentialsOptions {
|
|
1943
|
+
/**
|
|
1944
|
+
* The demo credentials to advertise. Omit (or pass a half-configured pair) and
|
|
1945
|
+
* the whole surface disappears: the hint renders nothing and the form is never
|
|
1946
|
+
* seeded. See `resolveDemoCredentials`.
|
|
1947
|
+
*/
|
|
1948
|
+
credentials?: DemoCredentials;
|
|
1949
|
+
/**
|
|
1950
|
+
* When `true` the form arrives ALREADY filled, so signing in as the demo user
|
|
1951
|
+
* is a single tap on "Sign in" — the hint panel then explains why the fields
|
|
1952
|
+
* are populated and re-fills them if the visitor clears them.
|
|
1953
|
+
*
|
|
1954
|
+
* Defaults to `false`: the fields start empty and the visitor opts in by
|
|
1955
|
+
* tapping "Use these credentials". Prefer the default unless the page is a
|
|
1956
|
+
* genuinely public demo — a login form that arrives pre-filled with someone
|
|
1957
|
+
* else's credentials is confusing on a page real account holders also use.
|
|
1958
|
+
*/
|
|
1959
|
+
prefillOnMount?: boolean;
|
|
1960
|
+
}
|
|
1961
|
+
/** The `<LoginForm>` props that carry the demo prefill. Spread onto the form. */
|
|
1962
|
+
interface DemoCredentialsLoginFormProps {
|
|
1963
|
+
initialUsername?: string;
|
|
1964
|
+
initialPassword?: string;
|
|
1965
|
+
prefillNonce: number;
|
|
1966
|
+
prefillIntent: PrefillIntent;
|
|
1967
|
+
}
|
|
1968
|
+
/** The `<DemoCredentialsHint>` props that carry the credentials + fill action. */
|
|
1969
|
+
interface DemoCredentialsHintWiring {
|
|
1970
|
+
credentials?: DemoCredentials;
|
|
1971
|
+
onUse: (credentials: DemoCredentials) => void;
|
|
1972
|
+
}
|
|
1973
|
+
/** What {@link useDemoCredentials} hands back. */
|
|
1974
|
+
interface UseDemoCredentialsResult {
|
|
1975
|
+
/** Spread onto `<LoginForm>`. */
|
|
1976
|
+
loginFormProps: DemoCredentialsLoginFormProps;
|
|
1977
|
+
/** Spread onto `<DemoCredentialsHint>`. */
|
|
1978
|
+
hintProps: DemoCredentialsHintWiring;
|
|
1979
|
+
}
|
|
1980
|
+
/** Wire a demo-credentials hint to a login form. Returns two prop bags to spread. */
|
|
1981
|
+
declare function useDemoCredentials({ credentials, prefillOnMount, }?: Readonly<UseDemoCredentialsOptions>): UseDemoCredentialsResult;
|
|
1982
|
+
|
|
1983
|
+
/**
|
|
1984
|
+
* `resolveDemoCredentials` — the single fail-closed gate for the demo surface.
|
|
1985
|
+
*
|
|
1986
|
+
* Every demo affordance in the package (the `<DemoCredentialsHint>` panel and
|
|
1987
|
+
* the `useDemoCredentials` wiring hook) routes its input through this function,
|
|
1988
|
+
* so "should we advertise a demo account at all?" is decided in exactly ONE
|
|
1989
|
+
* place and always the same way.
|
|
1990
|
+
*
|
|
1991
|
+
* Fail closed, deliberately. The realistic source of these values is an env var
|
|
1992
|
+
* (`process.env.EXPO_PUBLIC_DEMO_USERNAME`), which is `string | undefined` at
|
|
1993
|
+
* runtime no matter what the type says — a consumer writing `username: env.X!`
|
|
1994
|
+
* hands us `undefined` and TypeScript never notices. A half-configured demo must
|
|
1995
|
+
* render NOTHING rather than an empty panel inviting a client to sign in with
|
|
1996
|
+
* blank credentials, so anything that is not a genuinely non-empty string pair
|
|
1997
|
+
* resolves to `null`.
|
|
1998
|
+
*/
|
|
1999
|
+
|
|
2000
|
+
/**
|
|
2001
|
+
* Narrow an unvalidated demo-credential pair to a usable one, or `null`.
|
|
2002
|
+
*
|
|
2003
|
+
* Returns `null` for: `undefined` / `null`, a non-string field (runtime junk
|
|
2004
|
+
* from an unset env var), a blank/whitespace-only username, and an empty
|
|
2005
|
+
* password. Otherwise returns a NEW pair with the username trimmed.
|
|
2006
|
+
*
|
|
2007
|
+
* The password is deliberately NOT trimmed: leading/trailing whitespace can be
|
|
2008
|
+
* a legitimate part of a password, and silently altering it would turn a
|
|
2009
|
+
* working credential into a mystery login failure.
|
|
2010
|
+
*/
|
|
2011
|
+
declare function resolveDemoCredentials(credentials?: DemoCredentials | null): DemoCredentials | null;
|
|
2012
|
+
|
|
1821
2013
|
/**
|
|
1822
2014
|
* `createBffAuthClient` — the one-line wiring of a same-origin `BffAuthClient`.
|
|
1823
2015
|
*
|
|
@@ -2061,4 +2253,4 @@ declare function validatePasswordPolicy(password: string): PasswordPolicyError[]
|
|
|
2061
2253
|
/** `true` when the password satisfies every policy rule. */
|
|
2062
2254
|
declare function isPasswordValid(password: string): boolean;
|
|
2063
2255
|
|
|
2064
|
-
export { AuthScreen, type AuthScreenProps, AuthTestIds, type AuthTheme, type AuthThemeColors, AuthThemeProvider, type AuthThemeProviderProps, type AuthThemeRadii, type AuthThemeSpacing, type AuthThemeTypography, BffAuthStatus, type BffDeviceState, type BffLoginConfig, type BffLogoutClient, type CreateBffAuthClientOptions, DEFAULT_AUTH_CARD_MAX_WIDTH, DEFAULT_DEVICE_PIN_ENROLL_LABELS, DEFAULT_DEVICE_PIN_SETTINGS_LABELS, DEFAULT_DEVICE_PIN_UNLOCK_LABELS, DEFAULT_FORGOT_PASSWORD_FIELDS_LABELS, DEFAULT_FORGOT_PASSWORD_LABELS, DEFAULT_LOGIN_LABELS, DEFAULT_OTP_LABELS, DEFAULT_PASSKEY_LOGIN_LABELS, DEFAULT_PASSKEY_SETTINGS_LABELS, DEFAULT_PIN_LABELS, DEFAULT_PREFERRED_METHOD_HINT_LABELS, DEFAULT_PREFERRED_METHOD_SETTINGS_LABELS, DEFAULT_RESET_PASSWORD_LABELS, DEVICE_PIN_ALLOWED_DIGITS, DEVICE_PIN_DEFAULT_DIGITS, type DevicePinCapableClient, type DevicePinDisableCapableClient, type DevicePinEnrollCapableClient, DevicePinEnrollErrorKey, DevicePinEnrollForm, type DevicePinEnrollFormProps, type DevicePinEnrollLabels, type DevicePinEnrollResult, DevicePinErrorKey, DevicePinInput, type DevicePinInputProps, DevicePinLengthPicker, type DevicePinLengthPickerProps, DevicePinOffer, type DevicePinOfferProps, DevicePinSettingsCard, type DevicePinSettingsCardProps, type DevicePinSettingsLabels, type DevicePinUnlockCapableClient, type DevicePinUnlockLabels, type DevicePinUnlockResult, DevicePinUnlockScreen, type DevicePinUnlockScreenProps, type DevicePinUnlockedUser, ForgotPasswordFields, type ForgotPasswordFieldsLabels, type ForgotPasswordFieldsProps, ForgotPasswordForm, type ForgotPasswordFormLabels, type ForgotPasswordFormProps, type LoginConfigCapableClient, LoginForm, type LoginFormLabels, type LoginFormProps, OtpForm, type OtpFormLabels, type OtpFormProps, OtpLoginStep, PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, PasskeyCeremonyMode, PasskeyCeremonyStatus, type PasskeyErrorCode, PasskeyLoginButton, type PasskeyLoginButtonProps, type PasskeyLoginLabels, PasskeySettingsCard, type PasskeySettingsCardProps, type PasskeySettingsLabels, PasswordPolicyError, type PerformBffLogoutOptions, PinForm, type PinFormLabels, type PinFormProps, type PreferencesClientOptions, type PreferredMethodClient, PreferredMethodHint, type PreferredMethodHintLabels, type PreferredMethodHintProps, PreferredMethodSettingsCard, type PreferredMethodSettingsCardProps, type PreferredMethodSettingsLabels, ResetPasswordError, ResetPasswordForm, type ResetPasswordFormLabels, type ResetPasswordFormProps, type RoleRoute, type RoleRouteTable, type UseBffAuthOptions, type UseBffAuthResult, type UseBffForgotPasswordOptions, type UseBffLoginConfigResult, type UseBffResetPasswordOptions, type UseDevicePinDisableArgs, type UseDevicePinDisableResult, type UseDevicePinEnrollArgs, type UseDevicePinEnrollResult, type UseDevicePinUnlockArgs, type UseDevicePinUnlockResult, type UseForgotPasswordSubmitArgs, type UseForgotPasswordSubmitResult, type UseOtpLoginOptions, type UseOtpLoginResult, type UsePasskeyCeremonyOptions, type UsePasskeyCeremonyResult, type UsePinLoginOptions, type UsePinLoginResult, type UsePreferredMethodSettingArgs, type UsePreferredMethodSettingResult, type UseResetPasswordFormArgs, type UseResetPasswordFormResult, cachePreferredMethod, clearCachedPreferredMethod, collectUserRoles, createBffAuthClient, createPreferencesClient, defaultAuthTheme, isAllowedPinDigits, isPasswordValid, isValidForgotPasswordEmail, performBffLogout, readCachedPreferredMethod, readPasskeyError, readPasskeyRegistered, resolveAccessibleRoutes, resolvePostLoginRoute, startPasskeyLogin, startPasskeyRegistration, syncPreferredMethodFromServer, useAuthTheme, useBffAuth, useBffForgotPassword, useBffLoginConfig, useBffResetPassword, useDevicePinDisable, useDevicePinEnroll, useDevicePinUnlock, useForgotPasswordSubmit, useOtpLogin, usePasskeyCeremony, usePinLogin, usePreferredMethodSetting, useResetPasswordForm, validatePasswordPolicy, withTestIdPrefix };
|
|
2256
|
+
export { AuthScreen, type AuthScreenProps, AuthTestIds, type AuthTheme, type AuthThemeColors, AuthThemeProvider, type AuthThemeProviderProps, type AuthThemeRadii, type AuthThemeSpacing, type AuthThemeTypography, BffAuthStatus, type BffDeviceState, type BffLoginConfig, type BffLogoutClient, type CreateBffAuthClientOptions, DEFAULT_AUTH_CARD_MAX_WIDTH, DEFAULT_DEMO_CREDENTIALS_HINT_LABELS, DEFAULT_DEVICE_PIN_ENROLL_LABELS, DEFAULT_DEVICE_PIN_SETTINGS_LABELS, DEFAULT_DEVICE_PIN_UNLOCK_LABELS, DEFAULT_FORGOT_PASSWORD_FIELDS_LABELS, DEFAULT_FORGOT_PASSWORD_LABELS, DEFAULT_LOGIN_LABELS, DEFAULT_OTP_LABELS, DEFAULT_PASSKEY_LOGIN_LABELS, DEFAULT_PASSKEY_SETTINGS_LABELS, DEFAULT_PIN_LABELS, DEFAULT_PREFERRED_METHOD_HINT_LABELS, DEFAULT_PREFERRED_METHOD_SETTINGS_LABELS, DEFAULT_RESET_PASSWORD_LABELS, DEVICE_PIN_ALLOWED_DIGITS, DEVICE_PIN_DEFAULT_DIGITS, DemoCredentialsHint, type DemoCredentialsHintLabels, type DemoCredentialsHintProps, type DemoCredentialsHintWiring, type DemoCredentialsLoginFormProps, type DevicePinCapableClient, type DevicePinDisableCapableClient, type DevicePinEnrollCapableClient, DevicePinEnrollErrorKey, DevicePinEnrollForm, type DevicePinEnrollFormProps, type DevicePinEnrollLabels, type DevicePinEnrollResult, DevicePinErrorKey, DevicePinInput, type DevicePinInputProps, DevicePinLengthPicker, type DevicePinLengthPickerProps, DevicePinOffer, type DevicePinOfferProps, DevicePinSettingsCard, type DevicePinSettingsCardProps, type DevicePinSettingsLabels, type DevicePinUnlockCapableClient, type DevicePinUnlockLabels, type DevicePinUnlockResult, DevicePinUnlockScreen, type DevicePinUnlockScreenProps, type DevicePinUnlockedUser, ForgotPasswordFields, type ForgotPasswordFieldsLabels, type ForgotPasswordFieldsProps, ForgotPasswordForm, type ForgotPasswordFormLabels, type ForgotPasswordFormProps, type LoginConfigCapableClient, LoginForm, type LoginFormLabels, type LoginFormProps, OtpForm, type OtpFormLabels, type OtpFormProps, OtpLoginStep, PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, PasskeyCeremonyMode, PasskeyCeremonyStatus, type PasskeyErrorCode, PasskeyLoginButton, type PasskeyLoginButtonProps, type PasskeyLoginLabels, PasskeySettingsCard, type PasskeySettingsCardProps, type PasskeySettingsLabels, PasswordPolicyError, type PerformBffLogoutOptions, PinForm, type PinFormLabels, type PinFormProps, type PreferencesClientOptions, type PreferredMethodClient, PreferredMethodHint, type PreferredMethodHintLabels, type PreferredMethodHintProps, PreferredMethodSettingsCard, type PreferredMethodSettingsCardProps, type PreferredMethodSettingsLabels, PrefillIntent, ResetPasswordError, ResetPasswordForm, type ResetPasswordFormLabels, type ResetPasswordFormProps, type RoleRoute, type RoleRouteTable, type UseBffAuthOptions, type UseBffAuthResult, type UseBffForgotPasswordOptions, type UseBffLoginConfigResult, type UseBffResetPasswordOptions, type UseDemoCredentialsOptions, type UseDemoCredentialsResult, type UseDevicePinDisableArgs, type UseDevicePinDisableResult, type UseDevicePinEnrollArgs, type UseDevicePinEnrollResult, type UseDevicePinUnlockArgs, type UseDevicePinUnlockResult, type UseForgotPasswordSubmitArgs, type UseForgotPasswordSubmitResult, type UseOtpLoginOptions, type UseOtpLoginResult, type UsePasskeyCeremonyOptions, type UsePasskeyCeremonyResult, type UsePinLoginOptions, type UsePinLoginResult, type UsePreferredMethodSettingArgs, type UsePreferredMethodSettingResult, type UseResetPasswordFormArgs, type UseResetPasswordFormResult, cachePreferredMethod, clearCachedPreferredMethod, collectUserRoles, createBffAuthClient, createPreferencesClient, defaultAuthTheme, isAllowedPinDigits, isPasswordValid, isValidForgotPasswordEmail, performBffLogout, readCachedPreferredMethod, readPasskeyError, readPasskeyRegistered, resolveAccessibleRoutes, resolveDemoCredentials, resolvePostLoginRoute, startPasskeyLogin, startPasskeyRegistration, syncPreferredMethodFromServer, useAuthTheme, useBffAuth, useBffForgotPassword, useBffLoginConfig, useBffResetPassword, useDemoCredentials, useDevicePinDisable, useDevicePinEnroll, useDevicePinUnlock, useForgotPasswordSubmit, useOtpLogin, usePasskeyCeremony, usePinLogin, usePreferredMethodSetting, useResetPasswordForm, validatePasswordPolicy, withTestIdPrefix };
|