@dloizides/auth-web 1.12.1 → 1.14.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/dist/index.mjs CHANGED
@@ -8,15 +8,18 @@ export { BffAuthClient, createFetchHttpClient } from '@dloizides/auth-client';
8
8
  // src/components/AuthScreen.tsx
9
9
  var FULL_WIDTH = "100%";
10
10
  var CARD_BORDER_WIDTH = 1;
11
+ var CARD_TOP_OFFSET = 64;
11
12
  function useAuthScreenStyles(theme) {
12
13
  return useMemo(() => {
13
14
  const { colors, radii, spacing, typography } = theme;
14
15
  return StyleSheet.create({
15
16
  screen: {
16
17
  flex: 1,
17
- justifyContent: "center",
18
+ // Deliberately NOT `justifyContent: 'center'` — see CARD_TOP_OFFSET.
19
+ justifyContent: "flex-start",
18
20
  alignItems: "center",
19
21
  padding: spacing.md,
22
+ paddingTop: CARD_TOP_OFFSET,
20
23
  backgroundColor: colors.background
21
24
  },
22
25
  card: {
@@ -74,7 +77,8 @@ var defaultAuthTheme = {
74
77
  typography: {
75
78
  title: 28,
76
79
  subtitle: 16,
77
- label: 14,
80
+ // 13, not 14 — the shared contract's `field` voice. See AuthThemeTypography.label.
81
+ label: 13,
78
82
  body: 16,
79
83
  caption: 12
80
84
  }
@@ -281,7 +285,9 @@ var DEFAULT_DEMO_CREDENTIALS_HINT_LABELS = {
281
285
  usernameLabel: "Username",
282
286
  passwordLabel: "Password",
283
287
  useCredentials: "Use these credentials",
284
- useCredentialsHint: "Fill the sign-in form with the demo username and password"
288
+ useCredentialsHint: "Fill the sign-in form with the demo username and password",
289
+ toggle: "Try the demo",
290
+ toggleHint: "Show the demo account username and password"
285
291
  };
286
292
 
287
293
  // src/components/labels/resetPasswordLabels.ts
@@ -378,7 +384,9 @@ var AuthTestIds = {
378
384
  demoCredentialsHint: "auth-demo-credentials-hint",
379
385
  demoCredentialsUsername: "auth-demo-credentials-username",
380
386
  demoCredentialsPassword: "auth-demo-credentials-password",
381
- demoCredentialsUseButton: "auth-demo-credentials-use"
387
+ demoCredentialsUseButton: "auth-demo-credentials-use",
388
+ // The collapsed disclosure trigger (`disclosure` variant only).
389
+ demoCredentialsToggle: "auth-demo-credentials-toggle"
382
390
  };
383
391
  function withTestIdPrefix(baseId, prefix) {
384
392
  return prefix === void 0 || prefix === "" ? baseId : `${prefix}-${baseId}`;
@@ -386,15 +394,21 @@ function withTestIdPrefix(baseId, prefix) {
386
394
  var FULL_WIDTH2 = "100%";
387
395
  var CARD_MAX_WIDTH = 420;
388
396
  var BUTTON_VERTICAL_PADDING = 14;
397
+ var SCREEN_TOP_OFFSET = 64;
389
398
  function useAuthStyles(theme) {
390
399
  return useMemo(() => {
391
400
  const { colors, radii, spacing, typography } = theme;
392
401
  return StyleSheet.create({
393
402
  screen: {
394
403
  flex: 1,
395
- justifyContent: "center",
404
+ // Top-anchored, NOT centred — a centred card re-centres as it grows and
405
+ // drags the inputs up under the cursor. Same reasoning (and the same
406
+ // measurement) as `useAuthScreenStyles`' CARD_TOP_OFFSET; kept in step so
407
+ // a standalone `<LoginForm>` and an `<AuthScreen>`-composed one agree.
408
+ justifyContent: "flex-start",
396
409
  alignItems: "center",
397
410
  padding: spacing.md,
411
+ paddingTop: SCREEN_TOP_OFFSET,
398
412
  backgroundColor: colors.background
399
413
  },
400
414
  card: {
@@ -2008,14 +2022,15 @@ function DevicePinLengthPicker({
2008
2022
  const theme = useAuthTheme(themeProp);
2009
2023
  const dynamic = usePickerStyles(theme);
2010
2024
  const baseId = withTestIdPrefix(AuthTestIds.devicePinEnrollLength, testIdPrefix);
2011
- return /* @__PURE__ */ jsx(View, { style: styles2.row, children: DEVICE_PIN_ALLOWED_DIGITS.map((option) => {
2025
+ return /* @__PURE__ */ jsx(View, { accessibilityRole: "radiogroup", role: "radiogroup", style: styles2.row, children: DEVICE_PIN_ALLOWED_DIGITS.map((option) => {
2012
2026
  const active = option === selected;
2013
2027
  return /* @__PURE__ */ jsx(
2014
2028
  Pressable,
2015
2029
  {
2030
+ "aria-checked": active,
2016
2031
  accessibilityHint: interpolate(optionHint, { count: option }),
2017
2032
  accessibilityLabel: String(option),
2018
- accessibilityRole: "button",
2033
+ accessibilityRole: "radio",
2019
2034
  accessibilityState: { selected: active },
2020
2035
  disabled,
2021
2036
  style: [styles2.pill, dynamic.pill, active ? dynamic.active : null],
@@ -3159,6 +3174,7 @@ function PreferredMethodSettingsCard({
3159
3174
  return /* @__PURE__ */ jsx(
3160
3175
  TouchableOpacity,
3161
3176
  {
3177
+ "aria-checked": isSelected,
3162
3178
  accessibilityHint: labels.description,
3163
3179
  accessibilityLabel: option.label,
3164
3180
  accessibilityRole: "radio",
@@ -3215,7 +3231,62 @@ function PreferredMethodHint({
3215
3231
  }
3216
3232
  return /* @__PURE__ */ jsx(View, { testID: withTestIdPrefix(AuthTestIds.preferredMethodHint, testIdPrefix), children: /* @__PURE__ */ jsx(Text, { style: styles3.helperText, children: text }) });
3217
3233
  }
3234
+ function DemoCredentialsBody({
3235
+ credentials,
3236
+ labels,
3237
+ styles: styles3,
3238
+ authStyles,
3239
+ testIdPrefix,
3240
+ onUse
3241
+ }) {
3242
+ return /* @__PURE__ */ jsxs(View, { children: [
3243
+ /* @__PURE__ */ jsxs(View, { style: styles3.row, children: [
3244
+ /* @__PURE__ */ jsx(Text, { style: styles3.rowLabel, children: labels.usernameLabel }),
3245
+ /* @__PURE__ */ jsx(
3246
+ Text,
3247
+ {
3248
+ selectable: true,
3249
+ style: styles3.rowValue,
3250
+ testID: withTestIdPrefix(AuthTestIds.demoCredentialsUsername, testIdPrefix),
3251
+ children: credentials.username
3252
+ }
3253
+ )
3254
+ ] }),
3255
+ /* @__PURE__ */ jsxs(View, { style: styles3.row, children: [
3256
+ /* @__PURE__ */ jsx(Text, { style: styles3.rowLabel, children: labels.passwordLabel }),
3257
+ /* @__PURE__ */ jsx(
3258
+ Text,
3259
+ {
3260
+ selectable: true,
3261
+ style: styles3.rowValue,
3262
+ testID: withTestIdPrefix(AuthTestIds.demoCredentialsPassword, testIdPrefix),
3263
+ children: credentials.password
3264
+ }
3265
+ )
3266
+ ] }),
3267
+ onUse !== void 0 ? /* @__PURE__ */ jsx(
3268
+ TouchableOpacity,
3269
+ {
3270
+ accessibilityHint: labels.useCredentialsHint,
3271
+ accessibilityLabel: labels.useCredentials,
3272
+ accessibilityRole: "button",
3273
+ style: [authStyles.secondaryButton, styles3.useButton],
3274
+ testID: withTestIdPrefix(AuthTestIds.demoCredentialsUseButton, testIdPrefix),
3275
+ onPress: onUse,
3276
+ children: /* @__PURE__ */ jsx(Text, { style: authStyles.secondaryButtonText, children: labels.useCredentials })
3277
+ }
3278
+ ) : null
3279
+ ] });
3280
+ }
3281
+
3282
+ // src/components/DemoCredentialsHintVariant.ts
3283
+ var DemoCredentialsHintVariant = /* @__PURE__ */ ((DemoCredentialsHintVariant2) => {
3284
+ DemoCredentialsHintVariant2["Panel"] = "panel";
3285
+ DemoCredentialsHintVariant2["Disclosure"] = "disclosure";
3286
+ return DemoCredentialsHintVariant2;
3287
+ })(DemoCredentialsHintVariant || {});
3218
3288
  var PANEL_BORDER_WIDTH = 1;
3289
+ var TRIGGER_MIN_HEIGHT = 32;
3219
3290
  var ACCENT_RAIL_WIDTH = 3;
3220
3291
  var TITLE_LETTER_SPACING = 0.8;
3221
3292
  var DESCRIPTION_LINE_HEIGHT_RATIO = 1.45;
@@ -3276,6 +3347,40 @@ function useDemoCredentialsStyles(theme) {
3276
3347
  flexShrink: 1,
3277
3348
  backgroundColor: colors.surface,
3278
3349
  color: colors.text
3350
+ },
3351
+ // ── Disclosure variant ──────────────────────────────────────────────
3352
+ // No panel fill, no border, no brand rail: the collapsed state is one
3353
+ // line of text and nothing else, so on a page a real customer uses it
3354
+ // reads as a footnote rather than as a second call to action.
3355
+ disclosure: {
3356
+ marginTop: spacing.md,
3357
+ alignSelf: "stretch"
3358
+ },
3359
+ disclosureTrigger: {
3360
+ alignSelf: "center",
3361
+ justifyContent: "center",
3362
+ minHeight: TRIGGER_MIN_HEIGHT,
3363
+ paddingHorizontal: spacing.xs
3364
+ },
3365
+ disclosureTriggerText: {
3366
+ fontSize: typography.caption,
3367
+ textDecorationLine: "underline",
3368
+ // `textSecondary`, NOT a dimmed `text`. This is the same token the rest
3369
+ // of the helper copy uses, so it inherits whatever AA contrast the
3370
+ // consuming app already guarantees. Discretion here is carried by the
3371
+ // caption size, the centred placement below the form, and the absence
3372
+ // of any fill or border — never by fading the text toward the
3373
+ // background, which is how "discreet" quietly becomes a contrast bug.
3374
+ color: colors.textSecondary
3375
+ },
3376
+ disclosureBody: {
3377
+ marginTop: spacing.sm,
3378
+ paddingTop: spacing.sm,
3379
+ borderTopWidth: PANEL_BORDER_WIDTH,
3380
+ borderTopColor: colors.border
3381
+ },
3382
+ useButton: {
3383
+ alignSelf: "stretch"
3279
3384
  }
3280
3385
  });
3281
3386
  }, [theme]);
@@ -3296,6 +3401,7 @@ function resolveDemoCredentials(credentials) {
3296
3401
  }
3297
3402
  function DemoCredentialsHint({
3298
3403
  credentials,
3404
+ variant = "disclosure" /* Disclosure */,
3299
3405
  theme: themeProp,
3300
3406
  labels: labelsProp,
3301
3407
  testIdPrefix,
@@ -3304,6 +3410,7 @@ function DemoCredentialsHint({
3304
3410
  const theme = useAuthTheme(themeProp);
3305
3411
  const authStyles = useAuthStyles(theme);
3306
3412
  const styles3 = useDemoCredentialsStyles(theme);
3413
+ const [expanded, setExpanded] = useState(false);
3307
3414
  const labels = useMemo(
3308
3415
  () => ({ ...DEFAULT_DEMO_CREDENTIALS_HINT_LABELS, ...labelsProp }),
3309
3416
  [labelsProp]
@@ -3314,53 +3421,58 @@ function DemoCredentialsHint({
3314
3421
  onUse(resolved);
3315
3422
  }
3316
3423
  }, [resolved, onUse]);
3424
+ const handleToggle = useCallback(() => {
3425
+ setExpanded((current) => !current);
3426
+ }, []);
3317
3427
  if (resolved === null) {
3318
3428
  return null;
3319
3429
  }
3430
+ const body = /* @__PURE__ */ jsx(
3431
+ DemoCredentialsBody,
3432
+ {
3433
+ authStyles,
3434
+ credentials: resolved,
3435
+ labels,
3436
+ styles: styles3,
3437
+ testIdPrefix,
3438
+ onUse: onUse === void 0 ? void 0 : handleUse
3439
+ }
3440
+ );
3441
+ if (variant === "panel" /* Panel */) {
3442
+ return /* @__PURE__ */ jsxs(
3443
+ View,
3444
+ {
3445
+ style: styles3.panel,
3446
+ testID: withTestIdPrefix(AuthTestIds.demoCredentialsHint, testIdPrefix),
3447
+ children: [
3448
+ /* @__PURE__ */ jsx(Text, { style: styles3.title, children: labels.title }),
3449
+ /* @__PURE__ */ jsx(Text, { style: styles3.description, children: labels.description }),
3450
+ body
3451
+ ]
3452
+ }
3453
+ );
3454
+ }
3320
3455
  return /* @__PURE__ */ jsxs(
3321
3456
  View,
3322
3457
  {
3323
- style: styles3.panel,
3458
+ style: styles3.disclosure,
3324
3459
  testID: withTestIdPrefix(AuthTestIds.demoCredentialsHint, testIdPrefix),
3325
3460
  children: [
3326
- /* @__PURE__ */ jsx(Text, { style: styles3.title, children: labels.title }),
3327
- /* @__PURE__ */ jsx(Text, { style: styles3.description, children: labels.description }),
3328
- /* @__PURE__ */ jsxs(View, { style: styles3.row, children: [
3329
- /* @__PURE__ */ jsx(Text, { style: styles3.rowLabel, children: labels.usernameLabel }),
3330
- /* @__PURE__ */ jsx(
3331
- Text,
3332
- {
3333
- selectable: true,
3334
- style: styles3.rowValue,
3335
- testID: withTestIdPrefix(AuthTestIds.demoCredentialsUsername, testIdPrefix),
3336
- children: resolved.username
3337
- }
3338
- )
3339
- ] }),
3340
- /* @__PURE__ */ jsxs(View, { style: styles3.row, children: [
3341
- /* @__PURE__ */ jsx(Text, { style: styles3.rowLabel, children: labels.passwordLabel }),
3342
- /* @__PURE__ */ jsx(
3343
- Text,
3344
- {
3345
- selectable: true,
3346
- style: styles3.rowValue,
3347
- testID: withTestIdPrefix(AuthTestIds.demoCredentialsPassword, testIdPrefix),
3348
- children: resolved.password
3349
- }
3350
- )
3351
- ] }),
3352
- onUse !== void 0 ? /* @__PURE__ */ jsx(
3461
+ /* @__PURE__ */ jsx(
3353
3462
  TouchableOpacity,
3354
3463
  {
3355
- accessibilityHint: labels.useCredentialsHint,
3356
- accessibilityLabel: labels.useCredentials,
3464
+ "aria-expanded": expanded,
3465
+ accessibilityHint: labels.toggleHint,
3466
+ accessibilityLabel: labels.toggle,
3357
3467
  accessibilityRole: "button",
3358
- style: authStyles.secondaryButton,
3359
- testID: withTestIdPrefix(AuthTestIds.demoCredentialsUseButton, testIdPrefix),
3360
- onPress: handleUse,
3361
- children: /* @__PURE__ */ jsx(Text, { style: authStyles.secondaryButtonText, children: labels.useCredentials })
3468
+ accessibilityState: { expanded },
3469
+ style: styles3.disclosureTrigger,
3470
+ testID: withTestIdPrefix(AuthTestIds.demoCredentialsToggle, testIdPrefix),
3471
+ onPress: handleToggle,
3472
+ children: /* @__PURE__ */ jsx(Text, { style: styles3.disclosureTriggerText, children: labels.toggle })
3362
3473
  }
3363
- ) : null
3474
+ ),
3475
+ expanded ? /* @__PURE__ */ jsx(View, { style: styles3.disclosureBody, children: body }) : null
3364
3476
  ]
3365
3477
  }
3366
3478
  );
@@ -3606,6 +3718,6 @@ async function performBffLogout(options) {
3606
3718
  runGuarded(onRedirect, onError);
3607
3719
  }
3608
3720
 
3609
- export { AuthScreen, AuthTestIds, AuthThemeProvider, BffAuthStatus, 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, DevicePinEnrollErrorKey, DevicePinEnrollForm, DevicePinErrorKey, DevicePinInput, DevicePinLengthPicker, DevicePinOffer, DevicePinSettingsCard, DevicePinUnlockScreen, ForgotPasswordFields, ForgotPasswordForm, LoginForm, OtpForm, OtpLoginStep, PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, PasskeyCeremonyMode, PasskeyCeremonyStatus, PasskeyLoginButton, PasskeySettingsCard, PasswordPolicyError, PinForm, PreferredMethodHint, PreferredMethodSettingsCard, PrefillIntent, ResetPasswordError, ResetPasswordForm, 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 };
3721
+ export { AuthScreen, AuthTestIds, AuthThemeProvider, BffAuthStatus, 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, DemoCredentialsHintVariant, DevicePinEnrollErrorKey, DevicePinEnrollForm, DevicePinErrorKey, DevicePinInput, DevicePinLengthPicker, DevicePinOffer, DevicePinSettingsCard, DevicePinUnlockScreen, ForgotPasswordFields, ForgotPasswordForm, LoginForm, OtpForm, OtpLoginStep, PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, PasskeyCeremonyMode, PasskeyCeremonyStatus, PasskeyLoginButton, PasskeySettingsCard, PasswordPolicyError, PinForm, PreferredMethodHint, PreferredMethodSettingsCard, PrefillIntent, ResetPasswordError, ResetPasswordForm, 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 };
3610
3722
  //# sourceMappingURL=index.mjs.map
3611
3723
  //# sourceMappingURL=index.mjs.map