@dloizides/auth-web 1.24.0 → 1.25.1
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 +13 -0
- package/dist/index.d.mts +8 -10
- package/dist/index.d.ts +8 -10
- package/dist/index.js +70 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4277,10 +4277,12 @@ function RegisterFormFields({
|
|
|
4277
4277
|
onChange,
|
|
4278
4278
|
onSubmitEditing,
|
|
4279
4279
|
testIdPrefix,
|
|
4280
|
-
compact = false
|
|
4280
|
+
compact = false,
|
|
4281
|
+
hideTenantName = false
|
|
4281
4282
|
}) {
|
|
4283
|
+
const fields = compact ? COMPACT_FIELDS : FIELDS;
|
|
4282
4284
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4283
|
-
(
|
|
4285
|
+
fields.filter((config) => !(hideTenantName && config.key === "tenantName")).map((config) => {
|
|
4284
4286
|
const copy = copyFor(config.key, labels, compact);
|
|
4285
4287
|
return /* @__PURE__ */ jsxs(View, { style: styles3.fieldGroup, children: [
|
|
4286
4288
|
/* @__PURE__ */ jsx(Text, { style: styles3.label, children: copy.label }),
|
|
@@ -4410,19 +4412,19 @@ function trimRegisterValues(values) {
|
|
|
4410
4412
|
website: values.website.trim()
|
|
4411
4413
|
};
|
|
4412
4414
|
}
|
|
4413
|
-
function hasMissingRequiredField(values) {
|
|
4415
|
+
function hasMissingRequiredField(values, tenantNameHidden) {
|
|
4414
4416
|
const required = [
|
|
4415
4417
|
values.firstName,
|
|
4416
4418
|
values.lastName,
|
|
4417
4419
|
values.username,
|
|
4418
4420
|
values.email,
|
|
4419
4421
|
values.password,
|
|
4420
|
-
values.tenantName
|
|
4422
|
+
...tenantNameHidden ? [] : [values.tenantName]
|
|
4421
4423
|
];
|
|
4422
4424
|
return required.some((value) => value === "");
|
|
4423
4425
|
}
|
|
4424
|
-
function validateRegisterValues(values, passwordPolicy) {
|
|
4425
|
-
if (hasMissingRequiredField(values)) {
|
|
4426
|
+
function validateRegisterValues(values, passwordPolicy, tenantNameHidden = false) {
|
|
4427
|
+
if (hasMissingRequiredField(values, tenantNameHidden)) {
|
|
4426
4428
|
return "missingFields" /* MissingFields */;
|
|
4427
4429
|
}
|
|
4428
4430
|
if (!isEmailShaped(values.email)) {
|
|
@@ -4491,6 +4493,24 @@ function mapRegisterErrorCode(error) {
|
|
|
4491
4493
|
return match === void 0 ? "validationFailed" /* ValidationFailed */ : match[1];
|
|
4492
4494
|
}
|
|
4493
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
|
+
|
|
4494
4514
|
// src/hooks/registerCompact.ts
|
|
4495
4515
|
var WHITESPACE_RUN = /\s+/;
|
|
4496
4516
|
var UNSAFE_USERNAME_CHARS = /[^a-z0-9._-]/g;
|
|
@@ -4513,26 +4533,26 @@ function expandCompactRegisterValues(values) {
|
|
|
4513
4533
|
confirmPassword: values.password
|
|
4514
4534
|
};
|
|
4515
4535
|
}
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
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
|
+
);
|
|
4533
4555
|
}
|
|
4534
|
-
|
|
4535
|
-
// src/hooks/useRegisterSubmitMeta.ts
|
|
4536
4556
|
function useRegisterSubmitMeta() {
|
|
4537
4557
|
const openedAt = useRef(Date.now());
|
|
4538
4558
|
const key = useRef(null);
|
|
@@ -4580,17 +4600,21 @@ function useRegisterForm({
|
|
|
4580
4600
|
passwordPolicy = isRegisterPasswordStrong,
|
|
4581
4601
|
onSubmitAttempt,
|
|
4582
4602
|
compact = false,
|
|
4583
|
-
sharedRegistration = false
|
|
4603
|
+
sharedRegistration = false,
|
|
4604
|
+
deriveTenantName
|
|
4584
4605
|
}) {
|
|
4585
4606
|
const [state, setState] = useState(EMPTY_VALUES);
|
|
4586
4607
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
4587
4608
|
const [error, setError] = useState(null);
|
|
4588
4609
|
const inFlight = useRef(false);
|
|
4589
4610
|
const submitMeta = useRegisterSubmitMeta();
|
|
4611
|
+
const derivedName = useDerivedTenantName(deriveTenantName);
|
|
4612
|
+
const tenantNameHidden = deriveTenantName !== void 0;
|
|
4590
4613
|
const setField = useCallback((field2, value) => {
|
|
4591
4614
|
submitMeta.resetKey();
|
|
4615
|
+
derivedName.reset();
|
|
4592
4616
|
setState((prev) => ({ ...prev, [field2]: value }));
|
|
4593
|
-
}, [submitMeta]);
|
|
4617
|
+
}, [derivedName, submitMeta]);
|
|
4594
4618
|
const submit = useCallback(async () => {
|
|
4595
4619
|
if (inFlight.current) {
|
|
4596
4620
|
return { ok: false, error: "inFlight" /* InFlight */ };
|
|
@@ -4598,7 +4622,7 @@ function useRegisterForm({
|
|
|
4598
4622
|
onSubmitAttempt?.();
|
|
4599
4623
|
const trimmedRaw = trimRegisterValues(state);
|
|
4600
4624
|
const trimmed = compact ? expandCompactRegisterValues(trimmedRaw) : trimmedRaw;
|
|
4601
|
-
const refusal = trimmed.website === "" ? validateRegisterValues(trimmed, passwordPolicy) : "failed" /* Failed */;
|
|
4625
|
+
const refusal = trimmed.website === "" ? validateRegisterValues(trimmed, passwordPolicy, tenantNameHidden) : "failed" /* Failed */;
|
|
4602
4626
|
if (refusal !== null) {
|
|
4603
4627
|
setError(refusal);
|
|
4604
4628
|
return { ok: false, error: refusal };
|
|
@@ -4607,7 +4631,7 @@ function useRegisterForm({
|
|
|
4607
4631
|
setError(null);
|
|
4608
4632
|
setIsSubmitting(true);
|
|
4609
4633
|
try {
|
|
4610
|
-
const values = toSubmitValues(trimmed);
|
|
4634
|
+
const values = toSubmitValues(tenantNameHidden ? { ...trimmed, tenantName: derivedName.current() } : trimmed);
|
|
4611
4635
|
const result = await (sharedRegistration ? onSubmit(values, submitMeta.next()) : onSubmit(values));
|
|
4612
4636
|
if (sharedRegistration && isRegisterAccepted(result)) {
|
|
4613
4637
|
setState(withoutPasswords);
|
|
@@ -4616,12 +4640,16 @@ function useRegisterForm({
|
|
|
4616
4640
|
} catch (caught) {
|
|
4617
4641
|
const code = mapRegisterErrorCode(caught);
|
|
4618
4642
|
setError(code);
|
|
4643
|
+
if (tenantNameHidden && code === "tenantNameTaken" /* TenantNameTaken */) {
|
|
4644
|
+
derivedName.reset();
|
|
4645
|
+
submitMeta.resetKey();
|
|
4646
|
+
}
|
|
4619
4647
|
return { ok: false, error: code };
|
|
4620
4648
|
} finally {
|
|
4621
4649
|
inFlight.current = false;
|
|
4622
4650
|
setIsSubmitting(false);
|
|
4623
4651
|
}
|
|
4624
|
-
}, [compact, onSubmit, onSubmitAttempt, passwordPolicy, sharedRegistration, state, submitMeta]);
|
|
4652
|
+
}, [compact, derivedName, onSubmit, onSubmitAttempt, passwordPolicy, sharedRegistration, state, submitMeta, tenantNameHidden]);
|
|
4625
4653
|
return { state, setField, submit, isSubmitting, error };
|
|
4626
4654
|
}
|
|
4627
4655
|
function RegisterFormCore({
|
|
@@ -4635,6 +4663,7 @@ function RegisterFormCore({
|
|
|
4635
4663
|
footer,
|
|
4636
4664
|
testIdPrefix,
|
|
4637
4665
|
compact = false,
|
|
4666
|
+
deriveTenantName,
|
|
4638
4667
|
sharedRegistration
|
|
4639
4668
|
}) {
|
|
4640
4669
|
const theme = useAuthTheme(themeProp);
|
|
@@ -4648,7 +4677,8 @@ function RegisterFormCore({
|
|
|
4648
4677
|
onSubmitAttempt,
|
|
4649
4678
|
passwordPolicy,
|
|
4650
4679
|
compact,
|
|
4651
|
-
sharedRegistration
|
|
4680
|
+
sharedRegistration,
|
|
4681
|
+
deriveTenantName
|
|
4652
4682
|
});
|
|
4653
4683
|
const handlePress = useCallback(async () => {
|
|
4654
4684
|
routeRegisterOutcome(await submit(), { onSuccess, onError });
|
|
@@ -4662,6 +4692,7 @@ function RegisterFormCore({
|
|
|
4662
4692
|
{
|
|
4663
4693
|
compact,
|
|
4664
4694
|
disabled: isSubmitting,
|
|
4695
|
+
hideTenantName: deriveTenantName !== void 0,
|
|
4665
4696
|
labels,
|
|
4666
4697
|
styles: styles3,
|
|
4667
4698
|
testIdPrefix,
|
|
@@ -5797,6 +5828,13 @@ var AccountDeletionTestIds = {
|
|
|
5797
5828
|
emailNotSent: "account-deletion-email-not-sent",
|
|
5798
5829
|
alreadyRequested: "account-deletion-already-requested"
|
|
5799
5830
|
};
|
|
5831
|
+
|
|
5832
|
+
// src/components/scheduledDetail.ts
|
|
5833
|
+
var ISO_CALENDAR_DATE_LENGTH = 10;
|
|
5834
|
+
function scheduledDetail(receipt, labels) {
|
|
5835
|
+
const date = new Date(receipt?.scheduledDeletionDate ?? "");
|
|
5836
|
+
return Number.isNaN(date.getTime()) ? null : interpolate(labels.scheduledDate, { date: date.toISOString().slice(0, ISO_CALENDAR_DATE_LENGTH) });
|
|
5837
|
+
}
|
|
5800
5838
|
function errorText(errorKey, seconds, labels) {
|
|
5801
5839
|
switch (errorKey) {
|
|
5802
5840
|
case null:
|
|
@@ -5815,10 +5853,6 @@ function errorText(errorKey, seconds, labels) {
|
|
|
5815
5853
|
return labels.errorFailed;
|
|
5816
5854
|
}
|
|
5817
5855
|
}
|
|
5818
|
-
function scheduledDetail(receipt, labels) {
|
|
5819
|
-
const date = new Date(receipt?.scheduledDeletionDate ?? "");
|
|
5820
|
-
return Number.isNaN(date.getTime()) ? null : interpolate(labels.scheduledDate, { date: date.toLocaleDateString() });
|
|
5821
|
-
}
|
|
5822
5856
|
function noticeCopy(phase, receipt, labels) {
|
|
5823
5857
|
if (phase === "alreadyRequested" /* AlreadyRequested */) {
|
|
5824
5858
|
return {
|
|
@@ -5906,6 +5940,6 @@ function AccountDeletionForm({
|
|
|
5906
5940
|
] }) });
|
|
5907
5941
|
}
|
|
5908
5942
|
|
|
5909
|
-
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, 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 };
|
|
5943
|
+
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 };
|
|
5910
5944
|
//# sourceMappingURL=index.mjs.map
|
|
5911
5945
|
//# sourceMappingURL=index.mjs.map
|