@opexa/portal-components 0.1.71 → 0.1.73

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 (34) hide show
  1. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositContext.d.ts +2 -2
  2. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/useOnlineBankDeposit.d.ts +1 -1
  3. package/dist/components/KYC/KycOpenOnHomeMount.js +2 -2
  4. package/dist/components/PortalProvider/SessionWatcher.js +2 -42
  5. package/dist/constants/StorageKey.d.ts +1 -0
  6. package/dist/constants/StorageKey.js +1 -0
  7. package/dist/handlers/deleteSession.js +4 -2
  8. package/dist/handlers/getSession.js +11 -3
  9. package/dist/handlers/postSession.js +6 -1
  10. package/dist/middleware.js +33 -5
  11. package/dist/ui/AlertDialog/AlertDialog.d.ts +187 -187
  12. package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +17 -17
  13. package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
  14. package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
  15. package/dist/ui/Collapsible/Collapsible.d.ts +20 -20
  16. package/dist/ui/Collapsible/collapsible.recipe.d.ts +5 -5
  17. package/dist/ui/Combobox/Combobox.d.ts +42 -42
  18. package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
  19. package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
  20. package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
  21. package/dist/ui/Dialog/Dialog.d.ts +33 -33
  22. package/dist/ui/Dialog/dialog.recipe.d.ts +3 -3
  23. package/dist/ui/Drawer/Drawer.d.ts +33 -33
  24. package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
  25. package/dist/ui/Popover/Popover.d.ts +121 -121
  26. package/dist/ui/Popover/popover.recipe.d.ts +11 -11
  27. package/dist/ui/Select/Select.d.ts +45 -45
  28. package/dist/ui/Select/select.recipe.d.ts +3 -3
  29. package/dist/ui/Table/Table.d.ts +21 -21
  30. package/dist/ui/Table/table.anatomy.d.ts +1 -1
  31. package/dist/ui/Table/table.recipe.d.ts +3 -3
  32. package/dist/ui/Tabs/Tabs.d.ts +15 -15
  33. package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
  34. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  export declare const OnlineBankDepositContext: (props: {
2
2
  value: {
3
- view: "vca" | "form";
3
+ view: "form" | "vca";
4
4
  status: "waiting" | "failed" | "processing" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
5
5
  verify: () => void;
6
6
  reset: () => void;
@@ -13,7 +13,7 @@ export declare const OnlineBankDepositContext: (props: {
13
13
  } & {
14
14
  children?: import("react").ReactNode | undefined;
15
15
  }) => React.ReactNode, useOnlineBankDepositContext: () => {
16
- view: "vca" | "form";
16
+ view: "form" | "vca";
17
17
  status: "waiting" | "failed" | "processing" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
18
18
  verify: () => void;
19
19
  reset: () => void;
@@ -1,7 +1,7 @@
1
1
  import type { Deposit } from '../../../../types';
2
2
  export type UseOnlineBankDepositReturn = ReturnType<typeof useOnlineBankDeposit>;
3
3
  export declare function useOnlineBankDeposit(): {
4
- view: "vca" | "form";
4
+ view: "form" | "vca";
5
5
  status: "waiting" | "failed" | "processing" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
6
6
  verify: () => void;
7
7
  reset: () => void;
@@ -9,7 +9,6 @@ export function KycOpenOnHomeMount({ isSkippable, bypassKycCheck, enablePendingK
9
9
  const setkycAccountVerificationRequired = useGlobalStore((s) => s.kycAccountVerificationRequired.setOpen);
10
10
  const isSignUpOpen = useGlobalStore((s) => s.signUp.open);
11
11
  const isKycOpen = useGlobalStore((s) => s.kyc.open);
12
- const isKycReminderOpen = useGlobalStore((s) => s.kycReminder.open);
13
12
  const { data: verification, isLoading: verificationLoading } = useMemberVerificationQuery();
14
13
  const { data: account, isLoading: accountLoading } = useAccountQuery();
15
14
  const isVerificationLocked = account?.status === 'VERIFICATION_LOCKED';
@@ -36,6 +35,8 @@ export function KycOpenOnHomeMount({ isSkippable, bypassKycCheck, enablePendingK
36
35
  const shouldShowReminder = Boolean(isSkippable) && !isVerificationLocked;
37
36
  const hasSeenKycModal = sessionStorage.getItem('hasSeenKycModal');
38
37
  const isFirstVisit = !hasSeenKycModal;
38
+ // Closing the reminder must not re-run this home-mount decision.
39
+ const isKycReminderOpen = useGlobalStore.getState().kycReminder.open;
39
40
  if (isKycCompleted) {
40
41
  setkycReminderOpen(false);
41
42
  setkycOpen(false);
@@ -112,7 +113,6 @@ export function KycOpenOnHomeMount({ isSkippable, bypassKycCheck, enablePendingK
112
113
  accountLoading,
113
114
  isSignUpOpen,
114
115
  isKycOpen,
115
- isKycReminderOpen,
116
116
  isVerificationLocked,
117
117
  isPending,
118
118
  isRejected,
@@ -1,7 +1,5 @@
1
1
  'use client';
2
- import { App } from '@capacitor/app';
3
2
  import { useRouter } from 'next/navigation';
4
- import { useEffect, useRef } from 'react';
5
3
  import { useTimeout } from 'usehooks-ts';
6
4
  import { useShallow } from 'zustand/shallow';
7
5
  import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
@@ -9,51 +7,13 @@ import { useSessionHealthQuery } from '../../client/hooks/useSessionHealthQuery.
9
7
  import { useSessionQuery } from '../../client/hooks/useSessionQuery.js';
10
8
  import { useSignOutMutation } from '../../client/hooks/useSignOutMutation.js';
11
9
  import { toaster } from '../../client/utils/toaster.js';
12
- const SESSION_WATCH_INTERVAL = 5_000;
13
10
  export function SessionWatcher() {
14
11
  const router = useRouter();
15
12
  const sessionQuery = useSessionQuery();
16
- const isAuthenticated = sessionQuery.data?.status === 'authenticated';
17
- const isAuthenticatedRef = useRef(isAuthenticated);
18
- isAuthenticatedRef.current = isAuthenticated;
19
13
  const sessionHealthQuery = useSessionHealthQuery({
20
- enabled: false,
14
+ enabled: sessionQuery.data?.status === 'authenticated',
15
+ refetchInterval: 1000 * 5,
21
16
  });
22
- const refetchSessionHealthRef = useRef(sessionHealthQuery.refetch);
23
- refetchSessionHealthRef.current = sessionHealthQuery.refetch;
24
- useEffect(() => {
25
- let timeout = null;
26
- let isForeground = true;
27
- let stopped = false;
28
- const listener = App.addListener('appStateChange', ({ isActive }) => {
29
- isForeground = isActive;
30
- });
31
- const assignTimeout = () => {
32
- return setTimeout(async () => {
33
- if (isForeground && isAuthenticatedRef.current) {
34
- try {
35
- await refetchSessionHealthRef.current();
36
- }
37
- catch {
38
- // A failed check must not stop future session checks.
39
- }
40
- if (stopped) {
41
- return;
42
- }
43
- }
44
- timeout = assignTimeout();
45
- }, SESSION_WATCH_INTERVAL);
46
- };
47
- timeout = assignTimeout();
48
- return () => {
49
- stopped = true;
50
- if (timeout) {
51
- clearTimeout(timeout);
52
- timeout = null;
53
- }
54
- void listener.then((handle) => handle.remove()).catch(() => undefined);
55
- };
56
- }, []);
57
17
  const { gameLaunch, reset } = useGlobalStore(useShallow((ctx) => ({
58
18
  gameLaunch: ctx.gameLaunch,
59
19
  reset: ctx.reset,
@@ -1,6 +1,7 @@
1
1
  export declare const AUTH_CONFIG_COOKIE_NAME: string;
2
2
  export declare const ACCESS_TOKEN_COOKIE_NAME: string;
3
3
  export declare const REFRESH_TOKEN_COOKIE_NAME: string;
4
+ export declare const FINGERPRINT_COOKIE_NAME: string;
4
5
  export declare const DOMAIN_COOKIE_NAME: string;
5
6
  export declare const BTAG_COOKIE_NAME: string;
6
7
  export declare const CXD_STORAGE_KEY: string;
@@ -1,6 +1,7 @@
1
1
  export const AUTH_CONFIG_COOKIE_NAME = 'WebPortalAuthConfig';
2
2
  export const ACCESS_TOKEN_COOKIE_NAME = 'WebPortalAuthAccessToken';
3
3
  export const REFRESH_TOKEN_COOKIE_NAME = 'WebPortalAuthRefreshToken';
4
+ export const FINGERPRINT_COOKIE_NAME = 'WebPortalFingerprint';
4
5
  export const DOMAIN_COOKIE_NAME = 'WebPortalDomain';
5
6
  export const BTAG_COOKIE_NAME = 'WebPortalBtag';
6
7
  export const CXD_STORAGE_KEY = 'WebPortalCellxpertCxd';
@@ -1,10 +1,10 @@
1
1
  import { NextResponse } from 'next/server';
2
- import { ACCESS_TOKEN_COOKIE_NAME, AUTH_CONFIG_COOKIE_NAME, REFRESH_TOKEN_COOKIE_NAME, } from '../constants/index.js';
2
+ import { ACCESS_TOKEN_COOKIE_NAME, AUTH_CONFIG_COOKIE_NAME, FINGERPRINT_COOKIE_NAME, REFRESH_TOKEN_COOKIE_NAME, } from '../constants/index.js';
3
3
  import { destroySession } from '../services/auth.js';
4
4
  export async function deleteSession(request) {
5
5
  const accessToken = request.cookies.get(ACCESS_TOKEN_COOKIE_NAME)?.value;
6
6
  const authConfig = JSON.parse(request.cookies.get(AUTH_CONFIG_COOKIE_NAME)?.value ?? '{}');
7
- const authApiBaseUrl = authConfig.apiBaseUrl;
7
+ const authApiBaseUrl = authConfig.authApiBaseUrl;
8
8
  console.log('\n');
9
9
  console.log('[DESTROY SESSION]');
10
10
  console.log({ authApiBaseUrl });
@@ -21,5 +21,7 @@ export async function deleteSession(request) {
21
21
  });
22
22
  response.cookies.delete(ACCESS_TOKEN_COOKIE_NAME);
23
23
  response.cookies.delete(REFRESH_TOKEN_COOKIE_NAME);
24
+ response.cookies.delete(AUTH_CONFIG_COOKIE_NAME);
25
+ response.cookies.delete(FINGERPRINT_COOKIE_NAME);
24
26
  return response;
25
27
  }
@@ -1,12 +1,12 @@
1
1
  import { addDays, addMinutes, subMinutes } from 'date-fns';
2
2
  import { NextResponse } from 'next/server';
3
- import { ACCESS_TOKEN_COOKIE_NAME, AUTH_CONFIG_COOKIE_NAME, BTAG_COOKIE_NAME, DOMAIN_COOKIE_NAME, FINGERPRINT_HEADER_KEY, REFRESH_TOKEN_COOKIE_NAME, } from '../constants/index.js';
3
+ import { ACCESS_TOKEN_COOKIE_NAME, AUTH_CONFIG_COOKIE_NAME, BTAG_COOKIE_NAME, DOMAIN_COOKIE_NAME, FINGERPRINT_COOKIE_NAME, FINGERPRINT_HEADER_KEY, REFRESH_TOKEN_COOKIE_NAME, } from '../constants/index.js';
4
4
  import { refreshSession } from '../services/auth.js';
5
5
  export async function getSession(request) {
6
6
  const accessToken = request.cookies.get(ACCESS_TOKEN_COOKIE_NAME)?.value;
7
7
  const authConfig = JSON.parse(request.cookies.get(AUTH_CONFIG_COOKIE_NAME)?.value ?? '{}');
8
8
  const authVersion = authConfig.version;
9
- const authApiBaseUrl = authConfig.apiBaseUrl;
9
+ const authApiBaseUrl = authConfig.authApiBaseUrl;
10
10
  const fingerprint = request.headers.get(FINGERPRINT_HEADER_KEY);
11
11
  console.log('\n');
12
12
  console.log('[GET SESSION]');
@@ -59,6 +59,7 @@ export async function getSession(request) {
59
59
  response.cookies.delete(ACCESS_TOKEN_COOKIE_NAME);
60
60
  response.cookies.delete(REFRESH_TOKEN_COOKIE_NAME);
61
61
  response.cookies.delete(AUTH_CONFIG_COOKIE_NAME);
62
+ response.cookies.delete(FINGERPRINT_COOKIE_NAME);
62
63
  return response;
63
64
  }
64
65
  if (!accessToken || !isAccessTokenValid) {
@@ -105,10 +106,16 @@ export async function getSession(request) {
105
106
  sameSite: 'strict',
106
107
  });
107
108
  if (authVersion === 4) {
109
+ const _15d = subMinutes(addDays(new Date(), 15), 2);
110
+ response.cookies.set(FINGERPRINT_COOKIE_NAME, fingerprint ?? '', {
111
+ expires: _15d,
112
+ httpOnly: true,
113
+ sameSite: 'strict',
114
+ });
108
115
  response.cookies.set(REFRESH_TOKEN_COOKIE_NAME, authVersion === 4
109
116
  ? data.data.refreshToken
110
117
  : data.refreshToken, {
111
- expires: subMinutes(addDays(new Date(), 15), 2),
118
+ expires: _15d,
112
119
  httpOnly: true,
113
120
  sameSite: 'strict',
114
121
  });
@@ -131,6 +138,7 @@ export async function getSession(request) {
131
138
  });
132
139
  response.cookies.delete(REFRESH_TOKEN_COOKIE_NAME);
133
140
  response.cookies.delete(AUTH_CONFIG_COOKIE_NAME);
141
+ response.cookies.delete(FINGERPRINT_COOKIE_NAME);
134
142
  return response;
135
143
  }
136
144
  }
@@ -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, API_VERSION_HEADER_KEY, AUTH_API_BASE_URL_HEADER_KEY, AUTH_CONFIG_COOKIE_NAME, DOMAIN_HEADER_KEY, FINGERPRINT_HEADER_KEY, GOOGLE_FRAUD_DEFENSE_HEADER_KEY, PLATFORM_WEB_HEADER_KEY, RECAPTCHA_HEADER_KEY, REFRESH_TOKEN_COOKIE_NAME, SESSION_VERSION_HEADER_KEY, } from '../constants/index.js';
4
+ import { ACCESS_TOKEN_COOKIE_NAME, API_VERSION_HEADER_KEY, AUTH_API_BASE_URL_HEADER_KEY, AUTH_CONFIG_COOKIE_NAME, DOMAIN_HEADER_KEY, FINGERPRINT_COOKIE_NAME, FINGERPRINT_HEADER_KEY, GOOGLE_FRAUD_DEFENSE_HEADER_KEY, PLATFORM_WEB_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({
@@ -103,6 +103,11 @@ export async function postSession(request) {
103
103
  httpOnly: true,
104
104
  sameSite: 'strict',
105
105
  });
106
+ response.cookies.set(FINGERPRINT_COOKIE_NAME, fingerprint ?? '', {
107
+ expires: _15d,
108
+ httpOnly: true,
109
+ sameSite: 'strict',
110
+ });
106
111
  response.cookies.set(AUTH_CONFIG_COOKIE_NAME, JSON.stringify({
107
112
  version,
108
113
  authApiBaseUrl,
@@ -1,30 +1,58 @@
1
- import { addMinutes } from 'date-fns';
1
+ import { addDays, addMinutes, subMinutes } from 'date-fns';
2
2
  import { NextResponse, } from 'next/server';
3
- import { ACCESS_TOKEN_COOKIE_NAME, REFRESH_TOKEN_COOKIE_NAME, } from './constants/index.js';
3
+ import { ACCESS_TOKEN_COOKIE_NAME, AUTH_CONFIG_COOKIE_NAME, FINGERPRINT_COOKIE_NAME, FINGERPRINT_HEADER_KEY, REFRESH_TOKEN_COOKIE_NAME, } from './constants/index.js';
4
4
  import { refreshSession } from './services/auth.js';
5
5
  export const middleware = async (req) => {
6
6
  const accessToken = req.cookies.get(ACCESS_TOKEN_COOKIE_NAME)?.value;
7
7
  const refreshToken = req.cookies.get(REFRESH_TOKEN_COOKIE_NAME)?.value;
8
+ const authConfig = JSON.parse(req.cookies.get(AUTH_CONFIG_COOKIE_NAME)?.value ?? '{}');
9
+ const authVersion = authConfig.version;
10
+ const authApiBaseUrl = authConfig.authApiBaseUrl;
11
+ const fingerprint = req.cookies.get(FINGERPRINT_COOKIE_NAME)?.value;
8
12
  const res = NextResponse.next();
9
13
  const forwarded = req.headers.get('x-forwarded-for');
10
14
  const realIp = req.headers.get('x-real-ip');
11
15
  const ipaddress = forwarded || realIp || 'unknown';
16
+ console.log('\n');
17
+ console.log('[MIDDLEWARE]');
18
+ console.log({
19
+ authVersion,
20
+ authApiBaseUrl,
21
+ fingerprint,
22
+ accessToken,
23
+ refreshToken,
24
+ });
25
+ console.log('\n');
12
26
  if (!accessToken && refreshToken) {
13
27
  try {
14
28
  const data = await refreshSession({
15
29
  headers: {
16
30
  Authorization: `Bearer ${refreshToken}`,
17
31
  'x-forwarded-for': ipaddress,
32
+ ...(fingerprint && {
33
+ [FINGERPRINT_HEADER_KEY]: fingerprint,
34
+ }),
18
35
  },
19
- });
20
- res.cookies.set(ACCESS_TOKEN_COOKIE_NAME, data.accessToken, {
21
- expires: addMinutes(new Date(), 9),
36
+ }, authVersion, authApiBaseUrl);
37
+ res.cookies.set(ACCESS_TOKEN_COOKIE_NAME, authVersion === 4 ? data.data.accessToken : data.accessToken, {
38
+ expires: addMinutes(new Date(), authVersion === 4 ? 4 : 9),
22
39
  httpOnly: true,
23
40
  sameSite: 'strict',
24
41
  });
42
+ if (authVersion === 4) {
43
+ res.cookies.set(REFRESH_TOKEN_COOKIE_NAME, authVersion === 4
44
+ ? data.data.refreshToken
45
+ : data.refreshToken, {
46
+ expires: subMinutes(addDays(new Date(), 15), 2),
47
+ httpOnly: true,
48
+ sameSite: 'strict',
49
+ });
50
+ }
25
51
  }
26
52
  catch {
27
53
  res.cookies.delete(REFRESH_TOKEN_COOKIE_NAME);
54
+ res.cookies.delete(AUTH_CONFIG_COOKIE_NAME);
55
+ res.cookies.delete(FINGERPRINT_COOKIE_NAME);
28
56
  }
29
57
  }
30
58
  return res;