@dloizides/auth-web 1.23.0 → 1.25.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 +15 -0
- package/dist/index.d.mts +159 -10
- package/dist/index.d.ts +159 -10
- package/dist/index.js +566 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +555 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -397,6 +397,45 @@ var DEFAULT_VERIFY_EMAIL_LABELS = {
|
|
|
397
397
|
signIn: DEFAULT_VERIFY_SIGN_IN_LABELS
|
|
398
398
|
};
|
|
399
399
|
|
|
400
|
+
// src/components/labels/accountDeletionLabels.ts
|
|
401
|
+
var DEFAULT_ACCOUNT_DELETION_LABELS = {
|
|
402
|
+
title: "Delete your account",
|
|
403
|
+
subtitle: "We email you a link to confirm. Nothing is deleted until you open it.",
|
|
404
|
+
reason: {
|
|
405
|
+
label: "Reason (optional)",
|
|
406
|
+
placeholder: "Why are you leaving?",
|
|
407
|
+
hint: "Optional reason for deleting your account",
|
|
408
|
+
inputLabel: "Reason for deleting your account"
|
|
409
|
+
},
|
|
410
|
+
submit: "Request account deletion",
|
|
411
|
+
submitHint: "Emails you a link to confirm the deletion",
|
|
412
|
+
submitting: "Sending the request",
|
|
413
|
+
stepUpTitle: "Confirm your password",
|
|
414
|
+
stepUpSubtitle: "You signed in a while ago. Enter your password to continue.",
|
|
415
|
+
password: {
|
|
416
|
+
label: "Password",
|
|
417
|
+
placeholder: "Your password",
|
|
418
|
+
hint: "Your current password",
|
|
419
|
+
inputLabel: "Password"
|
|
420
|
+
},
|
|
421
|
+
stepUpSubmit: "Confirm and continue",
|
|
422
|
+
stepUpSubmitHint: "Checks your password, then sends the deletion request",
|
|
423
|
+
checkEmailTitle: "Check your email",
|
|
424
|
+
checkEmailBody: "Open the link we sent you to confirm. Your account stays active until then.",
|
|
425
|
+
emailNotSentTitle: "We could not send the email",
|
|
426
|
+
emailNotSentBody: "Your request is recorded, but the confirmation email did not go out. Contact support to finish it.",
|
|
427
|
+
scheduledDate: "Scheduled deletion date: {date}",
|
|
428
|
+
alreadyRequestedTitle: "Deletion already requested",
|
|
429
|
+
alreadyRequestedBody: "Look for the confirmation link in your email. You do not need to ask again.",
|
|
430
|
+
errorPasswordRequired: "Enter your password.",
|
|
431
|
+
errorWrongPassword: "That password is not correct.",
|
|
432
|
+
errorSignInRequired: "Your session ended. Sign in and try again.",
|
|
433
|
+
errorRateLimited: "Too many attempts. Wait a moment and try again.",
|
|
434
|
+
errorRateLimitedSeconds: "Too many attempts. Try again in {seconds} seconds.",
|
|
435
|
+
errorRetryLater: "We could not reach the account service. Try again later.",
|
|
436
|
+
errorFailed: "Something went wrong. Try again."
|
|
437
|
+
};
|
|
438
|
+
|
|
400
439
|
// src/components/testIds.ts
|
|
401
440
|
var AuthTestIds = {
|
|
402
441
|
loginForm: "auth-login-form",
|
|
@@ -679,7 +718,7 @@ function useLoginSubmit({
|
|
|
679
718
|
missingFieldsLabel,
|
|
680
719
|
invalidCredentialsLabel
|
|
681
720
|
}) {
|
|
682
|
-
const [
|
|
721
|
+
const [errorText2, setErrorText] = useState(null);
|
|
683
722
|
const inFlight = useRef(false);
|
|
684
723
|
const runLogin = useCallback(async () => {
|
|
685
724
|
if (inFlight.current) {
|
|
@@ -705,7 +744,7 @@ function useLoginSubmit({
|
|
|
705
744
|
const handleSubmit = useCallback(() => {
|
|
706
745
|
void runLogin();
|
|
707
746
|
}, [runLogin]);
|
|
708
|
-
return { errorText, handleSubmit };
|
|
747
|
+
return { errorText: errorText2, handleSubmit };
|
|
709
748
|
}
|
|
710
749
|
function isKeyRepeat(event) {
|
|
711
750
|
const native = event?.nativeEvent;
|
|
@@ -865,7 +904,7 @@ function LoginForm({
|
|
|
865
904
|
prefillNonce,
|
|
866
905
|
prefillIntent
|
|
867
906
|
});
|
|
868
|
-
const { errorText, handleSubmit } = useLoginSubmit({
|
|
907
|
+
const { errorText: errorText2, handleSubmit } = useLoginSubmit({
|
|
869
908
|
username,
|
|
870
909
|
password,
|
|
871
910
|
login,
|
|
@@ -921,12 +960,12 @@ function LoginForm({
|
|
|
921
960
|
}
|
|
922
961
|
)
|
|
923
962
|
] }),
|
|
924
|
-
|
|
963
|
+
errorText2 !== null ? /* @__PURE__ */ jsx(
|
|
925
964
|
Text,
|
|
926
965
|
{
|
|
927
966
|
style: styles3.errorText,
|
|
928
967
|
testID: withTestIdPrefix(AuthTestIds.loginError, testIdPrefix),
|
|
929
|
-
children:
|
|
968
|
+
children: errorText2
|
|
930
969
|
}
|
|
931
970
|
) : null,
|
|
932
971
|
onForgotPassword !== void 0 ? /* @__PURE__ */ jsx(
|
|
@@ -1018,7 +1057,7 @@ function ForgotPasswordForm({
|
|
|
1018
1057
|
);
|
|
1019
1058
|
const [email, setEmail] = useState("");
|
|
1020
1059
|
const [submitted, setSubmitted] = useState(false);
|
|
1021
|
-
const [
|
|
1060
|
+
const [errorText2, setErrorText] = useState(null);
|
|
1022
1061
|
const mutationOptions = useMemo(
|
|
1023
1062
|
() => ({
|
|
1024
1063
|
client,
|
|
@@ -1080,12 +1119,12 @@ function ForgotPasswordForm({
|
|
|
1080
1119
|
}
|
|
1081
1120
|
)
|
|
1082
1121
|
] }),
|
|
1083
|
-
|
|
1122
|
+
errorText2 !== null ? /* @__PURE__ */ jsx(
|
|
1084
1123
|
Text,
|
|
1085
1124
|
{
|
|
1086
1125
|
style: styles3.errorText,
|
|
1087
1126
|
testID: withTestIdPrefix(AuthTestIds.forgotPasswordError, testIdPrefix),
|
|
1088
|
-
children:
|
|
1127
|
+
children: errorText2
|
|
1089
1128
|
}
|
|
1090
1129
|
) : null,
|
|
1091
1130
|
/* @__PURE__ */ jsx(
|
|
@@ -1573,7 +1612,7 @@ function OtpRequestStep({
|
|
|
1573
1612
|
labels,
|
|
1574
1613
|
testIdPrefix,
|
|
1575
1614
|
isSubmitting,
|
|
1576
|
-
errorText,
|
|
1615
|
+
errorText: errorText2,
|
|
1577
1616
|
onSubmit
|
|
1578
1617
|
}) {
|
|
1579
1618
|
const [email, setEmail] = useState("");
|
|
@@ -1601,7 +1640,7 @@ function OtpRequestStep({
|
|
|
1601
1640
|
}
|
|
1602
1641
|
)
|
|
1603
1642
|
] }),
|
|
1604
|
-
|
|
1643
|
+
errorText2 !== null ? /* @__PURE__ */ jsx(Text, { style: styles3.errorText, testID: withTestIdPrefix(AuthTestIds.otpError, testIdPrefix), children: errorText2 }) : null,
|
|
1605
1644
|
/* @__PURE__ */ jsx(
|
|
1606
1645
|
TouchableOpacity,
|
|
1607
1646
|
{
|
|
@@ -1624,7 +1663,7 @@ function OtpVerifyStep({
|
|
|
1624
1663
|
testIdPrefix,
|
|
1625
1664
|
identifier,
|
|
1626
1665
|
isSubmitting,
|
|
1627
|
-
errorText,
|
|
1666
|
+
errorText: errorText2,
|
|
1628
1667
|
onSubmit,
|
|
1629
1668
|
onResend,
|
|
1630
1669
|
onChangeEmail
|
|
@@ -1655,7 +1694,7 @@ function OtpVerifyStep({
|
|
|
1655
1694
|
}
|
|
1656
1695
|
)
|
|
1657
1696
|
] }),
|
|
1658
|
-
|
|
1697
|
+
errorText2 !== null ? /* @__PURE__ */ jsx(Text, { style: styles3.errorText, testID: withTestIdPrefix(AuthTestIds.otpError, testIdPrefix), children: errorText2 }) : null,
|
|
1659
1698
|
/* @__PURE__ */ jsx(
|
|
1660
1699
|
TouchableOpacity,
|
|
1661
1700
|
{
|
|
@@ -1878,11 +1917,11 @@ function OtpForm({
|
|
|
1878
1917
|
setLocalError(null);
|
|
1879
1918
|
otp.reset();
|
|
1880
1919
|
}, [otp]);
|
|
1881
|
-
const
|
|
1920
|
+
const errorText2 = localError ?? transportErrorFor(otp.step, otp.error, labels);
|
|
1882
1921
|
const content = otp.step === "requestCode" /* RequestCode */ ? /* @__PURE__ */ jsx(
|
|
1883
1922
|
OtpRequestStep,
|
|
1884
1923
|
{
|
|
1885
|
-
errorText,
|
|
1924
|
+
errorText: errorText2,
|
|
1886
1925
|
isSubmitting: otp.isSubmitting,
|
|
1887
1926
|
labels,
|
|
1888
1927
|
styles: styles3,
|
|
@@ -1893,7 +1932,7 @@ function OtpForm({
|
|
|
1893
1932
|
) : /* @__PURE__ */ jsx(
|
|
1894
1933
|
OtpVerifyStep,
|
|
1895
1934
|
{
|
|
1896
|
-
errorText,
|
|
1935
|
+
errorText: errorText2,
|
|
1897
1936
|
identifier: otp.identifier,
|
|
1898
1937
|
isSubmitting: otp.isSubmitting,
|
|
1899
1938
|
labels,
|
|
@@ -2005,7 +2044,7 @@ function PinForm({
|
|
|
2005
2044
|
const [localError, setLocalError] = useState(null);
|
|
2006
2045
|
const [pinValue, setPinValue] = useState("");
|
|
2007
2046
|
const handleSubmit = useSubmitHandler(pin, labels, setLocalError, onSuccess);
|
|
2008
|
-
const
|
|
2047
|
+
const errorText2 = localError ?? transportErrorFor2(pin.error, labels);
|
|
2009
2048
|
const buttonStyle = pin.isSubmitting ? [styles3.primaryButton, styles3.primaryButtonDisabled] : styles3.primaryButton;
|
|
2010
2049
|
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2011
2050
|
/* @__PURE__ */ jsx(Text, { style: styles3.title, children: labels.title }),
|
|
@@ -2031,12 +2070,12 @@ function PinForm({
|
|
|
2031
2070
|
}
|
|
2032
2071
|
)
|
|
2033
2072
|
] }),
|
|
2034
|
-
|
|
2073
|
+
errorText2 !== null ? /* @__PURE__ */ jsx(
|
|
2035
2074
|
Text,
|
|
2036
2075
|
{
|
|
2037
2076
|
style: styles3.errorText,
|
|
2038
2077
|
testID: withTestIdPrefix(AuthTestIds.pinError, testIdPrefix),
|
|
2039
|
-
children:
|
|
2078
|
+
children: errorText2
|
|
2040
2079
|
}
|
|
2041
2080
|
) : null,
|
|
2042
2081
|
/* @__PURE__ */ jsx(
|
|
@@ -2262,7 +2301,7 @@ function useDevicePinUnlock({
|
|
|
2262
2301
|
const [pin, setPinState] = useState("");
|
|
2263
2302
|
const [submitting, setSubmitting] = useState(false);
|
|
2264
2303
|
const [errorKey, setErrorKey] = useState(null);
|
|
2265
|
-
const [
|
|
2304
|
+
const [retryAfterSeconds2, setRetryAfterSeconds] = useState(null);
|
|
2266
2305
|
const setPin = useCallback((next) => {
|
|
2267
2306
|
setPinState(next);
|
|
2268
2307
|
setErrorKey(null);
|
|
@@ -2302,7 +2341,7 @@ function useDevicePinUnlock({
|
|
|
2302
2341
|
setSubmitting(false);
|
|
2303
2342
|
});
|
|
2304
2343
|
}, [client, pin, digits, onSignedIn]);
|
|
2305
|
-
return { pin, submitting, errorKey, retryAfterSeconds, setPin, submit };
|
|
2344
|
+
return { pin, submitting, errorKey, retryAfterSeconds: retryAfterSeconds2, setPin, submit };
|
|
2306
2345
|
}
|
|
2307
2346
|
function resolveErrorText(errorKey, digits, retryAfter, labels) {
|
|
2308
2347
|
if (errorKey === null) {
|
|
@@ -2338,14 +2377,14 @@ function DevicePinUnlockScreen({
|
|
|
2338
2377
|
() => ({ ...DEFAULT_DEVICE_PIN_UNLOCK_LABELS, ...labelsProp }),
|
|
2339
2378
|
[labelsProp]
|
|
2340
2379
|
);
|
|
2341
|
-
const { pin, submitting, errorKey, retryAfterSeconds, setPin, submit } = useDevicePinUnlock({
|
|
2380
|
+
const { pin, submitting, errorKey, retryAfterSeconds: retryAfterSeconds2, setPin, submit } = useDevicePinUnlock({
|
|
2342
2381
|
client,
|
|
2343
2382
|
digits,
|
|
2344
2383
|
onSignedIn
|
|
2345
2384
|
});
|
|
2346
2385
|
const hasName = rememberedUsername !== "";
|
|
2347
2386
|
const title = hasName ? interpolate(labels.title, { name: rememberedUsername }) : labels.titleNoName;
|
|
2348
|
-
const error = resolveErrorText(errorKey, digits,
|
|
2387
|
+
const error = resolveErrorText(errorKey, digits, retryAfterSeconds2, labels);
|
|
2349
2388
|
const buttonStyle = submitting ? [styles3.primaryButton, styles3.primaryButtonDisabled] : styles3.primaryButton;
|
|
2350
2389
|
return /* @__PURE__ */ jsx(View, { style: styles3.screen, children: /* @__PURE__ */ jsxs(
|
|
2351
2390
|
View,
|
|
@@ -4238,10 +4277,12 @@ function RegisterFormFields({
|
|
|
4238
4277
|
onChange,
|
|
4239
4278
|
onSubmitEditing,
|
|
4240
4279
|
testIdPrefix,
|
|
4241
|
-
compact = false
|
|
4280
|
+
compact = false,
|
|
4281
|
+
hideTenantName = false
|
|
4242
4282
|
}) {
|
|
4283
|
+
const fields = compact ? COMPACT_FIELDS : FIELDS;
|
|
4243
4284
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4244
|
-
(
|
|
4285
|
+
fields.filter((config) => !(hideTenantName && config.key === "tenantName")).map((config) => {
|
|
4245
4286
|
const copy = copyFor(config.key, labels, compact);
|
|
4246
4287
|
return /* @__PURE__ */ jsxs(View, { style: styles3.fieldGroup, children: [
|
|
4247
4288
|
/* @__PURE__ */ jsx(Text, { style: styles3.label, children: copy.label }),
|
|
@@ -4305,13 +4346,13 @@ var RegisterErrorCode = /* @__PURE__ */ ((RegisterErrorCode2) => {
|
|
|
4305
4346
|
})(RegisterErrorCode || {});
|
|
4306
4347
|
|
|
4307
4348
|
// src/hooks/routeRegisterOutcome.ts
|
|
4308
|
-
function routeRegisterOutcome(
|
|
4309
|
-
if (
|
|
4310
|
-
handlers.onSuccess(
|
|
4349
|
+
function routeRegisterOutcome(outcome2, handlers) {
|
|
4350
|
+
if (outcome2.ok) {
|
|
4351
|
+
handlers.onSuccess(outcome2.result);
|
|
4311
4352
|
return;
|
|
4312
4353
|
}
|
|
4313
|
-
if (
|
|
4314
|
-
handlers.onError?.(
|
|
4354
|
+
if (outcome2.error !== "inFlight" /* InFlight */) {
|
|
4355
|
+
handlers.onError?.(outcome2.error);
|
|
4315
4356
|
}
|
|
4316
4357
|
}
|
|
4317
4358
|
|
|
@@ -4371,19 +4412,19 @@ function trimRegisterValues(values) {
|
|
|
4371
4412
|
website: values.website.trim()
|
|
4372
4413
|
};
|
|
4373
4414
|
}
|
|
4374
|
-
function hasMissingRequiredField(values) {
|
|
4415
|
+
function hasMissingRequiredField(values, tenantNameHidden) {
|
|
4375
4416
|
const required = [
|
|
4376
4417
|
values.firstName,
|
|
4377
4418
|
values.lastName,
|
|
4378
4419
|
values.username,
|
|
4379
4420
|
values.email,
|
|
4380
4421
|
values.password,
|
|
4381
|
-
values.tenantName
|
|
4422
|
+
...tenantNameHidden ? [] : [values.tenantName]
|
|
4382
4423
|
];
|
|
4383
4424
|
return required.some((value) => value === "");
|
|
4384
4425
|
}
|
|
4385
|
-
function validateRegisterValues(values, passwordPolicy) {
|
|
4386
|
-
if (hasMissingRequiredField(values)) {
|
|
4426
|
+
function validateRegisterValues(values, passwordPolicy, tenantNameHidden = false) {
|
|
4427
|
+
if (hasMissingRequiredField(values, tenantNameHidden)) {
|
|
4387
4428
|
return "missingFields" /* MissingFields */;
|
|
4388
4429
|
}
|
|
4389
4430
|
if (!isEmailShaped(values.email)) {
|
|
@@ -4452,6 +4493,24 @@ function mapRegisterErrorCode(error) {
|
|
|
4452
4493
|
return match === void 0 ? "validationFailed" /* ValidationFailed */ : match[1];
|
|
4453
4494
|
}
|
|
4454
4495
|
|
|
4496
|
+
// src/hooks/newIdempotencyKey.ts
|
|
4497
|
+
var HEX_RADIX = 16;
|
|
4498
|
+
var HEX_BYTE_LENGTH = 2;
|
|
4499
|
+
var KEY_BYTES = 16;
|
|
4500
|
+
var fallbackSequence = 0;
|
|
4501
|
+
function newIdempotencyKey() {
|
|
4502
|
+
const cryptoApi = globalThis.crypto;
|
|
4503
|
+
if (typeof cryptoApi?.randomUUID === "function") {
|
|
4504
|
+
return cryptoApi.randomUUID();
|
|
4505
|
+
}
|
|
4506
|
+
if (typeof cryptoApi?.getRandomValues === "function") {
|
|
4507
|
+
const bytes = cryptoApi.getRandomValues(new Uint8Array(KEY_BYTES));
|
|
4508
|
+
return Array.from(bytes, (byte) => byte.toString(HEX_RADIX).padStart(HEX_BYTE_LENGTH, "0")).join("");
|
|
4509
|
+
}
|
|
4510
|
+
fallbackSequence += 1;
|
|
4511
|
+
return `${Date.now().toString(HEX_RADIX)}-${String(fallbackSequence)}`;
|
|
4512
|
+
}
|
|
4513
|
+
|
|
4455
4514
|
// src/hooks/registerCompact.ts
|
|
4456
4515
|
var WHITESPACE_RUN = /\s+/;
|
|
4457
4516
|
var UNSAFE_USERNAME_CHARS = /[^a-z0-9._-]/g;
|
|
@@ -4474,26 +4533,26 @@ function expandCompactRegisterValues(values) {
|
|
|
4474
4533
|
confirmPassword: values.password
|
|
4475
4534
|
};
|
|
4476
4535
|
}
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4536
|
+
function createOpaqueTenantName() {
|
|
4537
|
+
return `workspace-${newIdempotencyKey()}`;
|
|
4538
|
+
}
|
|
4539
|
+
function useDerivedTenantName(derive) {
|
|
4540
|
+
const deriveRef = useRef(derive);
|
|
4541
|
+
deriveRef.current = derive;
|
|
4542
|
+
const name = useRef(null);
|
|
4543
|
+
return useMemo(
|
|
4544
|
+
() => ({
|
|
4545
|
+
current: () => {
|
|
4546
|
+
name.current ?? (name.current = deriveRef.current?.() ?? "");
|
|
4547
|
+
return name.current;
|
|
4548
|
+
},
|
|
4549
|
+
reset: () => {
|
|
4550
|
+
name.current = null;
|
|
4551
|
+
}
|
|
4552
|
+
}),
|
|
4553
|
+
[]
|
|
4554
|
+
);
|
|
4494
4555
|
}
|
|
4495
|
-
|
|
4496
|
-
// src/hooks/useRegisterSubmitMeta.ts
|
|
4497
4556
|
function useRegisterSubmitMeta() {
|
|
4498
4557
|
const openedAt = useRef(Date.now());
|
|
4499
4558
|
const key = useRef(null);
|
|
@@ -4541,17 +4600,21 @@ function useRegisterForm({
|
|
|
4541
4600
|
passwordPolicy = isRegisterPasswordStrong,
|
|
4542
4601
|
onSubmitAttempt,
|
|
4543
4602
|
compact = false,
|
|
4544
|
-
sharedRegistration = false
|
|
4603
|
+
sharedRegistration = false,
|
|
4604
|
+
deriveTenantName
|
|
4545
4605
|
}) {
|
|
4546
4606
|
const [state, setState] = useState(EMPTY_VALUES);
|
|
4547
4607
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
4548
4608
|
const [error, setError] = useState(null);
|
|
4549
4609
|
const inFlight = useRef(false);
|
|
4550
4610
|
const submitMeta = useRegisterSubmitMeta();
|
|
4611
|
+
const derivedName = useDerivedTenantName(deriveTenantName);
|
|
4612
|
+
const tenantNameHidden = deriveTenantName !== void 0;
|
|
4551
4613
|
const setField = useCallback((field2, value) => {
|
|
4552
4614
|
submitMeta.resetKey();
|
|
4615
|
+
derivedName.reset();
|
|
4553
4616
|
setState((prev) => ({ ...prev, [field2]: value }));
|
|
4554
|
-
}, [submitMeta]);
|
|
4617
|
+
}, [derivedName, submitMeta]);
|
|
4555
4618
|
const submit = useCallback(async () => {
|
|
4556
4619
|
if (inFlight.current) {
|
|
4557
4620
|
return { ok: false, error: "inFlight" /* InFlight */ };
|
|
@@ -4559,7 +4622,7 @@ function useRegisterForm({
|
|
|
4559
4622
|
onSubmitAttempt?.();
|
|
4560
4623
|
const trimmedRaw = trimRegisterValues(state);
|
|
4561
4624
|
const trimmed = compact ? expandCompactRegisterValues(trimmedRaw) : trimmedRaw;
|
|
4562
|
-
const refusal = trimmed.website === "" ? validateRegisterValues(trimmed, passwordPolicy) : "failed" /* Failed */;
|
|
4625
|
+
const refusal = trimmed.website === "" ? validateRegisterValues(trimmed, passwordPolicy, tenantNameHidden) : "failed" /* Failed */;
|
|
4563
4626
|
if (refusal !== null) {
|
|
4564
4627
|
setError(refusal);
|
|
4565
4628
|
return { ok: false, error: refusal };
|
|
@@ -4568,7 +4631,7 @@ function useRegisterForm({
|
|
|
4568
4631
|
setError(null);
|
|
4569
4632
|
setIsSubmitting(true);
|
|
4570
4633
|
try {
|
|
4571
|
-
const values = toSubmitValues(trimmed);
|
|
4634
|
+
const values = toSubmitValues(tenantNameHidden ? { ...trimmed, tenantName: derivedName.current() } : trimmed);
|
|
4572
4635
|
const result = await (sharedRegistration ? onSubmit(values, submitMeta.next()) : onSubmit(values));
|
|
4573
4636
|
if (sharedRegistration && isRegisterAccepted(result)) {
|
|
4574
4637
|
setState(withoutPasswords);
|
|
@@ -4577,12 +4640,16 @@ function useRegisterForm({
|
|
|
4577
4640
|
} catch (caught) {
|
|
4578
4641
|
const code = mapRegisterErrorCode(caught);
|
|
4579
4642
|
setError(code);
|
|
4643
|
+
if (tenantNameHidden && code === "tenantNameTaken" /* TenantNameTaken */) {
|
|
4644
|
+
derivedName.reset();
|
|
4645
|
+
submitMeta.resetKey();
|
|
4646
|
+
}
|
|
4580
4647
|
return { ok: false, error: code };
|
|
4581
4648
|
} finally {
|
|
4582
4649
|
inFlight.current = false;
|
|
4583
4650
|
setIsSubmitting(false);
|
|
4584
4651
|
}
|
|
4585
|
-
}, [compact, onSubmit, onSubmitAttempt, passwordPolicy, sharedRegistration, state, submitMeta]);
|
|
4652
|
+
}, [compact, derivedName, onSubmit, onSubmitAttempt, passwordPolicy, sharedRegistration, state, submitMeta, tenantNameHidden]);
|
|
4586
4653
|
return { state, setField, submit, isSubmitting, error };
|
|
4587
4654
|
}
|
|
4588
4655
|
function RegisterFormCore({
|
|
@@ -4596,6 +4663,7 @@ function RegisterFormCore({
|
|
|
4596
4663
|
footer,
|
|
4597
4664
|
testIdPrefix,
|
|
4598
4665
|
compact = false,
|
|
4666
|
+
deriveTenantName,
|
|
4599
4667
|
sharedRegistration
|
|
4600
4668
|
}) {
|
|
4601
4669
|
const theme = useAuthTheme(themeProp);
|
|
@@ -4609,7 +4677,8 @@ function RegisterFormCore({
|
|
|
4609
4677
|
onSubmitAttempt,
|
|
4610
4678
|
passwordPolicy,
|
|
4611
4679
|
compact,
|
|
4612
|
-
sharedRegistration
|
|
4680
|
+
sharedRegistration,
|
|
4681
|
+
deriveTenantName
|
|
4613
4682
|
});
|
|
4614
4683
|
const handlePress = useCallback(async () => {
|
|
4615
4684
|
routeRegisterOutcome(await submit(), { onSuccess, onError });
|
|
@@ -4623,6 +4692,7 @@ function RegisterFormCore({
|
|
|
4623
4692
|
{
|
|
4624
4693
|
compact,
|
|
4625
4694
|
disabled: isSubmitting,
|
|
4695
|
+
hideTenantName: deriveTenantName !== void 0,
|
|
4626
4696
|
labels,
|
|
4627
4697
|
styles: styles3,
|
|
4628
4698
|
testIdPrefix,
|
|
@@ -5441,6 +5511,432 @@ function SharedRegisterForm({
|
|
|
5441
5511
|
return /* @__PURE__ */ jsx(RegisterFormCore, { ...formProps, sharedRegistration: true, onSuccess: handleResult });
|
|
5442
5512
|
}
|
|
5443
5513
|
|
|
5444
|
-
|
|
5514
|
+
// src/account/AccountDeletionStatus.ts
|
|
5515
|
+
var AccountDeletionStatus = /* @__PURE__ */ ((AccountDeletionStatus2) => {
|
|
5516
|
+
AccountDeletionStatus2["Accepted"] = "accepted";
|
|
5517
|
+
AccountDeletionStatus2["StepUpRequired"] = "stepUpRequired";
|
|
5518
|
+
AccountDeletionStatus2["AlreadyRequested"] = "alreadyRequested";
|
|
5519
|
+
AccountDeletionStatus2["SignInRequired"] = "signInRequired";
|
|
5520
|
+
AccountDeletionStatus2["RateLimited"] = "rateLimited";
|
|
5521
|
+
AccountDeletionStatus2["RetryLater"] = "retryLater";
|
|
5522
|
+
AccountDeletionStatus2["Failed"] = "failed";
|
|
5523
|
+
return AccountDeletionStatus2;
|
|
5524
|
+
})(AccountDeletionStatus || {});
|
|
5525
|
+
|
|
5526
|
+
// src/account/StepUpStatus.ts
|
|
5527
|
+
var StepUpStatus = /* @__PURE__ */ ((StepUpStatus2) => {
|
|
5528
|
+
StepUpStatus2["Confirmed"] = "confirmed";
|
|
5529
|
+
StepUpStatus2["WrongPassword"] = "wrongPassword";
|
|
5530
|
+
StepUpStatus2["RateLimited"] = "rateLimited";
|
|
5531
|
+
StepUpStatus2["Failed"] = "failed";
|
|
5532
|
+
return StepUpStatus2;
|
|
5533
|
+
})(StepUpStatus || {});
|
|
5534
|
+
|
|
5535
|
+
// src/account/accountDeletionClient.ts
|
|
5536
|
+
var ACCOUNT_DELETE_REQUEST_ENDPOINT = "/bff/account/delete-request";
|
|
5537
|
+
var STEP_UP_PASSWORD_ENDPOINT = "/bff/step-up/password";
|
|
5538
|
+
var RECENT_AUTHENTICATION_REQUIRED = "RECENT_AUTHENTICATION_REQUIRED";
|
|
5539
|
+
var HTTP_ACCEPTED2 = 202;
|
|
5540
|
+
var HTTP_UNAUTHORIZED3 = 401;
|
|
5541
|
+
var HTTP_FORBIDDEN = 403;
|
|
5542
|
+
var HTTP_CONFLICT = 409;
|
|
5543
|
+
var HTTP_TOO_MANY_REQUESTS3 = 429;
|
|
5544
|
+
var HTTP_BAD_GATEWAY = 502;
|
|
5545
|
+
var DELTA_SECONDS = /^\d+$/;
|
|
5546
|
+
function retryAfterSeconds(response) {
|
|
5547
|
+
const raw = response.header?.("Retry-After")?.trim();
|
|
5548
|
+
return raw !== void 0 && DELTA_SECONDS.test(raw) ? Number(raw) : null;
|
|
5549
|
+
}
|
|
5550
|
+
function decodeReceipt(data) {
|
|
5551
|
+
const body = isRecord3(data) ? data : {};
|
|
5552
|
+
return {
|
|
5553
|
+
requestId: typeof body.requestId === "string" ? body.requestId : "",
|
|
5554
|
+
scheduledDeletionDate: typeof body.scheduledDeletionDate === "string" ? body.scheduledDeletionDate : "",
|
|
5555
|
+
confirmationEmailSent: body.confirmationEmailSent === true
|
|
5556
|
+
};
|
|
5557
|
+
}
|
|
5558
|
+
function isStaleLogin(data) {
|
|
5559
|
+
return isRecord3(data) && data.code === RECENT_AUTHENTICATION_REQUIRED;
|
|
5560
|
+
}
|
|
5561
|
+
function decodeDeletion(response) {
|
|
5562
|
+
switch (response.status) {
|
|
5563
|
+
case HTTP_ACCEPTED2:
|
|
5564
|
+
return { status: "accepted" /* Accepted */, receipt: decodeReceipt(response.data) };
|
|
5565
|
+
case HTTP_FORBIDDEN:
|
|
5566
|
+
return { status: isStaleLogin(response.data) ? "stepUpRequired" /* StepUpRequired */ : "failed" /* Failed */ };
|
|
5567
|
+
case HTTP_CONFLICT:
|
|
5568
|
+
return { status: "alreadyRequested" /* AlreadyRequested */ };
|
|
5569
|
+
case HTTP_UNAUTHORIZED3:
|
|
5570
|
+
return { status: "signInRequired" /* SignInRequired */ };
|
|
5571
|
+
case HTTP_TOO_MANY_REQUESTS3:
|
|
5572
|
+
return { status: "rateLimited" /* RateLimited */, retryAfterSeconds: retryAfterSeconds(response) };
|
|
5573
|
+
case HTTP_BAD_GATEWAY:
|
|
5574
|
+
return { status: "retryLater" /* RetryLater */ };
|
|
5575
|
+
default:
|
|
5576
|
+
return { status: "failed" /* Failed */ };
|
|
5577
|
+
}
|
|
5578
|
+
}
|
|
5579
|
+
function decodeStepUp(response) {
|
|
5580
|
+
if (response.ok) {
|
|
5581
|
+
return { status: "confirmed" /* Confirmed */ };
|
|
5582
|
+
}
|
|
5583
|
+
if (response.status === HTTP_UNAUTHORIZED3) {
|
|
5584
|
+
return { status: "wrongPassword" /* WrongPassword */ };
|
|
5585
|
+
}
|
|
5586
|
+
if (response.status === HTTP_TOO_MANY_REQUESTS3) {
|
|
5587
|
+
return { status: "rateLimited" /* RateLimited */, retryAfterSeconds: retryAfterSeconds(response) };
|
|
5588
|
+
}
|
|
5589
|
+
return { status: "failed" /* Failed */ };
|
|
5590
|
+
}
|
|
5591
|
+
function createBffAccountDeletionClient(options = {}) {
|
|
5592
|
+
const http = options.http ?? lazyFetchHttpClient3;
|
|
5593
|
+
const baseUrl = options.baseUrl ?? "";
|
|
5594
|
+
const post = (path, body) => http({
|
|
5595
|
+
url: `${baseUrl}${path}`,
|
|
5596
|
+
method: "POST",
|
|
5597
|
+
headers: { "Content-Type": "application/json", "X-BFF-Csrf": "1" },
|
|
5598
|
+
body: JSON.stringify(body),
|
|
5599
|
+
credentials: "include"
|
|
5600
|
+
});
|
|
5601
|
+
return {
|
|
5602
|
+
requestDeletion: async (reason) => {
|
|
5603
|
+
try {
|
|
5604
|
+
return decodeDeletion(await post(ACCOUNT_DELETE_REQUEST_ENDPOINT, reason === void 0 ? {} : { reason }));
|
|
5605
|
+
} catch {
|
|
5606
|
+
return { status: "failed" /* Failed */ };
|
|
5607
|
+
}
|
|
5608
|
+
},
|
|
5609
|
+
stepUpPassword: async (password) => {
|
|
5610
|
+
try {
|
|
5611
|
+
return decodeStepUp(await post(STEP_UP_PASSWORD_ENDPOINT, { password }));
|
|
5612
|
+
} catch {
|
|
5613
|
+
return { status: "failed" /* Failed */ };
|
|
5614
|
+
}
|
|
5615
|
+
}
|
|
5616
|
+
};
|
|
5617
|
+
}
|
|
5618
|
+
|
|
5619
|
+
// src/account/AccountDeletionErrorKey.ts
|
|
5620
|
+
var AccountDeletionErrorKey = /* @__PURE__ */ ((AccountDeletionErrorKey2) => {
|
|
5621
|
+
AccountDeletionErrorKey2["PasswordRequired"] = "passwordRequired";
|
|
5622
|
+
AccountDeletionErrorKey2["WrongPassword"] = "wrongPassword";
|
|
5623
|
+
AccountDeletionErrorKey2["SignInRequired"] = "signInRequired";
|
|
5624
|
+
AccountDeletionErrorKey2["RateLimited"] = "rateLimited";
|
|
5625
|
+
AccountDeletionErrorKey2["RetryLater"] = "retryLater";
|
|
5626
|
+
AccountDeletionErrorKey2["Failed"] = "failed";
|
|
5627
|
+
return AccountDeletionErrorKey2;
|
|
5628
|
+
})(AccountDeletionErrorKey || {});
|
|
5629
|
+
|
|
5630
|
+
// src/account/AccountDeletionPhase.ts
|
|
5631
|
+
var AccountDeletionPhase = /* @__PURE__ */ ((AccountDeletionPhase2) => {
|
|
5632
|
+
AccountDeletionPhase2["Confirm"] = "confirm";
|
|
5633
|
+
AccountDeletionPhase2["StepUp"] = "stepUp";
|
|
5634
|
+
AccountDeletionPhase2["Accepted"] = "accepted";
|
|
5635
|
+
AccountDeletionPhase2["AlreadyRequested"] = "alreadyRequested";
|
|
5636
|
+
return AccountDeletionPhase2;
|
|
5637
|
+
})(AccountDeletionPhase || {});
|
|
5638
|
+
|
|
5639
|
+
// src/account/accountDeletionFlow.ts
|
|
5640
|
+
function outcome(phase, errorKey = null, retryAfterSeconds2 = null) {
|
|
5641
|
+
return { phase, errorKey, receipt: null, retryAfterSeconds: retryAfterSeconds2 };
|
|
5642
|
+
}
|
|
5643
|
+
function fromDeletion(result, steppedUp) {
|
|
5644
|
+
switch (result.status) {
|
|
5645
|
+
case "accepted" /* Accepted */:
|
|
5646
|
+
return { ...outcome("accepted" /* Accepted */), receipt: result.receipt };
|
|
5647
|
+
case "stepUpRequired" /* StepUpRequired */:
|
|
5648
|
+
return outcome("stepUp" /* StepUp */, steppedUp ? "failed" /* Failed */ : null);
|
|
5649
|
+
case "alreadyRequested" /* AlreadyRequested */:
|
|
5650
|
+
return outcome("alreadyRequested" /* AlreadyRequested */);
|
|
5651
|
+
case "signInRequired" /* SignInRequired */:
|
|
5652
|
+
return outcome("confirm" /* Confirm */, "signInRequired" /* SignInRequired */);
|
|
5653
|
+
case "rateLimited" /* RateLimited */:
|
|
5654
|
+
return outcome("confirm" /* Confirm */, "rateLimited" /* RateLimited */, result.retryAfterSeconds);
|
|
5655
|
+
case "retryLater" /* RetryLater */:
|
|
5656
|
+
return outcome("confirm" /* Confirm */, "retryLater" /* RetryLater */);
|
|
5657
|
+
default:
|
|
5658
|
+
return outcome("confirm" /* Confirm */, "failed" /* Failed */);
|
|
5659
|
+
}
|
|
5660
|
+
}
|
|
5661
|
+
function fromStepUpFailure(result) {
|
|
5662
|
+
if (result.status === "wrongPassword" /* WrongPassword */) {
|
|
5663
|
+
return outcome("stepUp" /* StepUp */, "wrongPassword" /* WrongPassword */);
|
|
5664
|
+
}
|
|
5665
|
+
if (result.status === "rateLimited" /* RateLimited */) {
|
|
5666
|
+
return outcome("stepUp" /* StepUp */, "rateLimited" /* RateLimited */, result.retryAfterSeconds);
|
|
5667
|
+
}
|
|
5668
|
+
return outcome("stepUp" /* StepUp */, "failed" /* Failed */);
|
|
5669
|
+
}
|
|
5670
|
+
async function runDeletionAttempt(client, { phase, reason, password }) {
|
|
5671
|
+
const trimmed = reason.trim();
|
|
5672
|
+
const sentReason = trimmed === "" ? void 0 : trimmed;
|
|
5673
|
+
if (phase !== "stepUp" /* StepUp */) {
|
|
5674
|
+
return fromDeletion(await client.requestDeletion(sentReason), false);
|
|
5675
|
+
}
|
|
5676
|
+
const stepUp = await client.stepUpPassword(password);
|
|
5677
|
+
if (stepUp.status !== "confirmed" /* Confirmed */) {
|
|
5678
|
+
return fromStepUpFailure(stepUp);
|
|
5679
|
+
}
|
|
5680
|
+
return fromDeletion(await client.requestDeletion(sentReason), true);
|
|
5681
|
+
}
|
|
5682
|
+
var MS_PER_SECOND = 1e3;
|
|
5683
|
+
function useRetryAfterBlock(onExpired) {
|
|
5684
|
+
const [retryAfterSeconds2, setRetryAfterSeconds] = useState(null);
|
|
5685
|
+
const timer = useRef(null);
|
|
5686
|
+
const stopTimer = useCallback(() => {
|
|
5687
|
+
if (timer.current !== null) {
|
|
5688
|
+
clearTimeout(timer.current);
|
|
5689
|
+
}
|
|
5690
|
+
timer.current = null;
|
|
5691
|
+
}, []);
|
|
5692
|
+
useEffect(() => stopTimer, [stopTimer]);
|
|
5693
|
+
const block = useCallback(
|
|
5694
|
+
(seconds) => {
|
|
5695
|
+
stopTimer();
|
|
5696
|
+
setRetryAfterSeconds(seconds);
|
|
5697
|
+
timer.current = setTimeout(() => {
|
|
5698
|
+
timer.current = null;
|
|
5699
|
+
setRetryAfterSeconds(null);
|
|
5700
|
+
onExpired();
|
|
5701
|
+
}, seconds * MS_PER_SECOND);
|
|
5702
|
+
},
|
|
5703
|
+
[onExpired, stopTimer]
|
|
5704
|
+
);
|
|
5705
|
+
return { retryAfterSeconds: retryAfterSeconds2, block };
|
|
5706
|
+
}
|
|
5707
|
+
|
|
5708
|
+
// src/account/useAccountDeletion.ts
|
|
5709
|
+
function useAccountDeletion(args) {
|
|
5710
|
+
const { client, onAccepted, onSignInRequired } = args;
|
|
5711
|
+
const [reason, setReason] = useState("");
|
|
5712
|
+
const [password, setPasswordValue] = useState("");
|
|
5713
|
+
const [phase, setPhase] = useState("confirm" /* Confirm */);
|
|
5714
|
+
const [submitting, setSubmitting] = useState(false);
|
|
5715
|
+
const [errorKey, setErrorKey] = useState(null);
|
|
5716
|
+
const [receipt, setReceipt] = useState(null);
|
|
5717
|
+
const inFlight = useRef(false);
|
|
5718
|
+
const clearRateLimit = useCallback(() => {
|
|
5719
|
+
setErrorKey((current) => current === "rateLimited" /* RateLimited */ ? null : current);
|
|
5720
|
+
}, []);
|
|
5721
|
+
const { retryAfterSeconds: retryAfterSeconds2, block } = useRetryAfterBlock(clearRateLimit);
|
|
5722
|
+
const blocked = retryAfterSeconds2 !== null;
|
|
5723
|
+
const setPassword = useCallback((value) => {
|
|
5724
|
+
setPasswordValue(value);
|
|
5725
|
+
setErrorKey((current) => current === "rateLimited" /* RateLimited */ ? current : null);
|
|
5726
|
+
}, []);
|
|
5727
|
+
const applyOutcome = useCallback((outcome2) => {
|
|
5728
|
+
setPhase(outcome2.phase);
|
|
5729
|
+
setErrorKey(outcome2.errorKey);
|
|
5730
|
+
setPasswordValue("");
|
|
5731
|
+
if (outcome2.retryAfterSeconds !== null) {
|
|
5732
|
+
block(outcome2.retryAfterSeconds);
|
|
5733
|
+
}
|
|
5734
|
+
if (outcome2.errorKey === "signInRequired" /* SignInRequired */) {
|
|
5735
|
+
onSignInRequired?.();
|
|
5736
|
+
}
|
|
5737
|
+
if (outcome2.receipt === null) {
|
|
5738
|
+
return;
|
|
5739
|
+
}
|
|
5740
|
+
setReceipt(outcome2.receipt);
|
|
5741
|
+
onAccepted?.(outcome2.receipt);
|
|
5742
|
+
}, [block, onAccepted, onSignInRequired]);
|
|
5743
|
+
const submit = useCallback(() => {
|
|
5744
|
+
if (inFlight.current || blocked) {
|
|
5745
|
+
return;
|
|
5746
|
+
}
|
|
5747
|
+
if (phase === "stepUp" /* StepUp */ && password === "") {
|
|
5748
|
+
setErrorKey("passwordRequired" /* PasswordRequired */);
|
|
5749
|
+
return;
|
|
5750
|
+
}
|
|
5751
|
+
inFlight.current = true;
|
|
5752
|
+
setSubmitting(true);
|
|
5753
|
+
setErrorKey(null);
|
|
5754
|
+
runDeletionAttempt(client, { phase, reason, password }).then(applyOutcome).catch(() => {
|
|
5755
|
+
setPasswordValue("");
|
|
5756
|
+
setErrorKey("failed" /* Failed */);
|
|
5757
|
+
}).finally(() => {
|
|
5758
|
+
inFlight.current = false;
|
|
5759
|
+
setSubmitting(false);
|
|
5760
|
+
});
|
|
5761
|
+
}, [applyOutcome, blocked, client, password, phase, reason]);
|
|
5762
|
+
return { phase, reason, password, setReason, setPassword, submitting, blocked, retryAfterSeconds: retryAfterSeconds2, errorKey, receipt, submit };
|
|
5763
|
+
}
|
|
5764
|
+
var REASON_MAX_LENGTH = 1e3;
|
|
5765
|
+
function AccountDeletionField({
|
|
5766
|
+
copy,
|
|
5767
|
+
placeholderColor,
|
|
5768
|
+
secure,
|
|
5769
|
+
disabled,
|
|
5770
|
+
value,
|
|
5771
|
+
styles: styles3,
|
|
5772
|
+
testID,
|
|
5773
|
+
onChangeText,
|
|
5774
|
+
onSubmitEditing
|
|
5775
|
+
}) {
|
|
5776
|
+
const inputRef = useRef(null);
|
|
5777
|
+
useFocusOnMount(inputRef);
|
|
5778
|
+
return /* @__PURE__ */ jsxs(View, { style: styles3.fieldGroup, children: [
|
|
5779
|
+
/* @__PURE__ */ jsx(Text, { style: styles3.label, children: copy.label }),
|
|
5780
|
+
/* @__PURE__ */ jsx(
|
|
5781
|
+
TextInput,
|
|
5782
|
+
{
|
|
5783
|
+
ref: inputRef,
|
|
5784
|
+
accessibilityHint: copy.hint,
|
|
5785
|
+
accessibilityLabel: copy.inputLabel,
|
|
5786
|
+
autoComplete: secure ? "current-password" : "off",
|
|
5787
|
+
editable: !disabled,
|
|
5788
|
+
maxLength: secure ? void 0 : REASON_MAX_LENGTH,
|
|
5789
|
+
placeholder: copy.placeholder,
|
|
5790
|
+
placeholderTextColor: placeholderColor,
|
|
5791
|
+
returnKeyType: "go",
|
|
5792
|
+
secureTextEntry: secure,
|
|
5793
|
+
style: styles3.input,
|
|
5794
|
+
testID,
|
|
5795
|
+
value,
|
|
5796
|
+
onChangeText,
|
|
5797
|
+
onSubmitEditing
|
|
5798
|
+
}
|
|
5799
|
+
)
|
|
5800
|
+
] });
|
|
5801
|
+
}
|
|
5802
|
+
function AccountDeletionNotice({
|
|
5803
|
+
title,
|
|
5804
|
+
body,
|
|
5805
|
+
detail,
|
|
5806
|
+
styles: styles3,
|
|
5807
|
+
testID,
|
|
5808
|
+
footer
|
|
5809
|
+
}) {
|
|
5810
|
+
const headingRef = useRef(null);
|
|
5811
|
+
useFocusOnMount(headingRef);
|
|
5812
|
+
return /* @__PURE__ */ jsx(View, { style: styles3.screen, children: /* @__PURE__ */ jsxs(View, { accessibilityLiveRegion: "polite", style: styles3.card, testID, children: [
|
|
5813
|
+
/* @__PURE__ */ jsx(View, { ref: headingRef, accessible: true, focusable: true, children: /* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: styles3.title, children: title }) }),
|
|
5814
|
+
/* @__PURE__ */ jsx(Text, { style: styles3.subtitle, children: body }),
|
|
5815
|
+
detail === null ? null : /* @__PURE__ */ jsx(Text, { style: styles3.helperText, children: detail }),
|
|
5816
|
+
footer
|
|
5817
|
+
] }) });
|
|
5818
|
+
}
|
|
5819
|
+
|
|
5820
|
+
// src/components/accountDeletionTestIds.ts
|
|
5821
|
+
var AccountDeletionTestIds = {
|
|
5822
|
+
form: "account-deletion-form",
|
|
5823
|
+
reasonInput: "account-deletion-reason-input",
|
|
5824
|
+
stepUpInput: "account-deletion-password-input",
|
|
5825
|
+
submitButton: "account-deletion-submit-button",
|
|
5826
|
+
error: "account-deletion-error",
|
|
5827
|
+
checkEmail: "account-deletion-check-email",
|
|
5828
|
+
emailNotSent: "account-deletion-email-not-sent",
|
|
5829
|
+
alreadyRequested: "account-deletion-already-requested"
|
|
5830
|
+
};
|
|
5831
|
+
function errorText(errorKey, seconds, labels) {
|
|
5832
|
+
switch (errorKey) {
|
|
5833
|
+
case null:
|
|
5834
|
+
return null;
|
|
5835
|
+
case "passwordRequired" /* PasswordRequired */:
|
|
5836
|
+
return labels.errorPasswordRequired;
|
|
5837
|
+
case "wrongPassword" /* WrongPassword */:
|
|
5838
|
+
return labels.errorWrongPassword;
|
|
5839
|
+
case "signInRequired" /* SignInRequired */:
|
|
5840
|
+
return labels.errorSignInRequired;
|
|
5841
|
+
case "rateLimited" /* RateLimited */:
|
|
5842
|
+
return seconds === null ? labels.errorRateLimited : interpolate(labels.errorRateLimitedSeconds, { seconds });
|
|
5843
|
+
case "retryLater" /* RetryLater */:
|
|
5844
|
+
return labels.errorRetryLater;
|
|
5845
|
+
default:
|
|
5846
|
+
return labels.errorFailed;
|
|
5847
|
+
}
|
|
5848
|
+
}
|
|
5849
|
+
function scheduledDetail(receipt, labels) {
|
|
5850
|
+
const date = new Date(receipt?.scheduledDeletionDate ?? "");
|
|
5851
|
+
return Number.isNaN(date.getTime()) ? null : interpolate(labels.scheduledDate, { date: date.toLocaleDateString() });
|
|
5852
|
+
}
|
|
5853
|
+
function noticeCopy(phase, receipt, labels) {
|
|
5854
|
+
if (phase === "alreadyRequested" /* AlreadyRequested */) {
|
|
5855
|
+
return {
|
|
5856
|
+
title: labels.alreadyRequestedTitle,
|
|
5857
|
+
body: labels.alreadyRequestedBody,
|
|
5858
|
+
detail: null,
|
|
5859
|
+
testId: AccountDeletionTestIds.alreadyRequested
|
|
5860
|
+
};
|
|
5861
|
+
}
|
|
5862
|
+
if (phase !== "accepted" /* Accepted */) {
|
|
5863
|
+
return null;
|
|
5864
|
+
}
|
|
5865
|
+
const detail = scheduledDetail(receipt, labels);
|
|
5866
|
+
if (receipt?.confirmationEmailSent === true) {
|
|
5867
|
+
return { title: labels.checkEmailTitle, body: labels.checkEmailBody, detail, testId: AccountDeletionTestIds.checkEmail };
|
|
5868
|
+
}
|
|
5869
|
+
return { title: labels.emailNotSentTitle, body: labels.emailNotSentBody, detail, testId: AccountDeletionTestIds.emailNotSent };
|
|
5870
|
+
}
|
|
5871
|
+
function AccountDeletionForm({
|
|
5872
|
+
client,
|
|
5873
|
+
labels: labelsProp,
|
|
5874
|
+
theme: themeProp,
|
|
5875
|
+
testIdPrefix,
|
|
5876
|
+
footer,
|
|
5877
|
+
onAccepted,
|
|
5878
|
+
onSignInRequired
|
|
5879
|
+
}) {
|
|
5880
|
+
const theme = useAuthTheme(themeProp);
|
|
5881
|
+
const styles3 = useAuthStyles(theme);
|
|
5882
|
+
const labels = useMemo(() => ({ ...DEFAULT_ACCOUNT_DELETION_LABELS, ...labelsProp }), [labelsProp]);
|
|
5883
|
+
const form = useAccountDeletion({ client, onAccepted, onSignInRequired });
|
|
5884
|
+
const handleSubmitEditing = useSubmitOnEnter(form.submit);
|
|
5885
|
+
const testId = (id) => withTestIdPrefix(id, testIdPrefix);
|
|
5886
|
+
const notice = noticeCopy(form.phase, form.receipt, labels);
|
|
5887
|
+
if (notice !== null) {
|
|
5888
|
+
return /* @__PURE__ */ jsx(
|
|
5889
|
+
AccountDeletionNotice,
|
|
5890
|
+
{
|
|
5891
|
+
body: notice.body,
|
|
5892
|
+
detail: notice.detail,
|
|
5893
|
+
footer,
|
|
5894
|
+
styles: styles3,
|
|
5895
|
+
testID: testId(notice.testId),
|
|
5896
|
+
title: notice.title
|
|
5897
|
+
}
|
|
5898
|
+
);
|
|
5899
|
+
}
|
|
5900
|
+
const steppingUp = form.phase === "stepUp" /* StepUp */;
|
|
5901
|
+
const message = errorText(form.errorKey, form.retryAfterSeconds, labels);
|
|
5902
|
+
const submitLabel = steppingUp ? labels.stepUpSubmit : labels.submit;
|
|
5903
|
+
return /* @__PURE__ */ jsx(View, { style: styles3.screen, children: /* @__PURE__ */ jsxs(View, { style: styles3.card, testID: testId(AccountDeletionTestIds.form), children: [
|
|
5904
|
+
/* @__PURE__ */ jsx(Text, { style: styles3.title, children: steppingUp ? labels.stepUpTitle : labels.title }),
|
|
5905
|
+
/* @__PURE__ */ jsx(Text, { style: styles3.subtitle, children: steppingUp ? labels.stepUpSubtitle : labels.subtitle }),
|
|
5906
|
+
/* @__PURE__ */ jsx(
|
|
5907
|
+
AccountDeletionField,
|
|
5908
|
+
{
|
|
5909
|
+
copy: steppingUp ? labels.password : labels.reason,
|
|
5910
|
+
disabled: form.submitting,
|
|
5911
|
+
placeholderColor: theme.colors.textSecondary,
|
|
5912
|
+
secure: steppingUp,
|
|
5913
|
+
styles: styles3,
|
|
5914
|
+
testID: testId(steppingUp ? AccountDeletionTestIds.stepUpInput : AccountDeletionTestIds.reasonInput),
|
|
5915
|
+
value: steppingUp ? form.password : form.reason,
|
|
5916
|
+
onChangeText: steppingUp ? form.setPassword : form.setReason,
|
|
5917
|
+
onSubmitEditing: handleSubmitEditing
|
|
5918
|
+
},
|
|
5919
|
+
form.phase
|
|
5920
|
+
),
|
|
5921
|
+
message === null ? null : /* @__PURE__ */ jsx(Text, { accessibilityLiveRegion: "polite", style: styles3.errorText, testID: testId(AccountDeletionTestIds.error), children: message }),
|
|
5922
|
+
/* @__PURE__ */ jsx(View, { style: styles3.fieldGroup, children: /* @__PURE__ */ jsx(
|
|
5923
|
+
Button,
|
|
5924
|
+
{
|
|
5925
|
+
fullWidth: true,
|
|
5926
|
+
accessibilityHint: steppingUp ? labels.stepUpSubmitHint : labels.submitHint,
|
|
5927
|
+
accessibilityLabel: form.submitting ? labels.submitting : submitLabel,
|
|
5928
|
+
disabled: form.blocked,
|
|
5929
|
+
label: submitLabel,
|
|
5930
|
+
loading: form.submitting,
|
|
5931
|
+
testID: testId(AccountDeletionTestIds.submitButton),
|
|
5932
|
+
variant: "danger",
|
|
5933
|
+
onPress: form.submit
|
|
5934
|
+
}
|
|
5935
|
+
) }),
|
|
5936
|
+
footer
|
|
5937
|
+
] }) });
|
|
5938
|
+
}
|
|
5939
|
+
|
|
5940
|
+
export { ACCOUNT_DELETE_REQUEST_ENDPOINT, AccountDeletionErrorKey, AccountDeletionForm, AccountDeletionPhase, AccountDeletionStatus, AccountDeletionTestIds, AccountSettingsScreen, AuthScreen, AuthTestIds, AuthThemeProvider, BffAuthStatus, CHANGE_PASSWORD_ENDPOINT, ChangePasswordCard, ChangePasswordErrorKey, DEFAULT_ACCOUNT_DELETION_LABELS, 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_REGISTER_LABELS, DEFAULT_RESET_PASSWORD_LABELS, DEFAULT_VERIFY_EMAIL_LABELS, DEFAULT_VERIFY_NEW_PASSWORD_LABELS, DEFAULT_VERIFY_SIGN_IN_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, REGISTER_ENDPOINT, RESEND_VERIFICATION_ENDPOINT, RegisterErrorCode, RegisterForm, RegisterTestIds, ResetPasswordError, ResetPasswordForm, STEP_UP_PASSWORD_ENDPOINT, SharedRegisterForm, StepUpStatus, VERIFY_AND_LOGIN_ENDPOINT, VERIFY_EMAIL_ENDPOINT, VERIFY_TOKEN_PLACEHOLDER, VerifyEmailErrorCode, VerifyEmailPhase, VerifyEmailScreen, buildVerifyUrlTemplate, cachePreferredMethod, clearCachedPreferredMethod, collectUserRoles, createBffAccountDeletionClient, createBffAuthClient, createBffChangePasswordClient, createBffVerifyEmailClient, createOpaqueTenantName, createPreferencesClient, createSharedRegistrationClient, defaultAuthTheme, deriveUsernameFromEmail, isAllowedPinDigits, isPasswordValid, isRegisterAccepted, isRegisterPasswordStrong, isValidForgotPasswordEmail, performBffLogout, readCachedPreferredMethod, readPasskeyError, readPasskeyRegistered, readVerifyToken, resolveAccessibleRoutes, resolveAccountList, resolveDemoAccounts, resolveDemoCredentials, resolvePostLoginRoute, splitFullName, startPasskeyLogin, startPasskeyRegistration, syncPreferredMethodFromServer, useAccountDeletion, useAuthTheme, useBffAuth, useBffForgotPassword, useBffLoginConfig, useBffResetPassword, useChangePassword, useDemoCredentials, useDevicePinDisable, useDevicePinEnroll, useDevicePinUnlock, useForgotPasswordSubmit, useOtpLogin, usePasskeyCeremony, usePinLogin, usePreferredMethodSetting, useRegisterForm, useResendVerification, useResetPasswordForm, useVerifyEmail, validatePasswordPolicy, verifyEmailErrorText, withTestIdPrefix };
|
|
5445
5941
|
//# sourceMappingURL=index.mjs.map
|
|
5446
5942
|
//# sourceMappingURL=index.mjs.map
|