@opexa/portal-components 0.1.48 → 0.1.49

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.
Files changed (64) hide show
  1. package/dist/client/hooks/useAuthenticateMutation.js +8 -7
  2. package/dist/client/hooks/useRecaptcha.d.ts +17 -0
  3. package/dist/client/hooks/useRecaptcha.js +87 -0
  4. package/dist/client/hooks/useSignInMutation.js +8 -7
  5. package/dist/client/hooks/useSignUpByNameMutation.js +3 -5
  6. package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/AurixPayQRPHDepositContext.d.ts +2 -2
  7. package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/useAurixPayQRPHDeposit.d.ts +1 -1
  8. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositContext.d.ts +2 -2
  9. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/useOnlineBankDeposit.d.ts +1 -1
  10. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositContext.d.ts +2 -2
  11. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/useQRPHDeposit.d.ts +1 -1
  12. package/dist/components/PortalProvider/PortalProvider.d.ts +1 -1
  13. package/dist/components/PortalProvider/PortalProvider.js +2 -2
  14. package/dist/components/PortalProvider/Providers.d.ts +2 -1
  15. package/dist/components/PortalProvider/Providers.js +7 -3
  16. package/dist/constants/HeaderKey.d.ts +1 -0
  17. package/dist/constants/HeaderKey.js +1 -0
  18. package/dist/constants/StorageKey.d.ts +2 -1
  19. package/dist/constants/StorageKey.js +2 -1
  20. package/dist/handlers/postAuthenticate.js +5 -3
  21. package/dist/handlers/postSession.js +5 -3
  22. package/dist/ui/AlertDialog/AlertDialog.d.ts +187 -187
  23. package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +17 -17
  24. package/dist/ui/Badge/Badge.d.ts +12 -12
  25. package/dist/ui/Badge/badge.anatomy.d.ts +1 -1
  26. package/dist/ui/Badge/badge.recipe.d.ts +3 -3
  27. package/dist/ui/Carousel/Carousel.d.ts +45 -45
  28. package/dist/ui/Carousel/carousel.recipe.d.ts +5 -5
  29. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  30. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  31. package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
  32. package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
  33. package/dist/ui/Combobox/Combobox.d.ts +42 -42
  34. package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
  35. package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
  36. package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
  37. package/dist/ui/Dialog/Dialog.d.ts +33 -33
  38. package/dist/ui/Dialog/dialog.recipe.d.ts +3 -3
  39. package/dist/ui/Drawer/Drawer.d.ts +33 -33
  40. package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
  41. package/dist/ui/Field/Field.d.ts +21 -21
  42. package/dist/ui/Field/field.recipe.d.ts +3 -3
  43. package/dist/ui/Menu/Menu.d.ts +90 -90
  44. package/dist/ui/Menu/menu.recipe.d.ts +5 -5
  45. package/dist/ui/NumberInput/NumberInput.d.ts +24 -24
  46. package/dist/ui/NumberInput/numberInput.recipe.d.ts +3 -3
  47. package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
  48. package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
  49. package/dist/ui/PinInput/PinInput.d.ts +12 -12
  50. package/dist/ui/PinInput/pinInput.recipe.d.ts +3 -3
  51. package/dist/ui/Popover/Popover.d.ts +88 -88
  52. package/dist/ui/Popover/popover.recipe.d.ts +8 -8
  53. package/dist/ui/Progress/Progress.d.ts +27 -27
  54. package/dist/ui/Progress/progress.recipe.d.ts +3 -3
  55. package/dist/ui/QrCode/QrCode.d.ts +25 -25
  56. package/dist/ui/QrCode/qrCode.recipe.d.ts +5 -5
  57. package/dist/ui/SegmentGroup/SegmentGroup.d.ts +18 -18
  58. package/dist/ui/SegmentGroup/segmentGroup.recipe.d.ts +3 -3
  59. package/dist/ui/Select/Select.d.ts +45 -45
  60. package/dist/ui/Select/select.recipe.d.ts +3 -3
  61. package/dist/ui/Table/Table.d.ts +21 -21
  62. package/dist/ui/Table/table.anatomy.d.ts +1 -1
  63. package/dist/ui/Table/table.recipe.d.ts +3 -3
  64. package/package.json +1 -1
