@dloizides/auth-web 1.13.0 → 1.16.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 -1
- package/dist/index.d.mts +292 -5
- package/dist/index.d.ts +292 -5
- package/dist/index.js +408 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +403 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StyleSheet, Platform, View, Text, TextInput, TouchableOpacity, ActivityIndicator, Pressable } from 'react-native';
|
|
1
|
+
import { StyleSheet, Platform, View, Text, TextInput, TouchableOpacity, ActivityIndicator, Pressable, ScrollView } from 'react-native';
|
|
2
2
|
import { createContext, useContext, useMemo, useState, useRef, useEffect, useCallback } from 'react';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { useMutation } from '@tanstack/react-query';
|
|
@@ -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:
|
|
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
|
-
|
|
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
|
}
|
|
@@ -303,6 +307,29 @@ var DEFAULT_RESET_PASSWORD_LABELS = {
|
|
|
303
307
|
errorNetwork: "Something went wrong. Please try again."
|
|
304
308
|
};
|
|
305
309
|
|
|
310
|
+
// src/components/labels/accountSettingsLabels.ts
|
|
311
|
+
var DEFAULT_ACCOUNT_SETTINGS_LABELS = {
|
|
312
|
+
heading: "Account settings",
|
|
313
|
+
changePasswordTitle: "Change password",
|
|
314
|
+
changePasswordDescription: "Update the password you use to sign in.",
|
|
315
|
+
currentPasswordLabel: "Current password",
|
|
316
|
+
currentPasswordPlaceholder: "Enter your current password",
|
|
317
|
+
newPasswordLabel: "New password",
|
|
318
|
+
newPasswordPlaceholder: "Enter a new password",
|
|
319
|
+
confirmPasswordLabel: "Confirm new password",
|
|
320
|
+
confirmPasswordPlaceholder: "Re-enter your new password",
|
|
321
|
+
submit: "Change password",
|
|
322
|
+
submitting: "Changing password...",
|
|
323
|
+
submitHint: "Submit the form to change your password",
|
|
324
|
+
success: "Your password has been changed.",
|
|
325
|
+
errorWeakNewPassword: "Your new password must be at least 8 characters and include an uppercase letter, a lowercase letter and a number.",
|
|
326
|
+
errorMismatch: "The new password and its confirmation do not match.",
|
|
327
|
+
errorCurrentRequired: "Enter your current password.",
|
|
328
|
+
errorInvalidCurrent: "Your current password is incorrect, or the new password does not meet the policy.",
|
|
329
|
+
errorUnauthorized: "Your session has expired. Sign in again to change your password.",
|
|
330
|
+
errorFailed: "Could not change your password. Try again later."
|
|
331
|
+
};
|
|
332
|
+
|
|
306
333
|
// src/components/testIds.ts
|
|
307
334
|
var AuthTestIds = {
|
|
308
335
|
loginForm: "auth-login-form",
|
|
@@ -376,6 +403,15 @@ var AuthTestIds = {
|
|
|
376
403
|
preferredMethodSettingsError: "auth-preferred-method-settings-error",
|
|
377
404
|
// Preferred-method login-screen hint
|
|
378
405
|
preferredMethodHint: "auth-preferred-method-hint",
|
|
406
|
+
// Account-settings screen shell + in-app change-password form
|
|
407
|
+
accountSettings: "auth-account-settings",
|
|
408
|
+
accountSettingsChangePassword: "auth-account-settings-change-password",
|
|
409
|
+
changePasswordCurrentInput: "auth-change-password-current",
|
|
410
|
+
changePasswordNewInput: "auth-change-password-new",
|
|
411
|
+
changePasswordConfirmInput: "auth-change-password-confirm",
|
|
412
|
+
changePasswordSubmit: "auth-change-password-submit",
|
|
413
|
+
changePasswordError: "auth-change-password-error",
|
|
414
|
+
changePasswordSuccess: "auth-change-password-success",
|
|
379
415
|
// Public-demo credentials panel
|
|
380
416
|
demoCredentialsHint: "auth-demo-credentials-hint",
|
|
381
417
|
demoCredentialsUsername: "auth-demo-credentials-username",
|
|
@@ -390,15 +426,21 @@ function withTestIdPrefix(baseId, prefix) {
|
|
|
390
426
|
var FULL_WIDTH2 = "100%";
|
|
391
427
|
var CARD_MAX_WIDTH = 420;
|
|
392
428
|
var BUTTON_VERTICAL_PADDING = 14;
|
|
429
|
+
var SCREEN_TOP_OFFSET = 64;
|
|
393
430
|
function useAuthStyles(theme) {
|
|
394
431
|
return useMemo(() => {
|
|
395
432
|
const { colors, radii, spacing, typography } = theme;
|
|
396
433
|
return StyleSheet.create({
|
|
397
434
|
screen: {
|
|
398
435
|
flex: 1,
|
|
399
|
-
|
|
436
|
+
// Top-anchored, NOT centred — a centred card re-centres as it grows and
|
|
437
|
+
// drags the inputs up under the cursor. Same reasoning (and the same
|
|
438
|
+
// measurement) as `useAuthScreenStyles`' CARD_TOP_OFFSET; kept in step so
|
|
439
|
+
// a standalone `<LoginForm>` and an `<AuthScreen>`-composed one agree.
|
|
440
|
+
justifyContent: "flex-start",
|
|
400
441
|
alignItems: "center",
|
|
401
442
|
padding: spacing.md,
|
|
443
|
+
paddingTop: SCREEN_TOP_OFFSET,
|
|
402
444
|
backgroundColor: colors.background
|
|
403
445
|
},
|
|
404
446
|
card: {
|
|
@@ -2012,14 +2054,15 @@ function DevicePinLengthPicker({
|
|
|
2012
2054
|
const theme = useAuthTheme(themeProp);
|
|
2013
2055
|
const dynamic = usePickerStyles(theme);
|
|
2014
2056
|
const baseId = withTestIdPrefix(AuthTestIds.devicePinEnrollLength, testIdPrefix);
|
|
2015
|
-
return /* @__PURE__ */ jsx(View, { style: styles2.row, children: DEVICE_PIN_ALLOWED_DIGITS.map((option) => {
|
|
2057
|
+
return /* @__PURE__ */ jsx(View, { accessibilityRole: "radiogroup", role: "radiogroup", style: styles2.row, children: DEVICE_PIN_ALLOWED_DIGITS.map((option) => {
|
|
2016
2058
|
const active = option === selected;
|
|
2017
2059
|
return /* @__PURE__ */ jsx(
|
|
2018
2060
|
Pressable,
|
|
2019
2061
|
{
|
|
2062
|
+
"aria-checked": active,
|
|
2020
2063
|
accessibilityHint: interpolate(optionHint, { count: option }),
|
|
2021
2064
|
accessibilityLabel: String(option),
|
|
2022
|
-
accessibilityRole: "
|
|
2065
|
+
accessibilityRole: "radio",
|
|
2023
2066
|
accessibilityState: { selected: active },
|
|
2024
2067
|
disabled,
|
|
2025
2068
|
style: [styles2.pill, dynamic.pill, active ? dynamic.active : null],
|
|
@@ -3163,6 +3206,7 @@ function PreferredMethodSettingsCard({
|
|
|
3163
3206
|
return /* @__PURE__ */ jsx(
|
|
3164
3207
|
TouchableOpacity,
|
|
3165
3208
|
{
|
|
3209
|
+
"aria-checked": isSelected,
|
|
3166
3210
|
accessibilityHint: labels.description,
|
|
3167
3211
|
accessibilityLabel: option.label,
|
|
3168
3212
|
accessibilityRole: "radio",
|
|
@@ -3189,6 +3233,307 @@ function PreferredMethodSettingsCard({
|
|
|
3189
3233
|
}
|
|
3190
3234
|
);
|
|
3191
3235
|
}
|
|
3236
|
+
|
|
3237
|
+
// src/password/ChangePasswordErrorKey.ts
|
|
3238
|
+
var ChangePasswordErrorKey = /* @__PURE__ */ ((ChangePasswordErrorKey2) => {
|
|
3239
|
+
ChangePasswordErrorKey2["WeakNewPassword"] = "weak_new_password";
|
|
3240
|
+
ChangePasswordErrorKey2["Mismatch"] = "mismatch";
|
|
3241
|
+
ChangePasswordErrorKey2["CurrentRequired"] = "current_required";
|
|
3242
|
+
ChangePasswordErrorKey2["InvalidCurrent"] = "invalid_current";
|
|
3243
|
+
ChangePasswordErrorKey2["Unauthorized"] = "unauthorized";
|
|
3244
|
+
ChangePasswordErrorKey2["Failed"] = "failed";
|
|
3245
|
+
return ChangePasswordErrorKey2;
|
|
3246
|
+
})(ChangePasswordErrorKey || {});
|
|
3247
|
+
function errorKeyForStatus(status) {
|
|
3248
|
+
if (status === "invalidCurrent") {
|
|
3249
|
+
return "invalid_current" /* InvalidCurrent */;
|
|
3250
|
+
}
|
|
3251
|
+
if (status === "unauthorized") {
|
|
3252
|
+
return "unauthorized" /* Unauthorized */;
|
|
3253
|
+
}
|
|
3254
|
+
return "failed" /* Failed */;
|
|
3255
|
+
}
|
|
3256
|
+
function useChangePassword({
|
|
3257
|
+
client,
|
|
3258
|
+
onChanged
|
|
3259
|
+
}) {
|
|
3260
|
+
const [currentPassword, setCurrentValue] = useState("");
|
|
3261
|
+
const [newPassword, setNewValue] = useState("");
|
|
3262
|
+
const [confirmPassword, setConfirmValue] = useState("");
|
|
3263
|
+
const [submitting, setSubmitting] = useState(false);
|
|
3264
|
+
const [succeeded, setSucceeded] = useState(false);
|
|
3265
|
+
const [errorKey, setErrorKey] = useState(null);
|
|
3266
|
+
const clearStatus = useCallback(() => {
|
|
3267
|
+
setErrorKey(null);
|
|
3268
|
+
setSucceeded(false);
|
|
3269
|
+
}, []);
|
|
3270
|
+
const setCurrentPassword = useCallback((value) => {
|
|
3271
|
+
setCurrentValue(value);
|
|
3272
|
+
clearStatus();
|
|
3273
|
+
}, [clearStatus]);
|
|
3274
|
+
const setNewPassword = useCallback((value) => {
|
|
3275
|
+
setNewValue(value);
|
|
3276
|
+
clearStatus();
|
|
3277
|
+
}, [clearStatus]);
|
|
3278
|
+
const setConfirmPassword = useCallback((value) => {
|
|
3279
|
+
setConfirmValue(value);
|
|
3280
|
+
clearStatus();
|
|
3281
|
+
}, [clearStatus]);
|
|
3282
|
+
const reset = useCallback(() => {
|
|
3283
|
+
setCurrentValue("");
|
|
3284
|
+
setNewValue("");
|
|
3285
|
+
setConfirmValue("");
|
|
3286
|
+
setSubmitting(false);
|
|
3287
|
+
setSucceeded(false);
|
|
3288
|
+
setErrorKey(null);
|
|
3289
|
+
}, []);
|
|
3290
|
+
const submit = useCallback(() => {
|
|
3291
|
+
if (currentPassword === "") {
|
|
3292
|
+
setErrorKey("current_required" /* CurrentRequired */);
|
|
3293
|
+
return;
|
|
3294
|
+
}
|
|
3295
|
+
if (newPassword !== confirmPassword) {
|
|
3296
|
+
setErrorKey("mismatch" /* Mismatch */);
|
|
3297
|
+
return;
|
|
3298
|
+
}
|
|
3299
|
+
if (!isPasswordValid(newPassword)) {
|
|
3300
|
+
setErrorKey("weak_new_password" /* WeakNewPassword */);
|
|
3301
|
+
return;
|
|
3302
|
+
}
|
|
3303
|
+
setErrorKey(null);
|
|
3304
|
+
setSucceeded(false);
|
|
3305
|
+
setSubmitting(true);
|
|
3306
|
+
client.changePassword({ currentPassword, newPassword }).then((result) => {
|
|
3307
|
+
if (result.status === "success") {
|
|
3308
|
+
setCurrentValue("");
|
|
3309
|
+
setNewValue("");
|
|
3310
|
+
setConfirmValue("");
|
|
3311
|
+
setSucceeded(true);
|
|
3312
|
+
onChanged?.();
|
|
3313
|
+
return;
|
|
3314
|
+
}
|
|
3315
|
+
setErrorKey(errorKeyForStatus(result.status));
|
|
3316
|
+
}).catch(() => {
|
|
3317
|
+
setErrorKey("failed" /* Failed */);
|
|
3318
|
+
}).finally(() => {
|
|
3319
|
+
setSubmitting(false);
|
|
3320
|
+
});
|
|
3321
|
+
}, [client, currentPassword, newPassword, confirmPassword, onChanged]);
|
|
3322
|
+
return {
|
|
3323
|
+
currentPassword,
|
|
3324
|
+
newPassword,
|
|
3325
|
+
confirmPassword,
|
|
3326
|
+
setCurrentPassword,
|
|
3327
|
+
setNewPassword,
|
|
3328
|
+
setConfirmPassword,
|
|
3329
|
+
submitting,
|
|
3330
|
+
succeeded,
|
|
3331
|
+
errorKey,
|
|
3332
|
+
submit,
|
|
3333
|
+
reset
|
|
3334
|
+
};
|
|
3335
|
+
}
|
|
3336
|
+
function errorMessage2(errorKey, labels) {
|
|
3337
|
+
switch (errorKey) {
|
|
3338
|
+
case "weak_new_password" /* WeakNewPassword */:
|
|
3339
|
+
return labels.errorWeakNewPassword;
|
|
3340
|
+
case "mismatch" /* Mismatch */:
|
|
3341
|
+
return labels.errorMismatch;
|
|
3342
|
+
case "current_required" /* CurrentRequired */:
|
|
3343
|
+
return labels.errorCurrentRequired;
|
|
3344
|
+
case "invalid_current" /* InvalidCurrent */:
|
|
3345
|
+
return labels.errorInvalidCurrent;
|
|
3346
|
+
case "unauthorized" /* Unauthorized */:
|
|
3347
|
+
return labels.errorUnauthorized;
|
|
3348
|
+
case "failed" /* Failed */:
|
|
3349
|
+
return labels.errorFailed;
|
|
3350
|
+
default:
|
|
3351
|
+
return null;
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3354
|
+
function ChangePasswordCard({
|
|
3355
|
+
client,
|
|
3356
|
+
theme: themeProp,
|
|
3357
|
+
labels: labelsProp,
|
|
3358
|
+
testIdPrefix,
|
|
3359
|
+
onChanged
|
|
3360
|
+
}) {
|
|
3361
|
+
const theme = useAuthTheme(themeProp);
|
|
3362
|
+
const styles3 = useAuthStyles(theme);
|
|
3363
|
+
const labels = useMemo(
|
|
3364
|
+
() => ({ ...DEFAULT_ACCOUNT_SETTINGS_LABELS, ...labelsProp }),
|
|
3365
|
+
[labelsProp]
|
|
3366
|
+
);
|
|
3367
|
+
const form = useChangePassword({ client, onChanged });
|
|
3368
|
+
const message = errorMessage2(form.errorKey, labels);
|
|
3369
|
+
return /* @__PURE__ */ jsxs(
|
|
3370
|
+
View,
|
|
3371
|
+
{
|
|
3372
|
+
style: styles3.card,
|
|
3373
|
+
testID: withTestIdPrefix(AuthTestIds.accountSettingsChangePassword, testIdPrefix),
|
|
3374
|
+
children: [
|
|
3375
|
+
/* @__PURE__ */ jsx(Text, { style: styles3.title, children: labels.changePasswordTitle }),
|
|
3376
|
+
/* @__PURE__ */ jsx(Text, { style: styles3.subtitle, children: labels.changePasswordDescription }),
|
|
3377
|
+
/* @__PURE__ */ jsxs(View, { style: styles3.fieldGroup, children: [
|
|
3378
|
+
/* @__PURE__ */ jsx(Text, { style: styles3.label, children: labels.currentPasswordLabel }),
|
|
3379
|
+
/* @__PURE__ */ jsx(
|
|
3380
|
+
TextInput,
|
|
3381
|
+
{
|
|
3382
|
+
accessibilityLabel: labels.currentPasswordLabel,
|
|
3383
|
+
autoComplete: "current-password",
|
|
3384
|
+
placeholder: labels.currentPasswordPlaceholder,
|
|
3385
|
+
placeholderTextColor: theme.colors.textSecondary,
|
|
3386
|
+
secureTextEntry: true,
|
|
3387
|
+
style: styles3.input,
|
|
3388
|
+
testID: withTestIdPrefix(AuthTestIds.changePasswordCurrentInput, testIdPrefix),
|
|
3389
|
+
value: form.currentPassword,
|
|
3390
|
+
onChangeText: form.setCurrentPassword
|
|
3391
|
+
}
|
|
3392
|
+
)
|
|
3393
|
+
] }),
|
|
3394
|
+
/* @__PURE__ */ jsxs(View, { style: styles3.fieldGroup, children: [
|
|
3395
|
+
/* @__PURE__ */ jsx(Text, { style: styles3.label, children: labels.newPasswordLabel }),
|
|
3396
|
+
/* @__PURE__ */ jsx(
|
|
3397
|
+
TextInput,
|
|
3398
|
+
{
|
|
3399
|
+
accessibilityLabel: labels.newPasswordLabel,
|
|
3400
|
+
autoComplete: "new-password",
|
|
3401
|
+
placeholder: labels.newPasswordPlaceholder,
|
|
3402
|
+
placeholderTextColor: theme.colors.textSecondary,
|
|
3403
|
+
secureTextEntry: true,
|
|
3404
|
+
style: styles3.input,
|
|
3405
|
+
testID: withTestIdPrefix(AuthTestIds.changePasswordNewInput, testIdPrefix),
|
|
3406
|
+
value: form.newPassword,
|
|
3407
|
+
onChangeText: form.setNewPassword
|
|
3408
|
+
}
|
|
3409
|
+
)
|
|
3410
|
+
] }),
|
|
3411
|
+
/* @__PURE__ */ jsxs(View, { style: styles3.fieldGroup, children: [
|
|
3412
|
+
/* @__PURE__ */ jsx(Text, { style: styles3.label, children: labels.confirmPasswordLabel }),
|
|
3413
|
+
/* @__PURE__ */ jsx(
|
|
3414
|
+
TextInput,
|
|
3415
|
+
{
|
|
3416
|
+
accessibilityLabel: labels.confirmPasswordLabel,
|
|
3417
|
+
autoComplete: "new-password",
|
|
3418
|
+
placeholder: labels.confirmPasswordPlaceholder,
|
|
3419
|
+
placeholderTextColor: theme.colors.textSecondary,
|
|
3420
|
+
secureTextEntry: true,
|
|
3421
|
+
style: styles3.input,
|
|
3422
|
+
testID: withTestIdPrefix(AuthTestIds.changePasswordConfirmInput, testIdPrefix),
|
|
3423
|
+
value: form.confirmPassword,
|
|
3424
|
+
onChangeText: form.setConfirmPassword
|
|
3425
|
+
}
|
|
3426
|
+
)
|
|
3427
|
+
] }),
|
|
3428
|
+
message !== null ? /* @__PURE__ */ jsx(
|
|
3429
|
+
Text,
|
|
3430
|
+
{
|
|
3431
|
+
style: styles3.errorText,
|
|
3432
|
+
testID: withTestIdPrefix(AuthTestIds.changePasswordError, testIdPrefix),
|
|
3433
|
+
children: message
|
|
3434
|
+
}
|
|
3435
|
+
) : null,
|
|
3436
|
+
form.succeeded ? /* @__PURE__ */ jsx(
|
|
3437
|
+
Text,
|
|
3438
|
+
{
|
|
3439
|
+
style: styles3.successText,
|
|
3440
|
+
testID: withTestIdPrefix(AuthTestIds.changePasswordSuccess, testIdPrefix),
|
|
3441
|
+
children: labels.success
|
|
3442
|
+
}
|
|
3443
|
+
) : null,
|
|
3444
|
+
/* @__PURE__ */ jsx(
|
|
3445
|
+
TouchableOpacity,
|
|
3446
|
+
{
|
|
3447
|
+
accessibilityHint: labels.submitHint,
|
|
3448
|
+
accessibilityLabel: form.submitting ? labels.submitting : labels.submit,
|
|
3449
|
+
accessibilityRole: "button",
|
|
3450
|
+
disabled: form.submitting,
|
|
3451
|
+
style: form.submitting ? [styles3.primaryButton, styles3.primaryButtonDisabled] : styles3.primaryButton,
|
|
3452
|
+
testID: withTestIdPrefix(AuthTestIds.changePasswordSubmit, testIdPrefix),
|
|
3453
|
+
onPress: form.submit,
|
|
3454
|
+
children: form.submitting ? /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.colors.onPrimary, size: "small" }) : /* @__PURE__ */ jsx(Text, { style: styles3.primaryButtonText, children: labels.submit })
|
|
3455
|
+
}
|
|
3456
|
+
)
|
|
3457
|
+
]
|
|
3458
|
+
}
|
|
3459
|
+
);
|
|
3460
|
+
}
|
|
3461
|
+
var GAP = 16;
|
|
3462
|
+
var layout = StyleSheet.create({
|
|
3463
|
+
content: {
|
|
3464
|
+
width: "100%",
|
|
3465
|
+
alignItems: "center",
|
|
3466
|
+
rowGap: GAP
|
|
3467
|
+
}
|
|
3468
|
+
});
|
|
3469
|
+
function AccountSettingsScreen({
|
|
3470
|
+
changePassword,
|
|
3471
|
+
devicePin,
|
|
3472
|
+
passkeys,
|
|
3473
|
+
preferredMethod,
|
|
3474
|
+
theme: themeProp,
|
|
3475
|
+
labels: labelsProp,
|
|
3476
|
+
testIdPrefix
|
|
3477
|
+
}) {
|
|
3478
|
+
const theme = useAuthTheme(themeProp);
|
|
3479
|
+
const styles3 = useAuthStyles(theme);
|
|
3480
|
+
const labels = useMemo(
|
|
3481
|
+
() => ({ ...DEFAULT_ACCOUNT_SETTINGS_LABELS, ...labelsProp }),
|
|
3482
|
+
[labelsProp]
|
|
3483
|
+
);
|
|
3484
|
+
return /* @__PURE__ */ jsx(
|
|
3485
|
+
ScrollView,
|
|
3486
|
+
{
|
|
3487
|
+
contentContainerStyle: styles3.screen,
|
|
3488
|
+
testID: withTestIdPrefix(AuthTestIds.accountSettings, testIdPrefix),
|
|
3489
|
+
children: /* @__PURE__ */ jsxs(View, { style: layout.content, children: [
|
|
3490
|
+
/* @__PURE__ */ jsx(Text, { style: styles3.title, children: labels.heading }),
|
|
3491
|
+
/* @__PURE__ */ jsx(
|
|
3492
|
+
ChangePasswordCard,
|
|
3493
|
+
{
|
|
3494
|
+
client: changePassword.client,
|
|
3495
|
+
labels: labelsProp,
|
|
3496
|
+
testIdPrefix,
|
|
3497
|
+
theme,
|
|
3498
|
+
onChanged: changePassword.onChanged
|
|
3499
|
+
}
|
|
3500
|
+
),
|
|
3501
|
+
devicePin !== void 0 ? /* @__PURE__ */ jsx(
|
|
3502
|
+
DevicePinSettingsCard,
|
|
3503
|
+
{
|
|
3504
|
+
client: devicePin.client,
|
|
3505
|
+
enrollLabels: devicePin.enrollLabels,
|
|
3506
|
+
initialHasPin: devicePin.initialHasPin,
|
|
3507
|
+
labels: devicePin.labels,
|
|
3508
|
+
testIdPrefix,
|
|
3509
|
+
theme,
|
|
3510
|
+
onChanged: devicePin.onChanged
|
|
3511
|
+
}
|
|
3512
|
+
) : null,
|
|
3513
|
+
passkeys !== void 0 ? /* @__PURE__ */ jsx(
|
|
3514
|
+
PasskeySettingsCard,
|
|
3515
|
+
{
|
|
3516
|
+
labels: passkeys.labels,
|
|
3517
|
+
returnUrl: passkeys.returnUrl,
|
|
3518
|
+
testIdPrefix,
|
|
3519
|
+
theme
|
|
3520
|
+
}
|
|
3521
|
+
) : null,
|
|
3522
|
+
preferredMethod !== void 0 ? /* @__PURE__ */ jsx(
|
|
3523
|
+
PreferredMethodSettingsCard,
|
|
3524
|
+
{
|
|
3525
|
+
availableMethods: preferredMethod.availableMethods,
|
|
3526
|
+
client: preferredMethod.client,
|
|
3527
|
+
labels: preferredMethod.labels,
|
|
3528
|
+
testIdPrefix,
|
|
3529
|
+
theme,
|
|
3530
|
+
onChanged: preferredMethod.onChanged
|
|
3531
|
+
}
|
|
3532
|
+
) : null
|
|
3533
|
+
] })
|
|
3534
|
+
}
|
|
3535
|
+
);
|
|
3536
|
+
}
|
|
3192
3537
|
function hintFor(method, labels) {
|
|
3193
3538
|
if (method === "password") {
|
|
3194
3539
|
return labels.password;
|
|
@@ -3449,6 +3794,7 @@ function DemoCredentialsHint({
|
|
|
3449
3794
|
/* @__PURE__ */ jsx(
|
|
3450
3795
|
TouchableOpacity,
|
|
3451
3796
|
{
|
|
3797
|
+
"aria-expanded": expanded,
|
|
3452
3798
|
accessibilityHint: labels.toggleHint,
|
|
3453
3799
|
accessibilityLabel: labels.toggle,
|
|
3454
3800
|
accessibilityRole: "button",
|
|
@@ -3704,7 +4050,57 @@ async function performBffLogout(options) {
|
|
|
3704
4050
|
}
|
|
3705
4051
|
runGuarded(onRedirect, onError);
|
|
3706
4052
|
}
|
|
4053
|
+
var CHANGE_PASSWORD_ENDPOINT = "/bff/account/change-password";
|
|
4054
|
+
var CSRF_HEADER2 = "X-BFF-Csrf";
|
|
4055
|
+
var CSRF_HEADER_VALUE2 = "1";
|
|
4056
|
+
var JSON_CONTENT_TYPE2 = "application/json";
|
|
4057
|
+
var HTTP_NO_CONTENT = 204;
|
|
4058
|
+
var HTTP_OK = 200;
|
|
4059
|
+
var HTTP_BAD_REQUEST2 = 400;
|
|
4060
|
+
var HTTP_UNAUTHORIZED = 401;
|
|
4061
|
+
async function lazyFetchHttpClient2(request) {
|
|
4062
|
+
const fetchImpl = typeof fetch === "function" ? fetch.bind(globalThis) : void 0;
|
|
4063
|
+
if (fetchImpl === void 0) {
|
|
4064
|
+
throw new Error("createBffChangePasswordClient: fetch is not available in this environment");
|
|
4065
|
+
}
|
|
4066
|
+
return createFetchHttpClient(fetchImpl)(request);
|
|
4067
|
+
}
|
|
4068
|
+
function resultFromStatus(status) {
|
|
4069
|
+
if (status === HTTP_NO_CONTENT || status === HTTP_OK) {
|
|
4070
|
+
return { status: "success" };
|
|
4071
|
+
}
|
|
4072
|
+
if (status === HTTP_BAD_REQUEST2) {
|
|
4073
|
+
return { status: "invalidCurrent" };
|
|
4074
|
+
}
|
|
4075
|
+
if (status === HTTP_UNAUTHORIZED) {
|
|
4076
|
+
return { status: "unauthorized" };
|
|
4077
|
+
}
|
|
4078
|
+
return { status: "error" };
|
|
4079
|
+
}
|
|
4080
|
+
function createBffChangePasswordClient(options = {}) {
|
|
4081
|
+
const http = options.http ?? lazyFetchHttpClient2;
|
|
4082
|
+
const baseUrl = options.baseUrl ?? "";
|
|
4083
|
+
const url = `${baseUrl}${CHANGE_PASSWORD_ENDPOINT}`;
|
|
4084
|
+
return {
|
|
4085
|
+
changePassword: async (request) => {
|
|
4086
|
+
try {
|
|
4087
|
+
const response = await http({
|
|
4088
|
+
url,
|
|
4089
|
+
method: "POST",
|
|
4090
|
+
headers: { "Content-Type": JSON_CONTENT_TYPE2, [CSRF_HEADER2]: CSRF_HEADER_VALUE2 },
|
|
4091
|
+
body: JSON.stringify({
|
|
4092
|
+
currentPassword: request.currentPassword,
|
|
4093
|
+
newPassword: request.newPassword
|
|
4094
|
+
})
|
|
4095
|
+
});
|
|
4096
|
+
return resultFromStatus(response.status);
|
|
4097
|
+
} catch {
|
|
4098
|
+
return { status: "error" };
|
|
4099
|
+
}
|
|
4100
|
+
}
|
|
4101
|
+
};
|
|
4102
|
+
}
|
|
3707
4103
|
|
|
3708
|
-
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 };
|
|
4104
|
+
export { AccountSettingsScreen, AuthScreen, AuthTestIds, AuthThemeProvider, BffAuthStatus, CHANGE_PASSWORD_ENDPOINT, ChangePasswordCard, ChangePasswordErrorKey, DEFAULT_ACCOUNT_SETTINGS_LABELS, 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, createBffChangePasswordClient, createPreferencesClient, defaultAuthTheme, isAllowedPinDigits, isPasswordValid, isValidForgotPasswordEmail, performBffLogout, readCachedPreferredMethod, readPasskeyError, readPasskeyRegistered, resolveAccessibleRoutes, resolveDemoCredentials, resolvePostLoginRoute, startPasskeyLogin, startPasskeyRegistration, syncPreferredMethodFromServer, useAuthTheme, useBffAuth, useBffForgotPassword, useBffLoginConfig, useBffResetPassword, useChangePassword, useDemoCredentials, useDevicePinDisable, useDevicePinEnroll, useDevicePinUnlock, useForgotPasswordSubmit, useOtpLogin, usePasskeyCeremony, usePinLogin, usePreferredMethodSetting, useResetPasswordForm, validatePasswordPolicy, withTestIdPrefix };
|
|
3709
4105
|
//# sourceMappingURL=index.mjs.map
|
|
3710
4106
|
//# sourceMappingURL=index.mjs.map
|