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