@dloizides/auth-web 1.20.0 → 1.22.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 +16 -0
- package/dist/index.d.mts +138 -2
- package/dist/index.d.ts +138 -2
- package/dist/index.js +390 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +378 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -353,6 +353,31 @@ var DEFAULT_REGISTER_LABELS = {
|
|
|
353
353
|
}
|
|
354
354
|
};
|
|
355
355
|
|
|
356
|
+
// src/components/labels/verifyEmailLabels.ts
|
|
357
|
+
var DEFAULT_VERIFY_EMAIL_LABELS = {
|
|
358
|
+
loadingTitle: "Verifying your email...",
|
|
359
|
+
loadingHint: "Please wait while we verify your address.",
|
|
360
|
+
successTitle: "Your email is verified",
|
|
361
|
+
successBody: "Thanks for confirming your email address.",
|
|
362
|
+
successContinue: "Continue",
|
|
363
|
+
successContinueHint: "Go to the app",
|
|
364
|
+
errorTitle: "We couldn't verify your email",
|
|
365
|
+
errorInvalid: "This verification link is invalid. Request a new one.",
|
|
366
|
+
errorExpired: "This verification link has expired. Request a new one.",
|
|
367
|
+
errorUsed: "This link has already been used.",
|
|
368
|
+
errorGeneric: "Verification failed. Please try again later.",
|
|
369
|
+
missingToken: "This verification link is missing a token.",
|
|
370
|
+
resendCta: "Send a new verification email",
|
|
371
|
+
resendCtaHint: "Show the resend verification email form",
|
|
372
|
+
resendEmailLabel: "Email",
|
|
373
|
+
resendEmailHint: "The address to send a new verification link to",
|
|
374
|
+
resendEmailPlaceholder: "you@example.com",
|
|
375
|
+
resendMissingEmail: "Enter your email address.",
|
|
376
|
+
resendSubmit: "Send link",
|
|
377
|
+
resendSubmitHint: "Sends a new verification email",
|
|
378
|
+
resendConfirmation: "If that address has an account, a new verification link is on its way."
|
|
379
|
+
};
|
|
380
|
+
|
|
356
381
|
// src/components/testIds.ts
|
|
357
382
|
var AuthTestIds = {
|
|
358
383
|
loginForm: "auth-login-form",
|
|
@@ -443,7 +468,17 @@ var AuthTestIds = {
|
|
|
443
468
|
demoCredentialsPassword: "auth-demo-credentials-password",
|
|
444
469
|
demoCredentialsUseButton: "auth-demo-credentials-use",
|
|
445
470
|
// The collapsed disclosure trigger (`disclosure` variant only).
|
|
446
|
-
demoCredentialsToggle: "auth-demo-credentials-toggle"
|
|
471
|
+
demoCredentialsToggle: "auth-demo-credentials-toggle",
|
|
472
|
+
verifyEmailScreen: "auth-verify-email",
|
|
473
|
+
verifyEmailLoading: "auth-verify-email-loading",
|
|
474
|
+
verifyEmailSuccess: "auth-verify-email-success",
|
|
475
|
+
verifyEmailContinue: "auth-verify-email-continue",
|
|
476
|
+
verifyEmailError: "auth-verify-email-error",
|
|
477
|
+
verifyEmailResendCta: "auth-verify-email-resend-cta",
|
|
478
|
+
verifyEmailResendForm: "auth-verify-email-resend-form",
|
|
479
|
+
verifyEmailResendEmail: "auth-verify-email-resend-email",
|
|
480
|
+
verifyEmailResendSubmit: "auth-verify-email-resend-submit",
|
|
481
|
+
verifyEmailResendConfirmation: "auth-verify-email-resend-confirmation"
|
|
447
482
|
};
|
|
448
483
|
function withTestIdPrefix(baseId, prefix) {
|
|
449
484
|
return prefix === void 0 || prefix === "" ? baseId : `${prefix}-${baseId}`;
|
|
@@ -660,6 +695,18 @@ function useSubmitOnEnter(submit) {
|
|
|
660
695
|
[submit]
|
|
661
696
|
);
|
|
662
697
|
}
|
|
698
|
+
|
|
699
|
+
// src/components/usernameFieldProps.ts
|
|
700
|
+
var EMAIL_USERNAME_PROPS = {
|
|
701
|
+
autoComplete: "username",
|
|
702
|
+
inputMode: "email",
|
|
703
|
+
keyboardType: "email-address",
|
|
704
|
+
textContentType: "username"
|
|
705
|
+
};
|
|
706
|
+
var NO_EXTRA_PROPS = {};
|
|
707
|
+
function usernameFieldProps(emailUsername) {
|
|
708
|
+
return emailUsername ? EMAIL_USERNAME_PROPS : NO_EXTRA_PROPS;
|
|
709
|
+
}
|
|
663
710
|
var BffAuthStatus = /* @__PURE__ */ ((BffAuthStatus2) => {
|
|
664
711
|
BffAuthStatus2["Loading"] = "loading";
|
|
665
712
|
BffAuthStatus2["Authenticated"] = "authenticated";
|
|
@@ -775,7 +822,8 @@ function LoginForm({
|
|
|
775
822
|
initialUsername,
|
|
776
823
|
initialPassword,
|
|
777
824
|
prefillNonce,
|
|
778
|
-
prefillIntent
|
|
825
|
+
prefillIntent,
|
|
826
|
+
emailUsername = false
|
|
779
827
|
}) {
|
|
780
828
|
const theme = useAuthTheme(themeProp);
|
|
781
829
|
const styles3 = useAuthStyles(theme);
|
|
@@ -807,6 +855,7 @@ function LoginForm({
|
|
|
807
855
|
/* @__PURE__ */ jsx(
|
|
808
856
|
TextInput,
|
|
809
857
|
{
|
|
858
|
+
...usernameFieldProps(emailUsername),
|
|
810
859
|
accessibilityHint: labels.usernamePlaceholder,
|
|
811
860
|
accessibilityLabel: labels.usernameLabel,
|
|
812
861
|
autoCapitalize: "none",
|
|
@@ -1301,19 +1350,19 @@ function useResetMutation(client, callbacks) {
|
|
|
1301
1350
|
}
|
|
1302
1351
|
function runSubmit(args) {
|
|
1303
1352
|
args.setErrorKey(null);
|
|
1304
|
-
const
|
|
1353
|
+
const failure2 = preflight({
|
|
1305
1354
|
newPassword: args.newPassword,
|
|
1306
1355
|
confirm: args.confirmPassword,
|
|
1307
1356
|
token: args.token
|
|
1308
1357
|
});
|
|
1309
|
-
if (
|
|
1358
|
+
if (failure2 === null) {
|
|
1310
1359
|
args.mutate({ token: args.token, newPassword: args.newPassword });
|
|
1311
1360
|
return;
|
|
1312
1361
|
}
|
|
1313
|
-
if (
|
|
1362
|
+
if (failure2 === "tokenInvalid" /* TokenInvalid */) {
|
|
1314
1363
|
args.setHasInvalidToken(true);
|
|
1315
1364
|
}
|
|
1316
|
-
args.setErrorKey(
|
|
1365
|
+
args.setErrorKey(failure2);
|
|
1317
1366
|
}
|
|
1318
1367
|
function useFormState() {
|
|
1319
1368
|
const [newPassword, setNewPassword] = useState("");
|
|
@@ -4310,15 +4359,15 @@ function typedFailureOf(error) {
|
|
|
4310
4359
|
}
|
|
4311
4360
|
return { status: hasStatus ? status : null, errorCode: hasCode ? errorCode : null };
|
|
4312
4361
|
}
|
|
4313
|
-
function mapTypedFailure(
|
|
4314
|
-
const byCode =
|
|
4362
|
+
function mapTypedFailure(failure2) {
|
|
4363
|
+
const byCode = failure2.errorCode === null ? void 0 : BODY_ERROR_CODES[failure2.errorCode];
|
|
4315
4364
|
if (byCode !== void 0) {
|
|
4316
4365
|
return byCode;
|
|
4317
4366
|
}
|
|
4318
|
-
if (
|
|
4367
|
+
if (failure2.status === HTTP_TOO_MANY_REQUESTS) {
|
|
4319
4368
|
return "rateLimited" /* RateLimited */;
|
|
4320
4369
|
}
|
|
4321
|
-
const isServerError =
|
|
4370
|
+
const isServerError = failure2.status !== null && failure2.status >= HTTP_SERVER_ERROR_MIN;
|
|
4322
4371
|
return isServerError ? "failed" /* Failed */ : null;
|
|
4323
4372
|
}
|
|
4324
4373
|
function messageOf(error) {
|
|
@@ -4328,8 +4377,8 @@ function messageOf(error) {
|
|
|
4328
4377
|
return typeof error === "string" ? error : "";
|
|
4329
4378
|
}
|
|
4330
4379
|
function mapRegisterErrorCode(error) {
|
|
4331
|
-
const
|
|
4332
|
-
const typed =
|
|
4380
|
+
const failure2 = typedFailureOf(error);
|
|
4381
|
+
const typed = failure2 === null ? null : mapTypedFailure(failure2);
|
|
4333
4382
|
if (typed !== null) {
|
|
4334
4383
|
return typed;
|
|
4335
4384
|
}
|
|
@@ -4623,7 +4672,323 @@ function createBffChangePasswordClient(options = {}) {
|
|
|
4623
4672
|
}
|
|
4624
4673
|
};
|
|
4625
4674
|
}
|
|
4675
|
+
function useResendVerification({ client, verifyUrlTemplate }) {
|
|
4676
|
+
const [email, setEmail] = useState("");
|
|
4677
|
+
const [missingEmail, setMissingEmail] = useState(false);
|
|
4678
|
+
const [submitting, setSubmitting] = useState(false);
|
|
4679
|
+
const [confirmed, setConfirmed] = useState(false);
|
|
4680
|
+
const submit = useCallback(async () => {
|
|
4681
|
+
const trimmed = email.trim();
|
|
4682
|
+
if (trimmed === "") {
|
|
4683
|
+
setMissingEmail(true);
|
|
4684
|
+
return;
|
|
4685
|
+
}
|
|
4686
|
+
setMissingEmail(false);
|
|
4687
|
+
setSubmitting(true);
|
|
4688
|
+
await client.resendVerification(trimmed, verifyUrlTemplate);
|
|
4689
|
+
setSubmitting(false);
|
|
4690
|
+
setConfirmed(true);
|
|
4691
|
+
}, [client, email, verifyUrlTemplate]);
|
|
4692
|
+
return { email, setEmail, missingEmail, submitting, confirmed, submit };
|
|
4693
|
+
}
|
|
4694
|
+
function VerifyEmailResendForm({
|
|
4695
|
+
client,
|
|
4696
|
+
labels,
|
|
4697
|
+
styles: styles3,
|
|
4698
|
+
theme,
|
|
4699
|
+
verifyUrlTemplate,
|
|
4700
|
+
testIdPrefix
|
|
4701
|
+
}) {
|
|
4702
|
+
const resend = useResendVerification({ client, verifyUrlTemplate });
|
|
4703
|
+
const id = (base) => withTestIdPrefix(base, testIdPrefix);
|
|
4704
|
+
if (resend.confirmed) {
|
|
4705
|
+
return /* @__PURE__ */ jsx(Text, { style: styles3.successText, testID: id(AuthTestIds.verifyEmailResendConfirmation), children: labels.resendConfirmation });
|
|
4706
|
+
}
|
|
4707
|
+
const submit = () => {
|
|
4708
|
+
void resend.submit();
|
|
4709
|
+
};
|
|
4710
|
+
const buttonStyle = resend.submitting ? [styles3.primaryButton, styles3.primaryButtonDisabled] : styles3.primaryButton;
|
|
4711
|
+
return /* @__PURE__ */ jsxs(View, { testID: id(AuthTestIds.verifyEmailResendForm), children: [
|
|
4712
|
+
/* @__PURE__ */ jsxs(View, { style: styles3.fieldGroup, children: [
|
|
4713
|
+
/* @__PURE__ */ jsx(Text, { style: styles3.label, children: labels.resendEmailLabel }),
|
|
4714
|
+
/* @__PURE__ */ jsx(
|
|
4715
|
+
TextInput,
|
|
4716
|
+
{
|
|
4717
|
+
accessibilityHint: labels.resendEmailHint,
|
|
4718
|
+
accessibilityLabel: labels.resendEmailLabel,
|
|
4719
|
+
autoCapitalize: "none",
|
|
4720
|
+
autoComplete: "email",
|
|
4721
|
+
autoCorrect: false,
|
|
4722
|
+
autoFocus: true,
|
|
4723
|
+
editable: !resend.submitting,
|
|
4724
|
+
keyboardType: "email-address",
|
|
4725
|
+
placeholder: labels.resendEmailPlaceholder,
|
|
4726
|
+
placeholderTextColor: theme.colors.textSecondary,
|
|
4727
|
+
style: styles3.input,
|
|
4728
|
+
testID: id(AuthTestIds.verifyEmailResendEmail),
|
|
4729
|
+
value: resend.email,
|
|
4730
|
+
onChangeText: resend.setEmail
|
|
4731
|
+
}
|
|
4732
|
+
)
|
|
4733
|
+
] }),
|
|
4734
|
+
resend.missingEmail ? /* @__PURE__ */ jsx(Text, { style: styles3.errorText, children: labels.resendMissingEmail }) : null,
|
|
4735
|
+
/* @__PURE__ */ jsx(
|
|
4736
|
+
TouchableOpacity,
|
|
4737
|
+
{
|
|
4738
|
+
accessibilityHint: labels.resendSubmitHint,
|
|
4739
|
+
accessibilityLabel: labels.resendSubmit,
|
|
4740
|
+
accessibilityRole: "button",
|
|
4741
|
+
disabled: resend.submitting,
|
|
4742
|
+
style: buttonStyle,
|
|
4743
|
+
testID: id(AuthTestIds.verifyEmailResendSubmit),
|
|
4744
|
+
onPress: submit,
|
|
4745
|
+
children: resend.submitting ? /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.colors.onPrimary, size: "small" }) : /* @__PURE__ */ jsx(Text, { style: styles3.primaryButtonText, children: labels.resendSubmit })
|
|
4746
|
+
}
|
|
4747
|
+
)
|
|
4748
|
+
] });
|
|
4749
|
+
}
|
|
4750
|
+
|
|
4751
|
+
// src/verify/VerifyEmailErrorCode.ts
|
|
4752
|
+
var VerifyEmailErrorCode = /* @__PURE__ */ ((VerifyEmailErrorCode2) => {
|
|
4753
|
+
VerifyEmailErrorCode2["TokenInvalid"] = "TOKEN_INVALID";
|
|
4754
|
+
VerifyEmailErrorCode2["TokenExpired"] = "TOKEN_EXPIRED";
|
|
4755
|
+
VerifyEmailErrorCode2["TokenUsed"] = "TOKEN_USED";
|
|
4756
|
+
VerifyEmailErrorCode2["KeycloakUpdateFailed"] = "KEYCLOAK_UPDATE_FAILED";
|
|
4757
|
+
VerifyEmailErrorCode2["MissingToken"] = "MISSING_TOKEN";
|
|
4758
|
+
VerifyEmailErrorCode2["Generic"] = "GENERIC";
|
|
4759
|
+
return VerifyEmailErrorCode2;
|
|
4760
|
+
})(VerifyEmailErrorCode || {});
|
|
4761
|
+
|
|
4762
|
+
// src/verify/VerifyEmailPhase.ts
|
|
4763
|
+
var VerifyEmailPhase = /* @__PURE__ */ ((VerifyEmailPhase2) => {
|
|
4764
|
+
VerifyEmailPhase2["Loading"] = "loading";
|
|
4765
|
+
VerifyEmailPhase2["Success"] = "success";
|
|
4766
|
+
VerifyEmailPhase2["Failure"] = "failure";
|
|
4767
|
+
return VerifyEmailPhase2;
|
|
4768
|
+
})(VerifyEmailPhase || {});
|
|
4769
|
+
|
|
4770
|
+
// src/verify/useVerifyEmail.ts
|
|
4771
|
+
var LOADING = {
|
|
4772
|
+
phase: "loading" /* Loading */,
|
|
4773
|
+
errorCode: "GENERIC" /* Generic */
|
|
4774
|
+
};
|
|
4775
|
+
var SUCCESS = {
|
|
4776
|
+
phase: "success" /* Success */,
|
|
4777
|
+
errorCode: "GENERIC" /* Generic */
|
|
4778
|
+
};
|
|
4779
|
+
var REJECTED = { success: false, errorCode: "GENERIC" /* Generic */ };
|
|
4780
|
+
function failure(errorCode) {
|
|
4781
|
+
return { phase: "failure" /* Failure */, errorCode };
|
|
4782
|
+
}
|
|
4783
|
+
function useVerifyEmail({ client, token, onVerified, onFailed }) {
|
|
4784
|
+
const [state, setState] = useState(LOADING);
|
|
4785
|
+
const latest = useRef({ client, onVerified, onFailed });
|
|
4786
|
+
latest.current = { client, onVerified, onFailed };
|
|
4787
|
+
useEffect(() => {
|
|
4788
|
+
if (token === "") {
|
|
4789
|
+
setState(failure("MISSING_TOKEN" /* MissingToken */));
|
|
4790
|
+
latest.current.onFailed?.("MISSING_TOKEN" /* MissingToken */);
|
|
4791
|
+
return void 0;
|
|
4792
|
+
}
|
|
4793
|
+
let active = true;
|
|
4794
|
+
setState(LOADING);
|
|
4795
|
+
const settle = (result) => {
|
|
4796
|
+
if (!active) {
|
|
4797
|
+
return;
|
|
4798
|
+
}
|
|
4799
|
+
if (result.success) {
|
|
4800
|
+
setState(SUCCESS);
|
|
4801
|
+
latest.current.onVerified?.();
|
|
4802
|
+
return;
|
|
4803
|
+
}
|
|
4804
|
+
setState(failure(result.errorCode));
|
|
4805
|
+
latest.current.onFailed?.(result.errorCode);
|
|
4806
|
+
};
|
|
4807
|
+
void latest.current.client.verifyEmail(token).catch(() => REJECTED).then(settle);
|
|
4808
|
+
return () => {
|
|
4809
|
+
active = false;
|
|
4810
|
+
};
|
|
4811
|
+
}, [token]);
|
|
4812
|
+
return state;
|
|
4813
|
+
}
|
|
4814
|
+
|
|
4815
|
+
// src/verify/verifyEmailErrorText.ts
|
|
4816
|
+
function verifyEmailErrorText(code, labels) {
|
|
4817
|
+
if (code === "TOKEN_INVALID" /* TokenInvalid */) {
|
|
4818
|
+
return labels.errorInvalid;
|
|
4819
|
+
}
|
|
4820
|
+
if (code === "TOKEN_EXPIRED" /* TokenExpired */) {
|
|
4821
|
+
return labels.errorExpired;
|
|
4822
|
+
}
|
|
4823
|
+
if (code === "TOKEN_USED" /* TokenUsed */) {
|
|
4824
|
+
return labels.errorUsed;
|
|
4825
|
+
}
|
|
4826
|
+
if (code === "MISSING_TOKEN" /* MissingToken */) {
|
|
4827
|
+
return labels.missingToken;
|
|
4828
|
+
}
|
|
4829
|
+
return labels.errorGeneric;
|
|
4830
|
+
}
|
|
4831
|
+
function VerifyEmailScreen({
|
|
4832
|
+
client,
|
|
4833
|
+
token,
|
|
4834
|
+
onContinue,
|
|
4835
|
+
theme: themeProp,
|
|
4836
|
+
labels: labelsProp,
|
|
4837
|
+
verifyUrlTemplate,
|
|
4838
|
+
onVerified,
|
|
4839
|
+
onFailed,
|
|
4840
|
+
testIdPrefix
|
|
4841
|
+
}) {
|
|
4842
|
+
const theme = useAuthTheme(themeProp);
|
|
4843
|
+
const styles3 = useAuthStyles(theme);
|
|
4844
|
+
const labels = useMemo(
|
|
4845
|
+
() => ({ ...DEFAULT_VERIFY_EMAIL_LABELS, ...labelsProp }),
|
|
4846
|
+
[labelsProp]
|
|
4847
|
+
);
|
|
4848
|
+
const { phase, errorCode } = useVerifyEmail({ client, token, onVerified, onFailed });
|
|
4849
|
+
const [resendOpen, setResendOpen] = useState(false);
|
|
4850
|
+
const openResend = useCallback(() => setResendOpen(true), []);
|
|
4851
|
+
const id = (base) => withTestIdPrefix(base, testIdPrefix);
|
|
4852
|
+
return /* @__PURE__ */ jsx(View, { style: styles3.screen, testID: id(AuthTestIds.verifyEmailScreen), children: /* @__PURE__ */ jsxs(View, { style: styles3.card, children: [
|
|
4853
|
+
phase === "loading" /* Loading */ ? /* @__PURE__ */ jsxs(View, { testID: id(AuthTestIds.verifyEmailLoading), children: [
|
|
4854
|
+
/* @__PURE__ */ jsx(ActivityIndicator, { color: theme.colors.primary, size: "large" }),
|
|
4855
|
+
/* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: styles3.title, children: labels.loadingTitle }),
|
|
4856
|
+
/* @__PURE__ */ jsx(Text, { style: styles3.subtitle, children: labels.loadingHint })
|
|
4857
|
+
] }) : null,
|
|
4858
|
+
phase === "success" /* Success */ ? /* @__PURE__ */ jsxs(View, { testID: id(AuthTestIds.verifyEmailSuccess), children: [
|
|
4859
|
+
/* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: styles3.title, children: labels.successTitle }),
|
|
4860
|
+
/* @__PURE__ */ jsx(Text, { style: styles3.subtitle, children: labels.successBody }),
|
|
4861
|
+
/* @__PURE__ */ jsx(
|
|
4862
|
+
TouchableOpacity,
|
|
4863
|
+
{
|
|
4864
|
+
accessibilityHint: labels.successContinueHint,
|
|
4865
|
+
accessibilityLabel: labels.successContinue,
|
|
4866
|
+
accessibilityRole: "button",
|
|
4867
|
+
style: styles3.primaryButton,
|
|
4868
|
+
testID: id(AuthTestIds.verifyEmailContinue),
|
|
4869
|
+
onPress: onContinue,
|
|
4870
|
+
children: /* @__PURE__ */ jsx(Text, { style: styles3.primaryButtonText, children: labels.successContinue })
|
|
4871
|
+
}
|
|
4872
|
+
)
|
|
4873
|
+
] }) : null,
|
|
4874
|
+
phase === "failure" /* Failure */ ? /* @__PURE__ */ jsxs(View, { testID: id(AuthTestIds.verifyEmailError), children: [
|
|
4875
|
+
/* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: styles3.title, children: labels.errorTitle }),
|
|
4876
|
+
/* @__PURE__ */ jsx(Text, { style: styles3.errorText, children: verifyEmailErrorText(errorCode, labels) }),
|
|
4877
|
+
resendOpen ? /* @__PURE__ */ jsx(
|
|
4878
|
+
VerifyEmailResendForm,
|
|
4879
|
+
{
|
|
4880
|
+
client,
|
|
4881
|
+
labels,
|
|
4882
|
+
styles: styles3,
|
|
4883
|
+
testIdPrefix,
|
|
4884
|
+
theme,
|
|
4885
|
+
verifyUrlTemplate
|
|
4886
|
+
}
|
|
4887
|
+
) : /* @__PURE__ */ jsx(
|
|
4888
|
+
TouchableOpacity,
|
|
4889
|
+
{
|
|
4890
|
+
accessibilityHint: labels.resendCtaHint,
|
|
4891
|
+
accessibilityLabel: labels.resendCta,
|
|
4892
|
+
accessibilityRole: "button",
|
|
4893
|
+
style: styles3.primaryButton,
|
|
4894
|
+
testID: id(AuthTestIds.verifyEmailResendCta),
|
|
4895
|
+
onPress: openResend,
|
|
4896
|
+
children: /* @__PURE__ */ jsx(Text, { style: styles3.primaryButtonText, children: labels.resendCta })
|
|
4897
|
+
}
|
|
4898
|
+
)
|
|
4899
|
+
] }) : null
|
|
4900
|
+
] }) });
|
|
4901
|
+
}
|
|
4902
|
+
var VERIFY_EMAIL_ENDPOINT = "/bff/verify-email";
|
|
4903
|
+
var RESEND_VERIFICATION_ENDPOINT = "/bff/resend-verification";
|
|
4904
|
+
var CSRF_HEADER3 = "X-BFF-Csrf";
|
|
4905
|
+
var CSRF_HEADER_VALUE3 = "1";
|
|
4906
|
+
var JSON_CONTENT_TYPE3 = "application/json";
|
|
4907
|
+
var SERVER_ERROR_CODES2 = [
|
|
4908
|
+
"TOKEN_INVALID" /* TokenInvalid */,
|
|
4909
|
+
"TOKEN_EXPIRED" /* TokenExpired */,
|
|
4910
|
+
"TOKEN_USED" /* TokenUsed */,
|
|
4911
|
+
"KEYCLOAK_UPDATE_FAILED" /* KeycloakUpdateFailed */
|
|
4912
|
+
];
|
|
4913
|
+
var GENERIC_FAILURE = { success: false, errorCode: "GENERIC" /* Generic */ };
|
|
4914
|
+
async function lazyFetchHttpClient3(request) {
|
|
4915
|
+
const fetchImpl = typeof fetch === "function" ? fetch.bind(globalThis) : void 0;
|
|
4916
|
+
if (fetchImpl === void 0) {
|
|
4917
|
+
throw new Error("createBffVerifyEmailClient: fetch is not available in this environment");
|
|
4918
|
+
}
|
|
4919
|
+
return createFetchHttpClient(fetchImpl)(request);
|
|
4920
|
+
}
|
|
4921
|
+
function isServerErrorCode(value) {
|
|
4922
|
+
return typeof value === "string" && SERVER_ERROR_CODES2.includes(value);
|
|
4923
|
+
}
|
|
4924
|
+
function isRecord3(value) {
|
|
4925
|
+
return typeof value === "object" && value !== null;
|
|
4926
|
+
}
|
|
4927
|
+
function decodeVerifyResponse(body) {
|
|
4928
|
+
if (!isRecord3(body)) {
|
|
4929
|
+
return GENERIC_FAILURE;
|
|
4930
|
+
}
|
|
4931
|
+
if (body.success === true) {
|
|
4932
|
+
return { success: true };
|
|
4933
|
+
}
|
|
4934
|
+
return isServerErrorCode(body.errorCode) ? { success: false, errorCode: body.errorCode } : GENERIC_FAILURE;
|
|
4935
|
+
}
|
|
4936
|
+
function createBffVerifyEmailClient(options = {}) {
|
|
4937
|
+
const http = options.http ?? lazyFetchHttpClient3;
|
|
4938
|
+
const baseUrl = options.baseUrl ?? "";
|
|
4939
|
+
const post = (path, body) => http({
|
|
4940
|
+
url: `${baseUrl}${path}`,
|
|
4941
|
+
method: "POST",
|
|
4942
|
+
headers: { "Content-Type": JSON_CONTENT_TYPE3, [CSRF_HEADER3]: CSRF_HEADER_VALUE3 },
|
|
4943
|
+
body: JSON.stringify(body),
|
|
4944
|
+
credentials: "include"
|
|
4945
|
+
});
|
|
4946
|
+
return {
|
|
4947
|
+
verifyEmail: async (token) => {
|
|
4948
|
+
try {
|
|
4949
|
+
const response = await post(VERIFY_EMAIL_ENDPOINT, { token });
|
|
4950
|
+
return decodeVerifyResponse(response.data);
|
|
4951
|
+
} catch {
|
|
4952
|
+
return GENERIC_FAILURE;
|
|
4953
|
+
}
|
|
4954
|
+
},
|
|
4955
|
+
resendVerification: async (email, verifyUrlTemplate) => {
|
|
4956
|
+
const body = verifyUrlTemplate === void 0 ? { email } : { email, verifyUrlTemplate };
|
|
4957
|
+
try {
|
|
4958
|
+
const response = await post(RESEND_VERIFICATION_ENDPOINT, body);
|
|
4959
|
+
return response.ok;
|
|
4960
|
+
} catch {
|
|
4961
|
+
return false;
|
|
4962
|
+
}
|
|
4963
|
+
}
|
|
4964
|
+
};
|
|
4965
|
+
}
|
|
4966
|
+
|
|
4967
|
+
// src/verify/verifyEmailUrl.ts
|
|
4968
|
+
var VERIFY_TOKEN_PLACEHOLDER = "{token}";
|
|
4969
|
+
var DEFAULT_VERIFY_PATH = "/verify-email";
|
|
4970
|
+
function readWindowOrigin() {
|
|
4971
|
+
if (typeof window === "undefined" || typeof window.location !== "object") {
|
|
4972
|
+
return null;
|
|
4973
|
+
}
|
|
4974
|
+
return typeof window.location.origin === "string" ? window.location.origin : null;
|
|
4975
|
+
}
|
|
4976
|
+
function nonEmpty(value) {
|
|
4977
|
+
return value !== void 0 && value !== "" ? value : null;
|
|
4978
|
+
}
|
|
4979
|
+
function buildVerifyUrlTemplate(options = {}) {
|
|
4980
|
+
const origin = nonEmpty(options.origin) ?? readWindowOrigin() ?? options.fallbackOrigin ?? "";
|
|
4981
|
+
const path = options.path ?? DEFAULT_VERIFY_PATH;
|
|
4982
|
+
return `${origin}${path}?token=${VERIFY_TOKEN_PLACEHOLDER}`;
|
|
4983
|
+
}
|
|
4984
|
+
function readVerifyToken(raw) {
|
|
4985
|
+
if (typeof raw === "string") {
|
|
4986
|
+
return raw;
|
|
4987
|
+
}
|
|
4988
|
+
const first = raw?.[0];
|
|
4989
|
+
return typeof first === "string" ? first : "";
|
|
4990
|
+
}
|
|
4626
4991
|
|
|
4627
|
-
export { AccountSettingsScreen, AuthScreen, AuthTestIds, AuthThemeProvider, BffAuthStatus, CHANGE_PASSWORD_ENDPOINT, ChangePasswordCard, ChangePasswordErrorKey, DEFAULT_ACCOUNT_SETTINGS_LABELS, DEFAULT_AUTH_CARD_MAX_WIDTH, DEFAULT_DEMO_CREDENTIALS_HINT_LABELS, DEFAULT_DEVICE_PIN_ENROLL_LABELS, DEFAULT_DEVICE_PIN_SETTINGS_LABELS, DEFAULT_DEVICE_PIN_UNLOCK_LABELS, DEFAULT_FORGOT_PASSWORD_FIELDS_LABELS, DEFAULT_FORGOT_PASSWORD_LABELS, DEFAULT_LOGIN_LABELS, DEFAULT_OTP_LABELS, DEFAULT_PASSKEY_LOGIN_LABELS, DEFAULT_PASSKEY_SETTINGS_LABELS, DEFAULT_PIN_LABELS, DEFAULT_PREFERRED_METHOD_HINT_LABELS, DEFAULT_PREFERRED_METHOD_SETTINGS_LABELS, DEFAULT_REGISTER_LABELS, DEFAULT_RESET_PASSWORD_LABELS, DEVICE_PIN_ALLOWED_DIGITS, DEVICE_PIN_DEFAULT_DIGITS, DemoCredentialsHint, DemoCredentialsHintVariant, DevicePinEnrollErrorKey, DevicePinEnrollForm, DevicePinErrorKey, DevicePinInput, DevicePinLengthPicker, DevicePinOffer, DevicePinSettingsCard, DevicePinUnlockScreen, ForgotPasswordFields, ForgotPasswordForm, LoginForm, OtpForm, OtpLoginStep, PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, PasskeyCeremonyMode, PasskeyCeremonyStatus, PasskeyLoginButton, PasskeySettingsCard, PasswordPolicyError, PinForm, PreferredMethodHint, PreferredMethodSettingsCard, PrefillIntent, RegisterErrorCode, RegisterForm, RegisterTestIds, ResetPasswordError, ResetPasswordForm, cachePreferredMethod, clearCachedPreferredMethod, collectUserRoles, createBffAuthClient, createBffChangePasswordClient, createPreferencesClient, defaultAuthTheme, deriveUsernameFromEmail, isAllowedPinDigits, isPasswordValid, isRegisterPasswordStrong, isValidForgotPasswordEmail, performBffLogout, readCachedPreferredMethod, readPasskeyError, readPasskeyRegistered, resolveAccessibleRoutes, resolveAccountList, resolveDemoAccounts, resolveDemoCredentials, resolvePostLoginRoute, splitFullName, startPasskeyLogin, startPasskeyRegistration, syncPreferredMethodFromServer, useAuthTheme, useBffAuth, useBffForgotPassword, useBffLoginConfig, useBffResetPassword, useChangePassword, useDemoCredentials, useDevicePinDisable, useDevicePinEnroll, useDevicePinUnlock, useForgotPasswordSubmit, useOtpLogin, usePasskeyCeremony, usePinLogin, usePreferredMethodSetting, useRegisterForm, useResetPasswordForm, validatePasswordPolicy, withTestIdPrefix };
|
|
4992
|
+
export { AccountSettingsScreen, AuthScreen, AuthTestIds, AuthThemeProvider, BffAuthStatus, CHANGE_PASSWORD_ENDPOINT, ChangePasswordCard, ChangePasswordErrorKey, DEFAULT_ACCOUNT_SETTINGS_LABELS, DEFAULT_AUTH_CARD_MAX_WIDTH, DEFAULT_DEMO_CREDENTIALS_HINT_LABELS, DEFAULT_DEVICE_PIN_ENROLL_LABELS, DEFAULT_DEVICE_PIN_SETTINGS_LABELS, DEFAULT_DEVICE_PIN_UNLOCK_LABELS, DEFAULT_FORGOT_PASSWORD_FIELDS_LABELS, DEFAULT_FORGOT_PASSWORD_LABELS, DEFAULT_LOGIN_LABELS, DEFAULT_OTP_LABELS, DEFAULT_PASSKEY_LOGIN_LABELS, DEFAULT_PASSKEY_SETTINGS_LABELS, DEFAULT_PIN_LABELS, DEFAULT_PREFERRED_METHOD_HINT_LABELS, DEFAULT_PREFERRED_METHOD_SETTINGS_LABELS, DEFAULT_REGISTER_LABELS, DEFAULT_RESET_PASSWORD_LABELS, DEFAULT_VERIFY_EMAIL_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, RESEND_VERIFICATION_ENDPOINT, RegisterErrorCode, RegisterForm, RegisterTestIds, ResetPasswordError, ResetPasswordForm, VERIFY_EMAIL_ENDPOINT, VERIFY_TOKEN_PLACEHOLDER, VerifyEmailErrorCode, VerifyEmailPhase, VerifyEmailScreen, buildVerifyUrlTemplate, cachePreferredMethod, clearCachedPreferredMethod, collectUserRoles, createBffAuthClient, createBffChangePasswordClient, createBffVerifyEmailClient, createPreferencesClient, defaultAuthTheme, deriveUsernameFromEmail, isAllowedPinDigits, isPasswordValid, isRegisterPasswordStrong, isValidForgotPasswordEmail, performBffLogout, readCachedPreferredMethod, readPasskeyError, readPasskeyRegistered, readVerifyToken, resolveAccessibleRoutes, resolveAccountList, resolveDemoAccounts, resolveDemoCredentials, resolvePostLoginRoute, splitFullName, startPasskeyLogin, startPasskeyRegistration, syncPreferredMethodFromServer, useAuthTheme, useBffAuth, useBffForgotPassword, useBffLoginConfig, useBffResetPassword, useChangePassword, useDemoCredentials, useDevicePinDisable, useDevicePinEnroll, useDevicePinUnlock, useForgotPasswordSubmit, useOtpLogin, usePasskeyCeremony, usePinLogin, usePreferredMethodSetting, useRegisterForm, useResendVerification, useResetPasswordForm, useVerifyEmail, validatePasswordPolicy, verifyEmailErrorText, withTestIdPrefix };
|
|
4628
4993
|
//# sourceMappingURL=index.mjs.map
|
|
4629
4994
|
//# sourceMappingURL=index.mjs.map
|