@@ -1,26 +1,27 @@
1
1
  import { useMutation } from '@tanstack/react-query';
2
- import { useReCaptcha } from 'next-recaptcha-v3';
3
- import { RECAPTCHA_HEADER_KEY } from '../../constants/index.js';
2
+ import { GOOGLE_FRAUD_DEFENSE_HEADER_KEY, RECAPTCHA_HEADER_KEY, } from '../../constants/index.js';
4
3
  import { getQueryClient } from '../../utils/getQueryClient.js';
5
4
  import { getAuthenticateMutationKey } from '../../utils/mutationKeys.js';
6
5
  import { getSessionQueryKey } from '../../utils/queryKeys.js';
7
6
  import { authenticate } from '../services/authenticate.js';
8
7
  import { getSession } from '../services/getSession.js';
8
+ import { useRecaptcha } from './useRecaptcha.js';
9
9
  export const useAuthenticateMutation = (config) => {
10
10
  const queryClient = getQueryClient();
11
- const recaptcha = useReCaptcha();
11
+ const { executeRecaptcha, isGoogleFraudDefense } = useRecaptcha();
12
12
  return useMutation({
13
13
  ...config,
14
14
  mutationKey: getAuthenticateMutationKey(),
15
15
  mutationFn: async (input) => {
16
16
  const session = await getSession();
17
- const token = recaptcha.reCaptchaKey
18
- ? await recaptcha.executeRecaptcha('submit')
19
- : null;
17
+ const token = await executeRecaptcha('submit');
18
+ const recaptchaHeaderKey = isGoogleFraudDefense
19
+ ? GOOGLE_FRAUD_DEFENSE_HEADER_KEY
20
+ : RECAPTCHA_HEADER_KEY;
20
21
  await authenticate(input, {
21
22
  headers: {
22
23
  ...(token && {
23
- [RECAPTCHA_HEADER_KEY]: token,
24
+ [recaptchaHeaderKey]: token,
24
25
  }),
25
26
  ...(session.domain && {
26
27
  Domain: session.domain,
@@ -0,0 +1,17 @@
1
+ export interface UseRecaptchaReturn {
2
+ executeRecaptcha(action: string): Promise<string | null>;
3
+ isGoogleFraudDefense: boolean;
4
+ }
5
+ export declare function useRecaptcha(): UseRecaptchaReturn;
6
+ declare global {
7
+ interface Window {
8
+ grecaptcha?: {
9
+ enterprise?: {
10
+ ready(callback: () => void): void;
11
+ execute(siteKey: string, options: {
12
+ action: string;
13
+ }): Promise<string>;
14
+ };
15
+ };
16
+ }
17
+ }
@@ -0,0 +1,87 @@
1
+ 'use client';
2
+ import { useReCaptcha } from 'next-recaptcha-v3';
3
+ import { useCallback } from 'react';
4
+ import { GOOGLE_FRAUD_DEFENSE_SITE_KEY_STORAGE } from '../../constants/index.js';
5
+ import { useFeatureFlag } from './useFeatureFlag.js';
6
+ export function useRecaptcha() {
7
+ const { enabled } = useFeatureFlag();
8
+ const recaptchaV3 = useReCaptcha();
9
+ const executeRecaptcha = useCallback(async (action) => {
10
+ if (enabled) {
11
+ const siteKey = sessionStorage.getItem(GOOGLE_FRAUD_DEFENSE_SITE_KEY_STORAGE);
12
+ if (!siteKey)
13
+ return null;
14
+ return executeGoogleFraudDefense(siteKey, action);
15
+ }
16
+ if (!recaptchaV3.reCaptchaKey)
17
+ return null;
18
+ return recaptchaV3.executeRecaptcha(action);
19
+ }, [enabled, recaptchaV3]);
20
+ return { executeRecaptcha, isGoogleFraudDefense: enabled };
21
+ }
22
+ let enterpriseLoaded = false;
23
+ let enterpriseLoadPromise = null;
24
+ function loadEnterpriseScript(siteKey) {
25
+ if (enterpriseLoaded)
26
+ return Promise.resolve();
27
+ if (!enterpriseLoadPromise) {
28
+ enterpriseLoadPromise = new Promise((resolve, reject) => {
29
+ const script = document.createElement('script');
30
+ script.src = `https://www.google.com/recaptcha/enterprise.js?render=${siteKey}`;
31
+ script.async = true;
32
+ script.defer = true;
33
+ script.onload = () => {
34
+ enterpriseLoaded = true;
35
+ resolve();
36
+ };
37
+ script.onerror = () => {
38
+ enterpriseLoadPromise = null;
39
+ reject(new Error('Failed to load reCAPTCHA Enterprise script'));
40
+ };
41
+ document.head.appendChild(script);
42
+ });
43
+ }
44
+ return enterpriseLoadPromise;
45
+ }
46
+ function waitForEnterprise() {
47
+ return new Promise((resolve) => {
48
+ if (window.grecaptcha?.enterprise) {
49
+ resolve();
50
+ return;
51
+ }
52
+ const interval = setInterval(() => {
53
+ if (window.grecaptcha?.enterprise) {
54
+ clearInterval(interval);
55
+ resolve();
56
+ }
57
+ }, 100);
58
+ setTimeout(() => {
59
+ clearInterval(interval);
60
+ resolve();
61
+ }, 10000);
62
+ });
63
+ }
64
+ async function executeGoogleFraudDefense(siteKey, action) {
65
+ try {
66
+ await loadEnterpriseScript(siteKey);
67
+ await waitForEnterprise();
68
+ return new Promise((resolve) => {
69
+ if (!window.grecaptcha?.enterprise) {
70
+ resolve(null);
71
+ return;
72
+ }
73
+ window.grecaptcha.enterprise.ready(async () => {
74
+ try {
75
+ const token = await window.grecaptcha.enterprise.execute(siteKey, { action });
76
+ resolve(token);
77
+ }
78
+ catch {
79
+ resolve(null);
80
+ }
81
+ });
82
+ });
83
+ }
84
+ catch {
85
+ return null;
86
+ }
87
+ }
@@ -1,34 +1,35 @@
1
1
  import { Capacitor } from '@capacitor/core';
2
2
  import { useMutation } from '@tanstack/react-query';
3
3
  import { Thumbmark } from '@thumbmarkjs/thumbmarkjs';
4
- import { useReCaptcha } from 'next-recaptcha-v3';
5
- import { FINGERPRINT_HEADER_KEY, RECAPTCHA_HEADER_KEY } from '../../constants/index.js';
4
+ import { FINGERPRINT_HEADER_KEY, GOOGLE_FRAUD_DEFENSE_HEADER_KEY, RECAPTCHA_HEADER_KEY, } from '../../constants/index.js';
6
5
  import { createPoll } from '../../utils/createPoll.js';
7
6
  import { getQueryClient } from '../../utils/getQueryClient.js';
8
7
  import { getSignInMutationKey } from '../../utils/mutationKeys.js';
9
8
  import { getSessionQueryKey } from '../../utils/queryKeys.js';
10
9
  import { getSession } from '../services/getSession.js';
11
10
  import { signIn } from '../services/signIn.js';
11
+ import { useRecaptcha } from './useRecaptcha.js';
12
12
  export const useSignInMutation = (options) => {
13
13
  const queryClient = getQueryClient();
14
- const recaptcha = useReCaptcha();
14
+ const { executeRecaptcha, isGoogleFraudDefense } = useRecaptcha();
15
15
  const { versionSession, ...config } = options ?? {};
16
16
  return useMutation({
17
17
  ...config,
18
18
  mutationKey: getSignInMutationKey(),
19
19
  mutationFn: async (input) => {
20
20
  const session = await getSession();
21
- const token = recaptcha.reCaptchaKey
22
- ? await recaptcha.executeRecaptcha('submit')
23
- : null;
21
+ const token = await executeRecaptcha('submit');
24
22
  const isInplayEligible = input.type === 'NAME_AND_PASSWORD' || input.type === 'MOBILE_NUMBER';
25
23
  const fingerprint = versionSession === 'Inplay' && isInplayEligible
26
24
  ? await getFingerprint()
27
25
  : null;
26
+ const recaptchaHeaderKey = isGoogleFraudDefense
27
+ ? GOOGLE_FRAUD_DEFENSE_HEADER_KEY
28
+ : RECAPTCHA_HEADER_KEY;
28
29
  const signInOnce = () => signIn(input, {
29
30
  headers: {
30
31
  ...(token && {
31
- [RECAPTCHA_HEADER_KEY]: token,
32
+ [recaptchaHeaderKey]: token,
32
33
  }),
33
34
  ...(session.domain && {
34
35
  Domain: session.domain,
@@ -1,20 +1,18 @@
1
1
  import { useMutation } from '@tanstack/react-query';
2
- import { useReCaptcha } from 'next-recaptcha-v3';
3
2
  import { registerMemberAccountByName, } from '../../services/account.js';
4
3
  import { getSignUpMutationKey } from '../../utils/mutationKeys.js';
5
4
  import { getSession } from '../services/getSession.js';
6
5
  import { useCellxpertCxd } from './useCellxpertCxd.js';
6
+ import { useRecaptcha } from './useRecaptcha.js';
7
7
  export const useSignUpByNameMutation = (config) => {
8
- const recaptcha = useReCaptcha();
8
+ const { executeRecaptcha } = useRecaptcha();
9
9
  const [cellxpertCxd] = useCellxpertCxd();
10
10
  return useMutation({
11
11
  ...config,
12
12
  mutationKey: getSignUpMutationKey(),
13
13
  mutationFn: async (input) => {
14
14
  const session = await getSession();
15
- const reCAPTCHAResponse = recaptcha.reCaptchaKey
16
- ? await recaptcha.executeRecaptcha('submit')
17
- : '';
15
+ const reCAPTCHAResponse = (await executeRecaptcha('submit')) ?? '';
18
16
  return await registerMemberAccountByName({
19
17
  ...input,
20
18
  ...(cellxpertCxd && {
@@ -1,6 +1,6 @@
1
1
  export declare const AurixPayQRPHDepositContext: (props: {
2
2
  value: {
3
- status: "idle" | "confirmed" | "failed" | "generating-qr-code" | "qr-code-generated";
3
+ status: "idle" | "generating-qr-code" | "qr-code-generated" | "failed" | "confirmed";
4
4
  deposit: import("../../../../types").Deposit | null;
5
5
  errorMessage: {
6
6
  name: string;
@@ -13,7 +13,7 @@ export declare const AurixPayQRPHDepositContext: (props: {
13
13
  } & {
14
14
  children?: import("react").ReactNode | undefined;
15
15
  }) => React.ReactNode, useAurixPayQRPHDepositContext: () => {
16
- status: "idle" | "confirmed" | "failed" | "generating-qr-code" | "qr-code-generated";
16
+ status: "idle" | "generating-qr-code" | "qr-code-generated" | "failed" | "confirmed";
17
17
  deposit: import("../../../../types").Deposit | null;
18
18
  errorMessage: {
19
19
  name: string;
@@ -5,7 +5,7 @@ export interface GenerateQRCodeInput {
5
5
  promo?: string | null;
6
6
  }
7
7
  export declare function useAurixPayQRPHDeposit(): {
8
- status: "idle" | "confirmed" | "failed" | "generating-qr-code" | "qr-code-generated";
8
+ status: "idle" | "generating-qr-code" | "qr-code-generated" | "failed" | "confirmed";
9
9
  deposit: Deposit | null;
10
10
  errorMessage: {
11
11
  name: string;
@@ -1,7 +1,7 @@
1
1
  export declare const OnlineBankDepositContext: (props: {
2
2
  value: {
3
3
  view: "form" | "vca";
4
- status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
4
+ status: "waiting" | "failed" | "processing" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
5
5
  verify: () => void;
6
6
  reset: () => void;
7
7
  deposit: import("../../../../types").Deposit | null;
@@ -14,7 +14,7 @@ export declare const OnlineBankDepositContext: (props: {
14
14
  children?: import("react").ReactNode | undefined;
15
15
  }) => React.ReactNode, useOnlineBankDepositContext: () => {
16
16
  view: "form" | "vca";
17
- status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
17
+ status: "waiting" | "failed" | "processing" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
18
18
  verify: () => void;
19
19
  reset: () => void;
20
20
  deposit: import("../../../../types").Deposit | null;
@@ -2,7 +2,7 @@ import type { Deposit } from '../../../../types';
2
2
  export type UseOnlineBankDepositReturn = ReturnType<typeof useOnlineBankDeposit>;
3
3
  export declare function useOnlineBankDeposit(): {
4
4
  view: "form" | "vca";
5
- status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
5
+ status: "waiting" | "failed" | "processing" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
6
6
  verify: () => void;
7
7
  reset: () => void;
8
8
  deposit: Deposit | null;
@@ -1,6 +1,6 @@
1
1
  export declare const QRPHDepositContext: (props: {
2
2
  value: {
3
- status: "idle" | "confirmed" | "failed" | "generating-qr-code" | "qr-code-generated";
3
+ status: "idle" | "generating-qr-code" | "qr-code-generated" | "failed" | "confirmed";
4
4
  deposit: import("../../../../types").Deposit | null;
5
5
  errorMessage: {
6
6
  name: string;
@@ -13,7 +13,7 @@ export declare const QRPHDepositContext: (props: {
13
13
  } & {
14
14
  children?: import("react").ReactNode | undefined;
15
15
  }) => React.ReactNode, useQRPHDepositContext: () => {
16
- status: "idle" | "confirmed" | "failed" | "generating-qr-code" | "qr-code-generated";
16
+ status: "idle" | "generating-qr-code" | "qr-code-generated" | "failed" | "confirmed";
17
17
  deposit: import("../../../../types").Deposit | null;
18
18
  errorMessage: {
19
19
  name: string;
@@ -5,7 +5,7 @@ export interface GenerateQRCodeInput {
5
5
  promo?: string | null;
6
6
  }
7
7
  export declare function useQRPHDeposit(): {
8
- status: "idle" | "confirmed" | "failed" | "generating-qr-code" | "qr-code-generated";
8
+ status: "idle" | "generating-qr-code" | "qr-code-generated" | "failed" | "confirmed";
9
9
  deposit: Deposit | null;
10
10
  errorMessage: {
11
11
  name: string;
@@ -4,4 +4,4 @@ export interface PortalProviderProps extends ProvidersProps {
4
4
  children: ReactNode;
5
5
  enablePushNotif?: boolean;
6
6
  }
7
- export declare function PortalProvider({ recaptchaSiteKey, isNonRegulated, children, enablePushNotif, }: PortalProviderProps): Promise<import("react/jsx-runtime").JSX.Element>;
7
+ export declare function PortalProvider({ recaptchaSiteKey, googleFraudDefenseSiteKey, isNonRegulated, children, enablePushNotif, }: PortalProviderProps): Promise<import("react/jsx-runtime").JSX.Element>;
@@ -15,7 +15,7 @@ import { SetupCellxpertCxd } from './SetupCellxpertCxd.js';
15
15
  import { SetupDomain } from './SetupDomain.js';
16
16
  import { Snackbar } from './Snackbar.js';
17
17
  import { SocialAccountLinkObserver } from './SocialAccountLinkObserver.js';
18
- export async function PortalProvider({ recaptchaSiteKey, isNonRegulated, children, enablePushNotif = true, }) {
18
+ export async function PortalProvider({ recaptchaSiteKey, googleFraudDefenseSiteKey, isNonRegulated, children, enablePushNotif = true, }) {
19
19
  const queryClient = getQueryClient();
20
20
  await Promise.allSettled([
21
21
  prefetchPlatformQuery(),
@@ -23,5 +23,5 @@ export async function PortalProvider({ recaptchaSiteKey, isNonRegulated, childre
23
23
  prefetchAccountQuery(),
24
24
  prefetchWalletQuery(),
25
25
  ]);
26
- return (_jsxs(Fragment, { children: [_jsx(Providers, { isNonRegulated: isNonRegulated, recaptchaSiteKey: recaptchaSiteKey, children: _jsxs(HydrationBoundary, { state: dehydrate(queryClient), children: [children, _jsx(SessionWatcher, {}), _jsx(Suspense, { children: _jsx(SetupDomain, {}) }), _jsx(Suspense, { children: _jsx(SetupCellxpertCxd, {}) }), _jsx(Suspense, { children: _jsx(SetupBtag, {}) }), _jsx(Suspense, { children: _jsx(AppOnlyComponents, { enablePushNotif: enablePushNotif }) })] }) }), _jsx(Snackbar, {}), _jsx(Suspense, { children: _jsx(SocialAccountLinkObserver, {}) }), _jsx(Suspense, { children: _jsx(FeatureFlag, {}) })] }));
26
+ return (_jsxs(Fragment, { children: [_jsx(Providers, { isNonRegulated: isNonRegulated, recaptchaSiteKey: recaptchaSiteKey, googleFraudDefenseSiteKey: googleFraudDefenseSiteKey, children: _jsxs(HydrationBoundary, { state: dehydrate(queryClient), children: [children, _jsx(SessionWatcher, {}), _jsx(Suspense, { children: _jsx(SetupDomain, {}) }), _jsx(Suspense, { children: _jsx(SetupCellxpertCxd, {}) }), _jsx(Suspense, { children: _jsx(SetupBtag, {}) }), _jsx(Suspense, { children: _jsx(AppOnlyComponents, { enablePushNotif: enablePushNotif }) })] }) }), _jsx(Snackbar, {}), _jsx(Suspense, { children: _jsx(SocialAccountLinkObserver, {}) }), _jsx(Suspense, { children: _jsx(FeatureFlag, {}) })] }));
27
27
  }
@@ -2,5 +2,6 @@ import { type PropsWithChildren } from 'react';
2
2
  export interface ProvidersProps {
3
3
  recaptchaSiteKey?: string;
4
4
  isNonRegulated?: boolean;
5
+ googleFraudDefenseSiteKey?: string;
5
6
  }
6
- export declare function Providers({ recaptchaSiteKey, isNonRegulated, children, }: PropsWithChildren<ProvidersProps>): import("react/jsx-runtime").JSX.Element;
7
+ export declare function Providers({ recaptchaSiteKey, googleFraudDefenseSiteKey, isNonRegulated, children, }: PropsWithChildren<ProvidersProps>): import("react/jsx-runtime").JSX.Element;
@@ -5,16 +5,20 @@ import { ReCaptchaProvider } from 'next-recaptcha-v3';
5
5
  import { useEffect } from 'react';
6
6
  import { useShallow } from 'zustand/shallow';
7
7
  import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
8
+ import { GOOGLE_FRAUD_DEFENSE_SITE_KEY_STORAGE } from '../../constants/index.js';
8
9
  import { getQueryClient } from '../../utils/getQueryClient.js';
9
- export function Providers({ recaptchaSiteKey, isNonRegulated, children, }) {
10
+ export function Providers({ recaptchaSiteKey, googleFraudDefenseSiteKey, isNonRegulated, children, }) {
10
11
  const queryClient = getQueryClient();
11
12
  const setIsNonRegulated = useGlobalStore(useShallow((ctx) => ctx.setIsNonRegulated));
12
- // set a global store to check if the platform is non regulated
13
- // use this through out the components as a checker if we need to bypass kyc checks
14
13
  useEffect(() => {
15
14
  if (isNonRegulated) {
16
15
  setIsNonRegulated(true);
17
16
  }
18
17
  }, [isNonRegulated, setIsNonRegulated]);
18
+ useEffect(() => {
19
+ if (googleFraudDefenseSiteKey) {
20
+ sessionStorage.setItem(GOOGLE_FRAUD_DEFENSE_SITE_KEY_STORAGE, googleFraudDefenseSiteKey);
21
+ }
22
+ }, [googleFraudDefenseSiteKey]);
19
23
  return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(ReCaptchaProvider, { reCaptchaKey: recaptchaSiteKey, children: children }) }));
20
24
  }
@@ -3,3 +3,4 @@ export declare const TEST_PASS_HEADER_KEY: string;
3
3
  export declare const DOMAIN_HEADER_KEY: string;
4
4
  export declare const SESSION_VERSION_HEADER_KEY: string;
5
5
  export declare const FINGERPRINT_HEADER_KEY: string;
6
+ export declare const GOOGLE_FRAUD_DEFENSE_HEADER_KEY: string;
@@ -3,3 +3,4 @@ export const TEST_PASS_HEADER_KEY = 'Test-Pass';
3
3
  export const DOMAIN_HEADER_KEY = 'Domain';
4
4
  export const SESSION_VERSION_HEADER_KEY = 'X-Session-Version';
5
5
  export const FINGERPRINT_HEADER_KEY = 'Fingerprint';
6
+ export const GOOGLE_FRAUD_DEFENSE_HEADER_KEY = 'X-Recaptcha-Token';
@@ -2,7 +2,8 @@ export declare const ACCESS_TOKEN_COOKIE_NAME: string;
2
2
  export declare const REFRESH_TOKEN_COOKIE_NAME: string;
3
3
  export declare const DOMAIN_COOKIE_NAME: string;
4
4
  export declare const BTAG_COOKIE_NAME: string;
5
- export declare const FEATURE_FLAG_LOCAL_STORAGE_KEY: string;
6
5
  export declare const CXD_STORAGE_KEY: string;
7
6
  export declare const TERMS_OF_USE_PENDING_STORAGE_KEY: string;
8
7
  export declare const DISCLAIMER_ACCEPTED_KEY: string;
8
+ export declare const FEATURE_FLAG_LOCAL_STORAGE_KEY: string;
9
+ export declare const GOOGLE_FRAUD_DEFENSE_SITE_KEY_STORAGE: string;
@@ -2,7 +2,8 @@ export const ACCESS_TOKEN_COOKIE_NAME = 'WebPortalAuthAccessToken';
2
2
  export const REFRESH_TOKEN_COOKIE_NAME = 'WebPortalAuthRefreshToken';
3
3
  export const DOMAIN_COOKIE_NAME = 'WebPortalDomain';
4
4
  export const BTAG_COOKIE_NAME = 'WebPortalBtag';
5
- export const FEATURE_FLAG_LOCAL_STORAGE_KEY = 'WebPortalFeatureFlag';
6
5
  export const CXD_STORAGE_KEY = 'WebPortalCellxpertCxd';
7
6
  export const TERMS_OF_USE_PENDING_STORAGE_KEY = 'TermsOfUsePending';
8
7
  export const DISCLAIMER_ACCEPTED_KEY = 'WebPortalDisclaimerAccepted';
8
+ export const FEATURE_FLAG_LOCAL_STORAGE_KEY = 'WebPortalFeatureFlag';
9
+ export const GOOGLE_FRAUD_DEFENSE_SITE_KEY_STORAGE = 'GoogleFraudDefenseSiteKey';
@@ -1,7 +1,7 @@
1
1
  import { addDays, addMinutes, subMinutes } from 'date-fns';
2
2
  import { NextResponse } from 'next/server';
3
3
  import { z } from 'zod';
4
- import { ACCESS_TOKEN_COOKIE_NAME, DOMAIN_HEADER_KEY, RECAPTCHA_HEADER_KEY, REFRESH_TOKEN_COOKIE_NAME, } from '../constants/index.js';
4
+ import { ACCESS_TOKEN_COOKIE_NAME, DOMAIN_HEADER_KEY, GOOGLE_FRAUD_DEFENSE_HEADER_KEY, RECAPTCHA_HEADER_KEY, REFRESH_TOKEN_COOKIE_NAME, } from '../constants/index.js';
5
5
  import { authenticate } from '../services/auth.js';
6
6
  const AuthenticateDefinition = z.object({
7
7
  type: z.literal('SECURITY_QUESTION'),
@@ -21,12 +21,14 @@ export async function postAuthenticate(request) {
21
21
  }, { status: 400 });
22
22
  }
23
23
  const recaptcha = request.headers.get(RECAPTCHA_HEADER_KEY);
24
+ const googleFraudDefense = request.headers.get(GOOGLE_FRAUD_DEFENSE_HEADER_KEY);
25
+ const recaptchaToken = googleFraudDefense ?? recaptcha;
24
26
  const domain = request.headers.get(DOMAIN_HEADER_KEY);
25
27
  try {
26
28
  const res = await authenticate(parsed.data, {
27
29
  headers: {
28
- ...(recaptcha && {
29
- [RECAPTCHA_HEADER_KEY]: recaptcha,
30
+ ...(recaptchaToken && {
31
+ [RECAPTCHA_HEADER_KEY]: recaptchaToken,
30
32
  }),
31
33
  ...(domain && {
32
34
  [DOMAIN_HEADER_KEY]: domain,
@@ -1,7 +1,7 @@
1
1
  import { addDays, addMinutes, subMinutes } from 'date-fns';
2
2
  import { NextResponse } from 'next/server';
3
3
  import { z } from 'zod';
4
- import { ACCESS_TOKEN_COOKIE_NAME, DOMAIN_HEADER_KEY, FINGERPRINT_HEADER_KEY, RECAPTCHA_HEADER_KEY, REFRESH_TOKEN_COOKIE_NAME, SESSION_VERSION_HEADER_KEY, } from '../constants/index.js';
4
+ import { ACCESS_TOKEN_COOKIE_NAME, DOMAIN_HEADER_KEY, FINGERPRINT_HEADER_KEY, GOOGLE_FRAUD_DEFENSE_HEADER_KEY, RECAPTCHA_HEADER_KEY, REFRESH_TOKEN_COOKIE_NAME, SESSION_VERSION_HEADER_KEY, } from '../constants/index.js';
5
5
  import { createSession } from '../services/auth.js';
6
6
  const CreateSessionDefinition = z.union([
7
7
  z.object({
@@ -45,10 +45,12 @@ export async function postSession(request) {
45
45
  const versionSessionHeader = request.headers.get(SESSION_VERSION_HEADER_KEY);
46
46
  const versionSession = versionSessionHeader === 'Inplay' ? 'Inplay' : 'default';
47
47
  try {
48
+ const googleFraudDefense = request.headers.get(GOOGLE_FRAUD_DEFENSE_HEADER_KEY);
49
+ const recaptchaToken = googleFraudDefense ?? recaptcha;
48
50
  const res = await createSession(parsed.data, {
49
51
  headers: {
50
- ...(recaptcha && {
51
- [RECAPTCHA_HEADER_KEY]: recaptcha,
52
+ ...(recaptchaToken && {
53
+ [RECAPTCHA_HEADER_KEY]: recaptchaToken,
52
54
  }),
53
55
  ...(domain && {
54
56
  [DOMAIN_HEADER_KEY]: domain,