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