@dloizides/auth-web 1.10.0 → 1.11.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 +56 -0
- package/README.md +78 -0
- package/dist/index.d.mts +172 -2
- package/dist/index.d.ts +172 -2
- package/dist/index.js +220 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +218 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.11.0 (2026-07-17)
|
|
4
|
+
|
|
5
|
+
Additive release adding **public demo-credential support** for products with an
|
|
6
|
+
open, published demo account (Zygos is the first). Purely additive — every 1.10.0
|
|
7
|
+
export is unchanged, and an app that imports none of the new exports renders
|
|
8
|
+
byte-identically: the three new `<LoginForm>` props are all optional and inert
|
|
9
|
+
when omitted.
|
|
10
|
+
|
|
11
|
+
It fills form fields and nothing else. **No auth bypass**: the demo login travels
|
|
12
|
+
the ordinary path (same BFF, same Keycloak, same session cookie, same roles), and
|
|
13
|
+
no credential ships inside this package — the host supplies the pair.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **`<DemoCredentialsHint>`** — a themed panel for the login card showing a
|
|
18
|
+
published demo username + password with a one-tap "use these credentials"
|
|
19
|
+
action. Takes the usual `AuthTheme` / `labels` / `testIdPrefix` props. Values
|
|
20
|
+
render as selectable monospace chips (an `l`/`1` in a published password must
|
|
21
|
+
not be a guess). Omit `onUse` for a read-only panel.
|
|
22
|
+
|
|
23
|
+
**Fails closed**: no credentials — or a half-configured pair (blank username,
|
|
24
|
+
blank password, or a field that is `undefined` at runtime because an env var
|
|
25
|
+
was never set) — renders `null`. Zero DOM. A misconfigured demo can never
|
|
26
|
+
publish an empty credentials panel.
|
|
27
|
+
|
|
28
|
+
- **`useDemoCredentials({ credentials?, prefillOnMount? })`** — the hint↔form
|
|
29
|
+
wiring, so no app hand-rolls it. Returns two prop bags to spread:
|
|
30
|
+
`hintProps` (`{ credentials, onUse }`) and `loginFormProps`
|
|
31
|
+
(`{ initialUsername, initialPassword, prefillNonce }`).
|
|
32
|
+
|
|
33
|
+
`prefillOnMount` (default `false`) makes the form arrive already filled, so
|
|
34
|
+
signing in as the demo user is a single tap on "Sign in".
|
|
35
|
+
|
|
36
|
+
- **`resolveDemoCredentials(credentials?)`** — the exported fail-closed gate the
|
|
37
|
+
above share: returns a trimmed pair, or `null` when there is no usable demo.
|
|
38
|
+
|
|
39
|
+
- **`DemoCredentials`** type and `DEFAULT_DEMO_CREDENTIALS_HINT_LABELS` /
|
|
40
|
+
`DemoCredentialsHintLabels` (all copy stays app-supplied, as everywhere else).
|
|
41
|
+
|
|
42
|
+
- **`<LoginForm>` gains `initialUsername` / `initialPassword` / `prefillNonce`.**
|
|
43
|
+
The `initial*` props **seed** the fields; they do not own them — every value
|
|
44
|
+
stays editable and clearable, so a real account holder can always wipe the demo
|
|
45
|
+
values and sign in with their own. `prefillNonce` is the re-seed signal:
|
|
46
|
+
changing it re-applies the seed over fields the user has edited or cleared.
|
|
47
|
+
|
|
48
|
+
The nonce is not ceremony. `useState` ignores its initial argument on
|
|
49
|
+
re-render, so a fill button wired to `initialUsername` alone would render a
|
|
50
|
+
form that stays stubbornly empty — the nonce is what makes "click the hint →
|
|
51
|
+
form fills" work at all. `useDemoCredentials` manages it for you.
|
|
52
|
+
|
|
53
|
+
### Internal
|
|
54
|
+
|
|
55
|
+
- `useLoginPrefill` — extracts `<LoginForm>`'s credential field state (the only
|
|
56
|
+
part of that component with real logic), so the seed/re-seed contract is unit
|
|
57
|
+
tested directly rather than through the JSX.
|
|
58
|
+
|
|
3
59
|
## 1.10.0 (2026-07-17)
|
|
4
60
|
|
|
5
61
|
Additive release adding the shared **logout sequencer**. Purely additive — every
|
package/README.md
CHANGED
|
@@ -185,6 +185,82 @@ 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
|
+
`useDemoCredentials` owns the wiring, so apps don't hand-roll it:
|
|
201
|
+
|
|
202
|
+
```tsx
|
|
203
|
+
import { AuthScreen, DemoCredentialsHint, LoginForm, useDemoCredentials } from '@dloizides/auth-web';
|
|
204
|
+
|
|
205
|
+
// Hoisted (or memoised): a new object each render re-creates the prop bags.
|
|
206
|
+
const DEMO = { username: 'demo', password: 'ZygosDemo!2026.Try' };
|
|
207
|
+
|
|
208
|
+
function LoginScreen() {
|
|
209
|
+
const demo = useDemoCredentials({ credentials: DEMO, prefillOnMount: true });
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<AuthScreen theme={authTheme}>
|
|
213
|
+
<DemoCredentialsHint
|
|
214
|
+
{...demo.hintProps}
|
|
215
|
+
labels={authLabels.demo}
|
|
216
|
+
testIdPrefix="zygos"
|
|
217
|
+
theme={authTheme}
|
|
218
|
+
/>
|
|
219
|
+
<LoginForm
|
|
220
|
+
{...demo.loginFormProps}
|
|
221
|
+
chromeless
|
|
222
|
+
client={client}
|
|
223
|
+
labels={authLabels.login}
|
|
224
|
+
theme={authTheme}
|
|
225
|
+
onSuccess={handleSignedIn}
|
|
226
|
+
/>
|
|
227
|
+
</AuthScreen>
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
`hintProps` carries `{ credentials, onUse }`; `loginFormProps` carries
|
|
233
|
+
`{ initialUsername, initialPassword, prefillNonce }`.
|
|
234
|
+
|
|
235
|
+
**`prefillOnMount`** (default `false`) chooses the trade:
|
|
236
|
+
|
|
237
|
+
| | Fields on arrival | To sign in as the demo user | Cost |
|
|
238
|
+
|---|---|---|---|
|
|
239
|
+
| `false` | empty | tap *Use these credentials*, then *Sign in* | — |
|
|
240
|
+
| `true` | filled | tap *Sign in* | a real account holder must clear two fields first |
|
|
241
|
+
|
|
242
|
+
Use `true` only on a genuinely public demo surface. The panel renders either way,
|
|
243
|
+
so a visitor can always see *why* the fields are populated.
|
|
244
|
+
|
|
245
|
+
### It fails closed
|
|
246
|
+
|
|
247
|
+
No credentials — or a half-configured pair (blank username, blank password, or a
|
|
248
|
+
field that is `undefined` at runtime because an env var was never set) — renders
|
|
249
|
+
**nothing at all**: zero DOM. A misconfigured demo can never publish an empty
|
|
250
|
+
credentials panel. `resolveDemoCredentials` is exported if you need the same
|
|
251
|
+
decision elsewhere.
|
|
252
|
+
|
|
253
|
+
### The prefill is a seed, not a leash
|
|
254
|
+
|
|
255
|
+
`initialUsername` / `initialPassword` choose the fields' *starting* value and
|
|
256
|
+
then get out of the way: every field stays editable and clearable, so a real
|
|
257
|
+
account holder can always wipe the demo values and sign in with their own. This
|
|
258
|
+
is why `prefillNonce` exists — React ignores a `useState` initial argument on
|
|
259
|
+
re-render, so changing `initial*` alone does nothing once mounted, and a "fill
|
|
260
|
+
the form" button wired without the nonce would leave the form stubbornly empty.
|
|
261
|
+
`useDemoCredentials` manages it for you; drive it yourself only if you are not
|
|
262
|
+
using the hook.
|
|
263
|
+
|
|
188
264
|
## Internationalisation
|
|
189
265
|
|
|
190
266
|
`@dloizides/auth-web` ships **no** i18n framework. Every user-facing string is
|
|
@@ -215,6 +291,8 @@ const route = resolvePostLoginRoute(user, roleRoutes);
|
|
|
215
291
|
| Export | Kind |
|
|
216
292
|
|--------|------|
|
|
217
293
|
| `LoginForm`, `ForgotPasswordForm`, `ResetPasswordForm`, `OtpForm`, `PinForm` | Components |
|
|
294
|
+
| `AuthScreen`, `DemoCredentialsHint`, `PreferredMethodHint` | Composition + login-surface panels |
|
|
295
|
+
| `useDemoCredentials`, `resolveDemoCredentials`, `DemoCredentials` | Public demo credentials |
|
|
218
296
|
| `AuthThemeProvider`, `useAuthTheme`, `defaultAuthTheme`, `AuthTheme` | Theming |
|
|
219
297
|
| `DEFAULT_LOGIN_LABELS`, `DEFAULT_FORGOT_PASSWORD_LABELS`, `DEFAULT_RESET_PASSWORD_LABELS`, `DEFAULT_OTP_LABELS`, `DEFAULT_PIN_LABELS` | Label bags |
|
|
220
298
|
| `useBffAuth`, `useBffForgotPassword`, `useBffResetPassword`, `useResetPasswordForm`, `useOtpLogin`, `usePinLogin` | Headless hooks |
|
package/dist/index.d.mts
CHANGED
|
@@ -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,6 +439,7 @@ 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
|
|
|
429
445
|
/**
|
|
@@ -467,9 +483,27 @@ interface LoginFormProps {
|
|
|
467
483
|
* is byte-identical to before.
|
|
468
484
|
*/
|
|
469
485
|
chromeless?: boolean;
|
|
486
|
+
/**
|
|
487
|
+
* Seeds the username field's INITIAL value. The field stays fully editable and
|
|
488
|
+
* clearable afterwards — this is a starting value, not a controlled one, so a
|
|
489
|
+
* real account holder can always wipe it and type their own.
|
|
490
|
+
*/
|
|
491
|
+
initialUsername?: string;
|
|
492
|
+
/** Seeds the password field's initial value. Editable + clearable, as above. */
|
|
493
|
+
initialPassword?: string;
|
|
494
|
+
/**
|
|
495
|
+
* Re-seed signal. Changing it re-applies `initialUsername` / `initialPassword`
|
|
496
|
+
* to the fields even after the user has edited them — needed because React
|
|
497
|
+
* ignores a `useState` initial value on re-render, so changing the `initial*`
|
|
498
|
+
* props alone does nothing once mounted.
|
|
499
|
+
*
|
|
500
|
+
* Most apps should not manage this by hand: `useDemoCredentials` returns a
|
|
501
|
+
* `loginFormProps` bag carrying all three, ready to spread.
|
|
502
|
+
*/
|
|
503
|
+
prefillNonce?: number;
|
|
470
504
|
}
|
|
471
505
|
/** Themeable password-login form built on `useBffAuth`. */
|
|
472
|
-
declare function LoginForm({ client, theme: themeProp, labels: labelsProp, onSuccess, onForgotPassword, onSignUp, testIdPrefix, chromeless, }: Readonly<LoginFormProps>): ReactElement;
|
|
506
|
+
declare function LoginForm({ client, theme: themeProp, labels: labelsProp, onSuccess, onForgotPassword, onSignUp, testIdPrefix, chromeless, initialUsername, initialPassword, prefillNonce, }: Readonly<LoginFormProps>): ReactElement;
|
|
473
507
|
|
|
474
508
|
/**
|
|
475
509
|
* `<ForgotPasswordForm>` — the ready-made, themeable "request a reset link"
|
|
@@ -1211,6 +1245,67 @@ interface PreferredMethodHintProps {
|
|
|
1211
1245
|
/** Themeable login-screen preferred-method hint. Renders `null` when there is nothing to say. */
|
|
1212
1246
|
declare function PreferredMethodHint({ method, theme: themeProp, labels: labelsProp, testIdPrefix, }: Readonly<PreferredMethodHintProps>): ReactElement | null;
|
|
1213
1247
|
|
|
1248
|
+
/**
|
|
1249
|
+
* Public demo-credential contracts.
|
|
1250
|
+
*
|
|
1251
|
+
* A "demo credential" is a REAL account that a product publishes openly so a
|
|
1252
|
+
* prospective evaluator can sign in without a sign-up step. It is not a bypass:
|
|
1253
|
+
* the credentials travel the ordinary login path (same BFF, same Keycloak, same
|
|
1254
|
+
* session cookie, same roles). The package only makes them *discoverable* and
|
|
1255
|
+
* *one-click fillable* — it never authenticates anything itself.
|
|
1256
|
+
*/
|
|
1257
|
+
/** A publishable demo username + password pair. */
|
|
1258
|
+
interface DemoCredentials {
|
|
1259
|
+
/** The demo account's username. */
|
|
1260
|
+
username: string;
|
|
1261
|
+
/** The demo account's password. */
|
|
1262
|
+
password: string;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
/**
|
|
1266
|
+
* `<DemoCredentialsHint>` — the public-demo credentials panel.
|
|
1267
|
+
*
|
|
1268
|
+
* Mount on the login surface of a product with an OPEN demo account whose
|
|
1269
|
+
* credentials are already published (typically on the marketing site). It shows
|
|
1270
|
+
* the username and password and offers a one-tap "use these credentials" action
|
|
1271
|
+
* that fills the form, so a non-technical evaluator never has to copy-paste a
|
|
1272
|
+
* password between two tabs to see the product.
|
|
1273
|
+
*
|
|
1274
|
+
* It authenticates nothing. It fills fields; `<LoginForm>` then submits them
|
|
1275
|
+
* down the ordinary path — same BFF, same Keycloak, same session, same roles.
|
|
1276
|
+
* There is no bypass here and no credential in this package: the host supplies
|
|
1277
|
+
* the pair, and the demo account's blast radius is whatever the IdP grants it.
|
|
1278
|
+
*
|
|
1279
|
+
* Fails closed: no credentials (or a half-configured pair) renders `null` — zero
|
|
1280
|
+
* DOM — so a misconfigured env var can never publish an empty demo panel.
|
|
1281
|
+
*
|
|
1282
|
+
* Compose it as a child of `<AuthScreen>`, above a `chromeless` `<LoginForm>`;
|
|
1283
|
+
* `useDemoCredentials` wires the two together. Read-only mode (no `onUse`) drops
|
|
1284
|
+
* the button and just displays the credentials.
|
|
1285
|
+
*/
|
|
1286
|
+
|
|
1287
|
+
interface DemoCredentialsHintProps {
|
|
1288
|
+
/**
|
|
1289
|
+
* The demo credentials to advertise. `undefined` — or a pair with a blank
|
|
1290
|
+
* username or password — renders nothing at all.
|
|
1291
|
+
*/
|
|
1292
|
+
credentials?: DemoCredentials;
|
|
1293
|
+
/** Explicit theme; overrides any `<AuthThemeProvider>`. */
|
|
1294
|
+
theme?: AuthTheme;
|
|
1295
|
+
/** Localised copy. Partial — unspecified keys fall back to English defaults. */
|
|
1296
|
+
labels?: Partial<DemoCredentialsHintLabels>;
|
|
1297
|
+
/** Prefix applied to every `testID`. */
|
|
1298
|
+
testIdPrefix?: string;
|
|
1299
|
+
/**
|
|
1300
|
+
* Called with the resolved credentials when the user taps "use these
|
|
1301
|
+
* credentials". Omit to render the panel read-only (no button) — the values
|
|
1302
|
+
* are still selectable, so a visitor can copy them by hand.
|
|
1303
|
+
*/
|
|
1304
|
+
onUse?: (credentials: DemoCredentials) => void;
|
|
1305
|
+
}
|
|
1306
|
+
/** Themeable public-demo credentials panel. Renders `null` when there is no demo. */
|
|
1307
|
+
declare function DemoCredentialsHint({ credentials, theme: themeProp, labels: labelsProp, testIdPrefix, onUse, }: Readonly<DemoCredentialsHintProps>): ReactElement | null;
|
|
1308
|
+
|
|
1214
1309
|
/**
|
|
1215
1310
|
* React context for the `AuthTheme`.
|
|
1216
1311
|
*
|
|
@@ -1316,6 +1411,10 @@ declare const AuthTestIds: {
|
|
|
1316
1411
|
readonly preferredMethodSettingsOption: "auth-preferred-method-settings-option";
|
|
1317
1412
|
readonly preferredMethodSettingsError: "auth-preferred-method-settings-error";
|
|
1318
1413
|
readonly preferredMethodHint: "auth-preferred-method-hint";
|
|
1414
|
+
readonly demoCredentialsHint: "auth-demo-credentials-hint";
|
|
1415
|
+
readonly demoCredentialsUsername: "auth-demo-credentials-username";
|
|
1416
|
+
readonly demoCredentialsPassword: "auth-demo-credentials-password";
|
|
1417
|
+
readonly demoCredentialsUseButton: "auth-demo-credentials-use";
|
|
1319
1418
|
};
|
|
1320
1419
|
/** Apply an optional prefix to a base test ID. */
|
|
1321
1420
|
declare function withTestIdPrefix(baseId: string, prefix?: string): string;
|
|
@@ -1818,6 +1917,77 @@ interface UsePreferredMethodSettingResult {
|
|
|
1818
1917
|
}
|
|
1819
1918
|
declare function usePreferredMethodSetting({ client, onChanged, }: UsePreferredMethodSettingArgs): UsePreferredMethodSettingResult;
|
|
1820
1919
|
|
|
1920
|
+
/** Options for {@link useDemoCredentials}. */
|
|
1921
|
+
interface UseDemoCredentialsOptions {
|
|
1922
|
+
/**
|
|
1923
|
+
* The demo credentials to advertise. Omit (or pass a half-configured pair) and
|
|
1924
|
+
* the whole surface disappears: the hint renders nothing and the form is never
|
|
1925
|
+
* seeded. See `resolveDemoCredentials`.
|
|
1926
|
+
*/
|
|
1927
|
+
credentials?: DemoCredentials;
|
|
1928
|
+
/**
|
|
1929
|
+
* When `true` the form arrives ALREADY filled, so signing in as the demo user
|
|
1930
|
+
* is a single tap on "Sign in" — the hint panel then explains why the fields
|
|
1931
|
+
* are populated and re-fills them if the visitor clears them.
|
|
1932
|
+
*
|
|
1933
|
+
* Defaults to `false`: the fields start empty and the visitor opts in by
|
|
1934
|
+
* tapping "Use these credentials". Prefer the default unless the page is a
|
|
1935
|
+
* genuinely public demo — a login form that arrives pre-filled with someone
|
|
1936
|
+
* else's credentials is confusing on a page real account holders also use.
|
|
1937
|
+
*/
|
|
1938
|
+
prefillOnMount?: boolean;
|
|
1939
|
+
}
|
|
1940
|
+
/** The `<LoginForm>` props that carry the demo prefill. Spread onto the form. */
|
|
1941
|
+
interface DemoCredentialsLoginFormProps {
|
|
1942
|
+
initialUsername?: string;
|
|
1943
|
+
initialPassword?: string;
|
|
1944
|
+
prefillNonce: number;
|
|
1945
|
+
}
|
|
1946
|
+
/** The `<DemoCredentialsHint>` props that carry the credentials + fill action. */
|
|
1947
|
+
interface DemoCredentialsHintWiring {
|
|
1948
|
+
credentials?: DemoCredentials;
|
|
1949
|
+
onUse: (credentials: DemoCredentials) => void;
|
|
1950
|
+
}
|
|
1951
|
+
/** What {@link useDemoCredentials} hands back. */
|
|
1952
|
+
interface UseDemoCredentialsResult {
|
|
1953
|
+
/** Spread onto `<LoginForm>`. */
|
|
1954
|
+
loginFormProps: DemoCredentialsLoginFormProps;
|
|
1955
|
+
/** Spread onto `<DemoCredentialsHint>`. */
|
|
1956
|
+
hintProps: DemoCredentialsHintWiring;
|
|
1957
|
+
}
|
|
1958
|
+
/** Wire a demo-credentials hint to a login form. Returns two prop bags to spread. */
|
|
1959
|
+
declare function useDemoCredentials({ credentials, prefillOnMount, }?: Readonly<UseDemoCredentialsOptions>): UseDemoCredentialsResult;
|
|
1960
|
+
|
|
1961
|
+
/**
|
|
1962
|
+
* `resolveDemoCredentials` — the single fail-closed gate for the demo surface.
|
|
1963
|
+
*
|
|
1964
|
+
* Every demo affordance in the package (the `<DemoCredentialsHint>` panel and
|
|
1965
|
+
* the `useDemoCredentials` wiring hook) routes its input through this function,
|
|
1966
|
+
* so "should we advertise a demo account at all?" is decided in exactly ONE
|
|
1967
|
+
* place and always the same way.
|
|
1968
|
+
*
|
|
1969
|
+
* Fail closed, deliberately. The realistic source of these values is an env var
|
|
1970
|
+
* (`process.env.EXPO_PUBLIC_DEMO_USERNAME`), which is `string | undefined` at
|
|
1971
|
+
* runtime no matter what the type says — a consumer writing `username: env.X!`
|
|
1972
|
+
* hands us `undefined` and TypeScript never notices. A half-configured demo must
|
|
1973
|
+
* render NOTHING rather than an empty panel inviting a client to sign in with
|
|
1974
|
+
* blank credentials, so anything that is not a genuinely non-empty string pair
|
|
1975
|
+
* resolves to `null`.
|
|
1976
|
+
*/
|
|
1977
|
+
|
|
1978
|
+
/**
|
|
1979
|
+
* Narrow an unvalidated demo-credential pair to a usable one, or `null`.
|
|
1980
|
+
*
|
|
1981
|
+
* Returns `null` for: `undefined` / `null`, a non-string field (runtime junk
|
|
1982
|
+
* from an unset env var), a blank/whitespace-only username, and an empty
|
|
1983
|
+
* password. Otherwise returns a NEW pair with the username trimmed.
|
|
1984
|
+
*
|
|
1985
|
+
* The password is deliberately NOT trimmed: leading/trailing whitespace can be
|
|
1986
|
+
* a legitimate part of a password, and silently altering it would turn a
|
|
1987
|
+
* working credential into a mystery login failure.
|
|
1988
|
+
*/
|
|
1989
|
+
declare function resolveDemoCredentials(credentials?: DemoCredentials | null): DemoCredentials | null;
|
|
1990
|
+
|
|
1821
1991
|
/**
|
|
1822
1992
|
* `createBffAuthClient` — the one-line wiring of a same-origin `BffAuthClient`.
|
|
1823
1993
|
*
|
|
@@ -2061,4 +2231,4 @@ declare function validatePasswordPolicy(password: string): PasswordPolicyError[]
|
|
|
2061
2231
|
/** `true` when the password satisfies every policy rule. */
|
|
2062
2232
|
declare function isPasswordValid(password: string): boolean;
|
|
2063
2233
|
|
|
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 };
|
|
2234
|
+
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, type DemoCredentials, 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, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -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,6 +439,7 @@ 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
|
|
|
429
445
|
/**
|
|
@@ -467,9 +483,27 @@ interface LoginFormProps {
|
|
|
467
483
|
* is byte-identical to before.
|
|
468
484
|
*/
|
|
469
485
|
chromeless?: boolean;
|
|
486
|
+
/**
|
|
487
|
+
* Seeds the username field's INITIAL value. The field stays fully editable and
|
|
488
|
+
* clearable afterwards — this is a starting value, not a controlled one, so a
|
|
489
|
+
* real account holder can always wipe it and type their own.
|
|
490
|
+
*/
|
|
491
|
+
initialUsername?: string;
|
|
492
|
+
/** Seeds the password field's initial value. Editable + clearable, as above. */
|
|
493
|
+
initialPassword?: string;
|
|
494
|
+
/**
|
|
495
|
+
* Re-seed signal. Changing it re-applies `initialUsername` / `initialPassword`
|
|
496
|
+
* to the fields even after the user has edited them — needed because React
|
|
497
|
+
* ignores a `useState` initial value on re-render, so changing the `initial*`
|
|
498
|
+
* props alone does nothing once mounted.
|
|
499
|
+
*
|
|
500
|
+
* Most apps should not manage this by hand: `useDemoCredentials` returns a
|
|
501
|
+
* `loginFormProps` bag carrying all three, ready to spread.
|
|
502
|
+
*/
|
|
503
|
+
prefillNonce?: number;
|
|
470
504
|
}
|
|
471
505
|
/** Themeable password-login form built on `useBffAuth`. */
|
|
472
|
-
declare function LoginForm({ client, theme: themeProp, labels: labelsProp, onSuccess, onForgotPassword, onSignUp, testIdPrefix, chromeless, }: Readonly<LoginFormProps>): ReactElement;
|
|
506
|
+
declare function LoginForm({ client, theme: themeProp, labels: labelsProp, onSuccess, onForgotPassword, onSignUp, testIdPrefix, chromeless, initialUsername, initialPassword, prefillNonce, }: Readonly<LoginFormProps>): ReactElement;
|
|
473
507
|
|
|
474
508
|
/**
|
|
475
509
|
* `<ForgotPasswordForm>` — the ready-made, themeable "request a reset link"
|
|
@@ -1211,6 +1245,67 @@ interface PreferredMethodHintProps {
|
|
|
1211
1245
|
/** Themeable login-screen preferred-method hint. Renders `null` when there is nothing to say. */
|
|
1212
1246
|
declare function PreferredMethodHint({ method, theme: themeProp, labels: labelsProp, testIdPrefix, }: Readonly<PreferredMethodHintProps>): ReactElement | null;
|
|
1213
1247
|
|
|
1248
|
+
/**
|
|
1249
|
+
* Public demo-credential contracts.
|
|
1250
|
+
*
|
|
1251
|
+
* A "demo credential" is a REAL account that a product publishes openly so a
|
|
1252
|
+
* prospective evaluator can sign in without a sign-up step. It is not a bypass:
|
|
1253
|
+
* the credentials travel the ordinary login path (same BFF, same Keycloak, same
|
|
1254
|
+
* session cookie, same roles). The package only makes them *discoverable* and
|
|
1255
|
+
* *one-click fillable* — it never authenticates anything itself.
|
|
1256
|
+
*/
|
|
1257
|
+
/** A publishable demo username + password pair. */
|
|
1258
|
+
interface DemoCredentials {
|
|
1259
|
+
/** The demo account's username. */
|
|
1260
|
+
username: string;
|
|
1261
|
+
/** The demo account's password. */
|
|
1262
|
+
password: string;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
/**
|
|
1266
|
+
* `<DemoCredentialsHint>` — the public-demo credentials panel.
|
|
1267
|
+
*
|
|
1268
|
+
* Mount on the login surface of a product with an OPEN demo account whose
|
|
1269
|
+
* credentials are already published (typically on the marketing site). It shows
|
|
1270
|
+
* the username and password and offers a one-tap "use these credentials" action
|
|
1271
|
+
* that fills the form, so a non-technical evaluator never has to copy-paste a
|
|
1272
|
+
* password between two tabs to see the product.
|
|
1273
|
+
*
|
|
1274
|
+
* It authenticates nothing. It fills fields; `<LoginForm>` then submits them
|
|
1275
|
+
* down the ordinary path — same BFF, same Keycloak, same session, same roles.
|
|
1276
|
+
* There is no bypass here and no credential in this package: the host supplies
|
|
1277
|
+
* the pair, and the demo account's blast radius is whatever the IdP grants it.
|
|
1278
|
+
*
|
|
1279
|
+
* Fails closed: no credentials (or a half-configured pair) renders `null` — zero
|
|
1280
|
+
* DOM — so a misconfigured env var can never publish an empty demo panel.
|
|
1281
|
+
*
|
|
1282
|
+
* Compose it as a child of `<AuthScreen>`, above a `chromeless` `<LoginForm>`;
|
|
1283
|
+
* `useDemoCredentials` wires the two together. Read-only mode (no `onUse`) drops
|
|
1284
|
+
* the button and just displays the credentials.
|
|
1285
|
+
*/
|
|
1286
|
+
|
|
1287
|
+
interface DemoCredentialsHintProps {
|
|
1288
|
+
/**
|
|
1289
|
+
* The demo credentials to advertise. `undefined` — or a pair with a blank
|
|
1290
|
+
* username or password — renders nothing at all.
|
|
1291
|
+
*/
|
|
1292
|
+
credentials?: DemoCredentials;
|
|
1293
|
+
/** Explicit theme; overrides any `<AuthThemeProvider>`. */
|
|
1294
|
+
theme?: AuthTheme;
|
|
1295
|
+
/** Localised copy. Partial — unspecified keys fall back to English defaults. */
|
|
1296
|
+
labels?: Partial<DemoCredentialsHintLabels>;
|
|
1297
|
+
/** Prefix applied to every `testID`. */
|
|
1298
|
+
testIdPrefix?: string;
|
|
1299
|
+
/**
|
|
1300
|
+
* Called with the resolved credentials when the user taps "use these
|
|
1301
|
+
* credentials". Omit to render the panel read-only (no button) — the values
|
|
1302
|
+
* are still selectable, so a visitor can copy them by hand.
|
|
1303
|
+
*/
|
|
1304
|
+
onUse?: (credentials: DemoCredentials) => void;
|
|
1305
|
+
}
|
|
1306
|
+
/** Themeable public-demo credentials panel. Renders `null` when there is no demo. */
|
|
1307
|
+
declare function DemoCredentialsHint({ credentials, theme: themeProp, labels: labelsProp, testIdPrefix, onUse, }: Readonly<DemoCredentialsHintProps>): ReactElement | null;
|
|
1308
|
+
|
|
1214
1309
|
/**
|
|
1215
1310
|
* React context for the `AuthTheme`.
|
|
1216
1311
|
*
|
|
@@ -1316,6 +1411,10 @@ declare const AuthTestIds: {
|
|
|
1316
1411
|
readonly preferredMethodSettingsOption: "auth-preferred-method-settings-option";
|
|
1317
1412
|
readonly preferredMethodSettingsError: "auth-preferred-method-settings-error";
|
|
1318
1413
|
readonly preferredMethodHint: "auth-preferred-method-hint";
|
|
1414
|
+
readonly demoCredentialsHint: "auth-demo-credentials-hint";
|
|
1415
|
+
readonly demoCredentialsUsername: "auth-demo-credentials-username";
|
|
1416
|
+
readonly demoCredentialsPassword: "auth-demo-credentials-password";
|
|
1417
|
+
readonly demoCredentialsUseButton: "auth-demo-credentials-use";
|
|
1319
1418
|
};
|
|
1320
1419
|
/** Apply an optional prefix to a base test ID. */
|
|
1321
1420
|
declare function withTestIdPrefix(baseId: string, prefix?: string): string;
|
|
@@ -1818,6 +1917,77 @@ interface UsePreferredMethodSettingResult {
|
|
|
1818
1917
|
}
|
|
1819
1918
|
declare function usePreferredMethodSetting({ client, onChanged, }: UsePreferredMethodSettingArgs): UsePreferredMethodSettingResult;
|
|
1820
1919
|
|
|
1920
|
+
/** Options for {@link useDemoCredentials}. */
|
|
1921
|
+
interface UseDemoCredentialsOptions {
|
|
1922
|
+
/**
|
|
1923
|
+
* The demo credentials to advertise. Omit (or pass a half-configured pair) and
|
|
1924
|
+
* the whole surface disappears: the hint renders nothing and the form is never
|
|
1925
|
+
* seeded. See `resolveDemoCredentials`.
|
|
1926
|
+
*/
|
|
1927
|
+
credentials?: DemoCredentials;
|
|
1928
|
+
/**
|
|
1929
|
+
* When `true` the form arrives ALREADY filled, so signing in as the demo user
|
|
1930
|
+
* is a single tap on "Sign in" — the hint panel then explains why the fields
|
|
1931
|
+
* are populated and re-fills them if the visitor clears them.
|
|
1932
|
+
*
|
|
1933
|
+
* Defaults to `false`: the fields start empty and the visitor opts in by
|
|
1934
|
+
* tapping "Use these credentials". Prefer the default unless the page is a
|
|
1935
|
+
* genuinely public demo — a login form that arrives pre-filled with someone
|
|
1936
|
+
* else's credentials is confusing on a page real account holders also use.
|
|
1937
|
+
*/
|
|
1938
|
+
prefillOnMount?: boolean;
|
|
1939
|
+
}
|
|
1940
|
+
/** The `<LoginForm>` props that carry the demo prefill. Spread onto the form. */
|
|
1941
|
+
interface DemoCredentialsLoginFormProps {
|
|
1942
|
+
initialUsername?: string;
|
|
1943
|
+
initialPassword?: string;
|
|
1944
|
+
prefillNonce: number;
|
|
1945
|
+
}
|
|
1946
|
+
/** The `<DemoCredentialsHint>` props that carry the credentials + fill action. */
|
|
1947
|
+
interface DemoCredentialsHintWiring {
|
|
1948
|
+
credentials?: DemoCredentials;
|
|
1949
|
+
onUse: (credentials: DemoCredentials) => void;
|
|
1950
|
+
}
|
|
1951
|
+
/** What {@link useDemoCredentials} hands back. */
|
|
1952
|
+
interface UseDemoCredentialsResult {
|
|
1953
|
+
/** Spread onto `<LoginForm>`. */
|
|
1954
|
+
loginFormProps: DemoCredentialsLoginFormProps;
|
|
1955
|
+
/** Spread onto `<DemoCredentialsHint>`. */
|
|
1956
|
+
hintProps: DemoCredentialsHintWiring;
|
|
1957
|
+
}
|
|
1958
|
+
/** Wire a demo-credentials hint to a login form. Returns two prop bags to spread. */
|
|
1959
|
+
declare function useDemoCredentials({ credentials, prefillOnMount, }?: Readonly<UseDemoCredentialsOptions>): UseDemoCredentialsResult;
|
|
1960
|
+
|
|
1961
|
+
/**
|
|
1962
|
+
* `resolveDemoCredentials` — the single fail-closed gate for the demo surface.
|
|
1963
|
+
*
|
|
1964
|
+
* Every demo affordance in the package (the `<DemoCredentialsHint>` panel and
|
|
1965
|
+
* the `useDemoCredentials` wiring hook) routes its input through this function,
|
|
1966
|
+
* so "should we advertise a demo account at all?" is decided in exactly ONE
|
|
1967
|
+
* place and always the same way.
|
|
1968
|
+
*
|
|
1969
|
+
* Fail closed, deliberately. The realistic source of these values is an env var
|
|
1970
|
+
* (`process.env.EXPO_PUBLIC_DEMO_USERNAME`), which is `string | undefined` at
|
|
1971
|
+
* runtime no matter what the type says — a consumer writing `username: env.X!`
|
|
1972
|
+
* hands us `undefined` and TypeScript never notices. A half-configured demo must
|
|
1973
|
+
* render NOTHING rather than an empty panel inviting a client to sign in with
|
|
1974
|
+
* blank credentials, so anything that is not a genuinely non-empty string pair
|
|
1975
|
+
* resolves to `null`.
|
|
1976
|
+
*/
|
|
1977
|
+
|
|
1978
|
+
/**
|
|
1979
|
+
* Narrow an unvalidated demo-credential pair to a usable one, or `null`.
|
|
1980
|
+
*
|
|
1981
|
+
* Returns `null` for: `undefined` / `null`, a non-string field (runtime junk
|
|
1982
|
+
* from an unset env var), a blank/whitespace-only username, and an empty
|
|
1983
|
+
* password. Otherwise returns a NEW pair with the username trimmed.
|
|
1984
|
+
*
|
|
1985
|
+
* The password is deliberately NOT trimmed: leading/trailing whitespace can be
|
|
1986
|
+
* a legitimate part of a password, and silently altering it would turn a
|
|
1987
|
+
* working credential into a mystery login failure.
|
|
1988
|
+
*/
|
|
1989
|
+
declare function resolveDemoCredentials(credentials?: DemoCredentials | null): DemoCredentials | null;
|
|
1990
|
+
|
|
1821
1991
|
/**
|
|
1822
1992
|
* `createBffAuthClient` — the one-line wiring of a same-origin `BffAuthClient`.
|
|
1823
1993
|
*
|
|
@@ -2061,4 +2231,4 @@ declare function validatePasswordPolicy(password: string): PasswordPolicyError[]
|
|
|
2061
2231
|
/** `true` when the password satisfies every policy rule. */
|
|
2062
2232
|
declare function isPasswordValid(password: string): boolean;
|
|
2063
2233
|
|
|
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 };
|
|
2234
|
+
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, type DemoCredentials, 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, 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 };
|