@opexa/portal-components 0.1.60 → 0.1.63

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 (75) hide show
  1. package/dist/client/hooks/platformGamesFallback.d.ts +6 -0
  2. package/dist/client/hooks/platformGamesFallback.js +64 -0
  3. package/dist/client/hooks/useGamesQuery.js +40 -6
  4. package/dist/client/hooks/useSignInMutation.d.ts +2 -1
  5. package/dist/client/hooks/useSignInMutation.js +3 -3
  6. package/dist/client/services/signIn.d.ts +2 -2
  7. package/dist/client/services/signIn.js +6 -2
  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/SignIn/CrazyWin/MobileNumberSignIn.js +1 -0
  11. package/dist/components/SignIn/CrazyWin/NameAndPasswordSignIn.js +1 -0
  12. package/dist/components/SignIn/HappyBingo/MobileNumberSignIn.js +1 -0
  13. package/dist/components/SignIn/HappyBingo/NameAndPasswordSignIn.js +1 -0
  14. package/dist/components/SignIn/MobileNumberSignIn.js +1 -0
  15. package/dist/components/SignIn/MobileNumberSignInternational.js +1 -0
  16. package/dist/components/SignIn/NameAndPasswordSignIn.js +1 -0
  17. package/dist/components/SignIn/SignIn.lazy.d.ts +7 -1
  18. package/dist/constants/GameProvider.js +1 -1
  19. package/dist/constants/HeaderKey.d.ts +2 -0
  20. package/dist/constants/HeaderKey.js +2 -0
  21. package/dist/handlers/postSession.js +6 -3
  22. package/dist/images/crazywin-game-providers/SEXYCASINO.png +0 -0
  23. package/dist/images/game-providers/SEXYCASINO.png +0 -0
  24. package/dist/schemas/forgotPasswordSchema.d.ts +8 -8
  25. package/dist/services/auth.d.ts +10 -3
  26. package/dist/services/auth.js +24 -16
  27. package/dist/services/wallet.d.ts +3 -1
  28. package/dist/ui/AlertDialog/AlertDialog.d.ts +88 -88
  29. package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +8 -8
  30. package/dist/ui/Avatar/Avatar.d.ts +9 -9
  31. package/dist/ui/Avatar/avatar.recipe.d.ts +3 -3
  32. package/dist/ui/Badge/Badge.d.ts +12 -12
  33. package/dist/ui/Badge/badge.anatomy.d.ts +1 -1
  34. package/dist/ui/Badge/badge.recipe.d.ts +3 -3
  35. package/dist/ui/Carousel/Carousel.d.ts +72 -72
  36. package/dist/ui/Carousel/carousel.recipe.d.ts +8 -8
  37. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  38. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  39. package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
  40. package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
  41. package/dist/ui/Combobox/Combobox.d.ts +42 -42
  42. package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
  43. package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
  44. package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
  45. package/dist/ui/Dialog/Dialog.d.ts +33 -33
  46. package/dist/ui/Dialog/dialog.recipe.d.ts +3 -3
  47. package/dist/ui/Drawer/Drawer.d.ts +33 -33
  48. package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
  49. package/dist/ui/Field/Field.d.ts +21 -21
  50. package/dist/ui/Field/field.recipe.d.ts +3 -3
  51. package/dist/ui/Menu/Menu.d.ts +144 -144
  52. package/dist/ui/Menu/menu.recipe.d.ts +8 -8
  53. package/dist/ui/NumberInput/NumberInput.d.ts +24 -24
  54. package/dist/ui/NumberInput/numberInput.recipe.d.ts +3 -3
  55. package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
  56. package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
  57. package/dist/ui/PinInput/PinInput.d.ts +12 -12
  58. package/dist/ui/PinInput/pinInput.recipe.d.ts +3 -3
  59. package/dist/ui/Popover/Popover.d.ts +121 -121
  60. package/dist/ui/Popover/popover.recipe.d.ts +11 -11
  61. package/dist/ui/Progress/Progress.d.ts +27 -27
  62. package/dist/ui/Progress/progress.recipe.d.ts +3 -3
  63. package/dist/ui/QrCode/QrCode.d.ts +25 -25
  64. package/dist/ui/QrCode/qrCode.recipe.d.ts +5 -5
  65. package/dist/ui/SegmentGroup/SegmentGroup.d.ts +18 -18
  66. package/dist/ui/SegmentGroup/segmentGroup.recipe.d.ts +3 -3
  67. package/dist/ui/Select/Select.d.ts +45 -45
  68. package/dist/ui/Select/select.recipe.d.ts +3 -3
  69. package/dist/ui/Table/Table.d.ts +21 -21
  70. package/dist/ui/Table/table.anatomy.d.ts +1 -1
  71. package/dist/ui/Table/table.recipe.d.ts +3 -3
  72. package/dist/utils/getProviderData.js +1 -1
  73. package/dist/utils/queryKeys.d.ts +1 -0
  74. package/dist/utils/queryKeys.js +1 -0
  75. package/package.json +1 -1
@@ -0,0 +1,6 @@
1
+ import type { GamesInput__Next } from '../../services/cmsPortal';
2
+ import type { PlatformGamesInput } from '../../services/wallet';
3
+ import type { Game, PaginatedQueryResult, PlatformGame } from '../../types';
4
+ export declare const mapGamesInputToPlatformGamesInput: (input?: GamesInput__Next) => PlatformGamesInput;
5
+ export declare const getPlatformGameFallbackImage: (provider: string) => string;
6
+ export declare const normalizePlatformGames: (data: PaginatedQueryResult<PlatformGame>) => PaginatedQueryResult<Game>;
@@ -0,0 +1,64 @@
1
+ import { PLATFORM_ID, SITE_ID, STATIC_ENDPOINT } from '../../constants/index.js';
2
+ export const mapGamesInputToPlatformGamesInput = (input) => {
3
+ const filter = input?.filter;
4
+ return {
5
+ ...(input?.first != null && { first: input.first }),
6
+ ...(input?.after != null && { after: input.after }),
7
+ filter: {
8
+ ...(filter?.reference && { id: filter.reference }),
9
+ ...(filter?.type && { type: filter.type }),
10
+ ...(filter?.provider && { provider: filter.provider }),
11
+ status: { equal: 'ACTIVE' },
12
+ hidden: { equal: false },
13
+ },
14
+ };
15
+ };
16
+ export const getPlatformGameFallbackImage = (provider) => {
17
+ const slug = provider.toLocaleLowerCase();
18
+ return `${STATIC_ENDPOINT}/images/${slug}/thumbnail-${slug}.webp`;
19
+ };
20
+ const normalizePlatformGame = (platformGame, cursor) => {
21
+ const name = platformGame.displayName ?? platformGame.name;
22
+ if (platformGame.hidden ||
23
+ platformGame.status !== 'ACTIVE' ||
24
+ !name ||
25
+ !platformGame.provider ||
26
+ !platformGame.type) {
27
+ return null;
28
+ }
29
+ return {
30
+ id: platformGame.id,
31
+ game: platformGame.id,
32
+ name,
33
+ type: platformGame.type,
34
+ provider: platformGame.provider,
35
+ tags: [],
36
+ rank: '0',
37
+ site: SITE_ID,
38
+ image: getPlatformGameFallbackImage(platformGame.provider),
39
+ cursor,
40
+ status: 'ACTIVE',
41
+ platform: PLATFORM_ID,
42
+ reference: platformGame.id,
43
+ dateTimeCreated: '',
44
+ dateTimeLastUpdated: '',
45
+ favorite: false,
46
+ hidden: false,
47
+ };
48
+ };
49
+ export const normalizePlatformGames = (data) => {
50
+ const edges = data.edges.flatMap((edge) => {
51
+ const game = normalizePlatformGame(edge.node, edge.cursor);
52
+ return game ? [{ cursor: edge.cursor, node: game }] : [];
53
+ });
54
+ return {
55
+ edges,
56
+ totalCount: data.totalCount,
57
+ pageInfo: {
58
+ hasNextPage: Boolean(data.pageInfo.hasNextPage && data.pageInfo.endCursor),
59
+ endCursor: data.pageInfo.hasNextPage
60
+ ? data.pageInfo.endCursor
61
+ : undefined,
62
+ },
63
+ };
64
+ };
@@ -1,25 +1,59 @@
1
1
  import { useInfiniteQuery } from '@tanstack/react-query';
2
2
  import { getGames__next, } from '../../services/cmsPortal.js';
3
- import { getGamesQueryKey } from '../../utils/queryKeys.js';
3
+ import { getPlatformGames } from '../../services/wallet.js';
4
+ import { getGamesPlatformFallbackQueryKey, getGamesQueryKey, } from '../../utils/queryKeys.js';
5
+ import { mapGamesInputToPlatformGamesInput, normalizePlatformGames, } from './platformGamesFallback.js';
6
+ import { useFeatureFlag } from './useFeatureFlag.js';
7
+ const parsePageParam = (pageParam) => {
8
+ if (pageParam?.startsWith('platform:')) {
9
+ return { after: pageParam.slice('platform:'.length), source: 'platform' };
10
+ }
11
+ if (pageParam?.startsWith('cms:')) {
12
+ return { after: pageParam.slice('cms:'.length), source: 'cms' };
13
+ }
14
+ return { after: pageParam, source: 'cms' };
15
+ };
4
16
  export const useGamesQuery = (input, config) => {
17
+ const featureFlag = useFeatureFlag();
18
+ const shouldUsePlatformGames = featureFlag.enabled;
5
19
  return useInfiniteQuery({
6
20
  refetchOnMount: false,
7
21
  refetchOnReconnect: false,
8
22
  refetchOnWindowFocus: false,
9
23
  ...config,
10
- queryKey: getGamesQueryKey(input),
11
- queryFn: ({ pageParam, signal }) => {
12
- return getGames__next({
24
+ queryKey: shouldUsePlatformGames
25
+ ? getGamesPlatformFallbackQueryKey(input)
26
+ : getGamesQueryKey(input),
27
+ queryFn: async ({ pageParam, signal }) => {
28
+ const { after, source } = parsePageParam(pageParam);
29
+ if (source === 'platform') {
30
+ const page = await getPlatformGames(mapGamesInputToPlatformGamesInput({ ...input, after }), { signal });
31
+ return { ...normalizePlatformGames(page), __source: 'platform' };
32
+ }
33
+ const page = await getGames__next({
13
34
  ...input,
14
- after: pageParam,
35
+ after,
15
36
  }, {
16
37
  signal,
17
38
  });
39
+ signal.throwIfAborted();
40
+ if (!pageParam && shouldUsePlatformGames && page.edges.length === 0) {
41
+ const platformPage = await getPlatformGames(mapGamesInputToPlatformGamesInput(input), { signal });
42
+ return {
43
+ ...normalizePlatformGames(platformPage),
44
+ __source: 'platform',
45
+ };
46
+ }
47
+ return { ...page, __source: 'cms' };
18
48
  },
19
49
  initialPageParam: undefined,
20
50
  getNextPageParam(lastPage) {
21
51
  if (lastPage?.pageInfo?.hasNextPage) {
22
- return lastPage?.pageInfo?.endCursor;
52
+ const after = lastPage.pageInfo.endCursor;
53
+ if (after) {
54
+ const source = lastPage.__source ?? 'cms';
55
+ return `${source}:${after}`;
56
+ }
23
57
  }
24
58
  },
25
59
  });
@@ -1,8 +1,9 @@
1
1
  import { type UseMutationResult } from '@tanstack/react-query';
2
- import type { VersionSession } from '../../services/auth';
2
+ import type { ApiVersion, VersionSession } from '../../services/auth';
3
3
  import type { Authenticator, MutationConfig } from '../../types';
4
4
  import { type SignInInput } from '../services/signIn';
5
5
  export interface UseSignInMutationOptions extends MutationConfig<Authenticator | null, SignInInput> {
6
6
  versionSession?: VersionSession;
7
+ version?: ApiVersion;
7
8
  }
8
9
  export declare const useSignInMutation: (options?: UseSignInMutationOptions) => UseMutationResult<Authenticator | null, Error, SignInInput>;
@@ -12,7 +12,7 @@ import { useRecaptcha } from './useRecaptcha.js';
12
12
  export const useSignInMutation = (options) => {
13
13
  const queryClient = getQueryClient();
14
14
  const { executeRecaptcha, isGoogleFraudDefense } = useRecaptcha();
15
- const { versionSession, ...config } = options ?? {};
15
+ const { versionSession, version = 1, ...config } = options ?? {};
16
16
  return useMutation({
17
17
  ...config,
18
18
  mutationKey: getSignInMutationKey(),
@@ -20,7 +20,7 @@ export const useSignInMutation = (options) => {
20
20
  const session = await getSession();
21
21
  const token = await executeRecaptcha('submit');
22
22
  const isInplayEligible = input.type === 'NAME_AND_PASSWORD' || input.type === 'MOBILE_NUMBER';
23
- const fingerprint = versionSession === 'Inplay' && isInplayEligible
23
+ const fingerprint = (versionSession === 'Inplay' || version !== 1) && isInplayEligible
24
24
  ? await getFingerprint()
25
25
  : null;
26
26
  const recaptchaHeaderKey = isGoogleFraudDefense
@@ -41,7 +41,7 @@ export const useSignInMutation = (options) => {
41
41
  ? { Channel: 'ANDROID' }
42
42
  : { Channel: 'IOS' }),
43
43
  },
44
- }, versionSession);
44
+ }, versionSession, version);
45
45
  const authenticator = versionSession === 'Inplay' && isInplayEligible
46
46
  ? await pollSignIn(signInOnce)
47
47
  : await signInOnce();
@@ -1,5 +1,5 @@
1
- import type { CreateSessionInput, VersionSession } from '../../services/auth';
1
+ import type { ApiVersion, CreateSessionInput, VersionSession } from '../../services/auth';
2
2
  import { type HttpRequestOptions } from '../../services/httpRequest';
3
3
  import type { Authenticator } from '../../types';
4
4
  export type SignInInput = CreateSessionInput;
5
- export declare function signIn(input: SignInInput, options?: HttpRequestOptions, versionSession?: VersionSession): Promise<Authenticator | null>;
5
+ export declare function signIn(input: SignInInput, options?: HttpRequestOptions, versionSession?: VersionSession, version?: ApiVersion): Promise<Authenticator | null>;
@@ -1,10 +1,14 @@
1
1
  import { Capacitor } from '@capacitor/core';
2
- import { SESSION_VERSION_HEADER_KEY } from '../../constants/index.js';
2
+ import { API_VERSION_HEADER_KEY, PLATFORM_WEB_HEADER_KEY, SESSION_VERSION_HEADER_KEY, } from '../../constants/index.js';
3
3
  import { httpRequest, } from '../../services/httpRequest.js';
4
4
  const platform = Capacitor.getPlatform();
5
- export async function signIn(input, options, versionSession = 'default') {
5
+ export async function signIn(input, options, versionSession = 'default', version = 1) {
6
6
  const headers = new Headers(options?.headers);
7
7
  headers.set(SESSION_VERSION_HEADER_KEY, versionSession);
8
+ headers.set(API_VERSION_HEADER_KEY, String(version));
9
+ if (version === 4 && platform === 'web') {
10
+ headers.set(PLATFORM_WEB_HEADER_KEY, 'true');
11
+ }
8
12
  const res = await httpRequest.json('/api/sessions', {
9
13
  ...options,
10
14
  headers,
@@ -1,6 +1,6 @@
1
1
  export declare const OnlineBankDepositContext: (props: {
2
2
  value: {
3
- view: "form" | "vca";
3
+ view: "vca" | "form";
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: "form" | "vca";
16
+ view: "vca" | "form";
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: "form" | "vca";
4
+ view: "vca" | "form";
5
5
  status: "waiting" | "failed" | "processing" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
6
6
  verify: () => void;
7
7
  reset: () => void;
@@ -46,6 +46,7 @@ export function MobileNumberSignIn() {
46
46
  })));
47
47
  const signInMutation = useSignInMutation({
48
48
  versionSession: signInProps.versionSession,
49
+ version: signInProps.version,
49
50
  onSuccess: async () => {
50
51
  step1Form.reset();
51
52
  step2Form.reset();
@@ -46,6 +46,7 @@ export function NameAndPasswordSignIn() {
46
46
  })));
47
47
  const signInMutation = useSignInMutation({
48
48
  versionSession: signInProps.versionSession,
49
+ version: signInProps.version,
49
50
  onSuccess: async (authenticator) => {
50
51
  if (authenticator) {
51
52
  context.setStep(2);
@@ -47,6 +47,7 @@ export function MobileNumberSignIn() {
47
47
  })));
48
48
  const signInMutation = useSignInMutation({
49
49
  versionSession: signInProps.versionSession,
50
+ version: signInProps.version,
50
51
  onSuccess: async () => {
51
52
  step1Form.reset();
52
53
  step2Form.reset();
@@ -43,6 +43,7 @@ export function NameAndPasswordSignIn() {
43
43
  })));
44
44
  const signInMutation = useSignInMutation({
45
45
  versionSession: signInProps.versionSession,
46
+ version: signInProps.version,
46
47
  onSuccess: async (authenticator) => {
47
48
  if (authenticator) {
48
49
  context.setStep(2);
@@ -54,6 +54,7 @@ export function MobileNumberSignIn() {
54
54
  })));
55
55
  const signInMutation = useSignInMutation({
56
56
  versionSession: signInProps.versionSession,
57
+ version: signInProps.version,
57
58
  onSuccess: async () => {
58
59
  step1Form.reset();
59
60
  step2Form.reset();
@@ -82,6 +82,7 @@ export function MobileNumberSignInInternational() {
82
82
  })));
83
83
  const signInMutation = useSignInMutation({
84
84
  versionSession: signInProps.versionSession,
85
+ version: signInProps.version,
85
86
  onSuccess: async () => {
86
87
  step1Form.reset();
87
88
  step2Form.reset();
@@ -56,6 +56,7 @@ export function NameAndPasswordSignIn() {
56
56
  const [formType, setFormType] = useState('NAME_AND_PASSWORD');
57
57
  const signInMutation = useSignInMutation({
58
58
  versionSession: signInProps.versionSession,
59
+ version: signInProps.version,
59
60
  onSuccess: async (authenticator) => {
60
61
  if (authenticator) {
61
62
  context.setStep(2);
@@ -1,6 +1,6 @@
1
1
  import { type ImageProps } from 'next/image';
2
2
  import { type ReactNode } from 'react';
3
- import type { VersionSession } from '../../services/auth';
3
+ import type { ApiVersion, VersionSession } from '../../services/auth';
4
4
  import type { CountryCode } from '../../utils/countries/types';
5
5
  import { type UseSignInProps } from './useSignIn';
6
6
  export interface ClassNameEntries {
@@ -31,6 +31,12 @@ export interface SignInProps extends UseSignInProps {
31
31
  * - `Inplay`: `${AUTH_ENDPOINT}/v3/inplay/sessions`
32
32
  */
33
33
  versionSession?: VersionSession;
34
+ /**
35
+ * Mirrors portal-sdk's `sdk.signIn` version argument.
36
+ * - `1` (default): legacy flat-response session endpoint
37
+ * - `4`: cookie/fingerprint-aware endpoint (e.g. `/v4/sessions`)
38
+ */
39
+ version?: ApiVersion;
34
40
  fingerprint?: () => Promise<string | null> | string | null;
35
41
  }
36
42
  export declare function SignIn(props: SignInProps): import("react/jsx-runtime").JSX.Element;
@@ -40,7 +40,7 @@ import rtg from '../images/game-providers/RTG.png';
40
40
  import rubyPlay from '../images/game-providers/RUBY_PLAY.png';
41
41
  import saba from '../images/game-providers/SABA.png';
42
42
  import sagaming from '../images/game-providers/SAGAMING.png';
43
- import sexycasino from '../images/game-providers/SEXYCASINO.webp';
43
+ import sexycasino from '../images/game-providers/SEXYCASINO.png';
44
44
  import spadegaming from '../images/game-providers/SPADEGAMING.png';
45
45
  import spinix from '../images/game-providers/SPINIX.png';
46
46
  import spribe from '../images/game-providers/SPRIBE.png';
@@ -2,5 +2,7 @@ export declare const RECAPTCHA_HEADER_KEY: string;
2
2
  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
+ export declare const API_VERSION_HEADER_KEY: string;
6
+ export declare const PLATFORM_WEB_HEADER_KEY: string;
5
7
  export declare const FINGERPRINT_HEADER_KEY: string;
6
8
  export declare const GOOGLE_FRAUD_DEFENSE_HEADER_KEY: string;
@@ -2,5 +2,7 @@ export const RECAPTCHA_HEADER_KEY = 'Google-Recaptcha-Response';
2
2
  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
+ export const API_VERSION_HEADER_KEY = 'X-Api-Version';
6
+ export const PLATFORM_WEB_HEADER_KEY = 'X-Platform-Web';
5
7
  export const FINGERPRINT_HEADER_KEY = 'Fingerprint';
6
8
  export const GOOGLE_FRAUD_DEFENSE_HEADER_KEY = 'X-Recaptcha-Token';
@@ -1,8 +1,8 @@
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, GOOGLE_FRAUD_DEFENSE_HEADER_KEY, RECAPTCHA_HEADER_KEY, REFRESH_TOKEN_COOKIE_NAME, SESSION_VERSION_HEADER_KEY, } from '../constants/index.js';
5
- import { createSession } from '../services/auth.js';
4
+ import { ACCESS_TOKEN_COOKIE_NAME, API_VERSION_HEADER_KEY, 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';
5
+ import { createSession, } from '../services/auth.js';
6
6
  const CreateSessionDefinition = z.union([
7
7
  z.object({
8
8
  type: z.literal('NAME_AND_PASSWORD'),
@@ -44,6 +44,8 @@ export async function postSession(request) {
44
44
  const fingerprint = request.headers.get(FINGERPRINT_HEADER_KEY);
45
45
  const versionSessionHeader = request.headers.get(SESSION_VERSION_HEADER_KEY);
46
46
  const versionSession = versionSessionHeader === 'Inplay' ? 'Inplay' : 'default';
47
+ const version = request.headers.get(API_VERSION_HEADER_KEY) === '4' ? 4 : 1;
48
+ const isWeb = request.headers.get(PLATFORM_WEB_HEADER_KEY) === 'true';
47
49
  try {
48
50
  const googleFraudDefense = request.headers.get(GOOGLE_FRAUD_DEFENSE_HEADER_KEY);
49
51
  const recaptchaToken = googleFraudDefense ?? recaptcha;
@@ -65,8 +67,9 @@ export async function postSession(request) {
65
67
  'X-Forwarded-For': ipAddress,
66
68
  }),
67
69
  ...(channel && { Channel: channel }),
70
+ ...(isWeb && { [PLATFORM_WEB_HEADER_KEY]: 'true' }),
68
71
  },
69
- }, versionSession);
72
+ }, versionSession, version);
70
73
  if (res.authenticator) {
71
74
  return NextResponse.json({
72
75
  ok: true,
@@ -8,24 +8,24 @@ export declare const createForgotPasswordSchema: (mobileNumberParser: MobileNumb
8
8
  mobileNumber: z.ZodEffects<z.ZodString, string, string>;
9
9
  verificationCode: z.ZodEffects<z.ZodString, string, string>;
10
10
  }, "strip", z.ZodTypeAny, {
11
- password: string;
12
- verificationCode: string;
13
11
  mobileNumber: string;
12
+ verificationCode: string;
13
+ password: string;
14
14
  confirmPassword: string;
15
15
  }, {
16
- password: string;
17
- verificationCode: string;
18
16
  mobileNumber: string;
17
+ verificationCode: string;
18
+ password: string;
19
19
  confirmPassword: string;
20
20
  }>, {
21
- password: string;
22
- verificationCode: string;
23
21
  mobileNumber: string;
22
+ verificationCode: string;
23
+ password: string;
24
24
  confirmPassword: string;
25
25
  }, {
26
- password: string;
27
- verificationCode: string;
28
26
  mobileNumber: string;
27
+ verificationCode: string;
28
+ password: string;
29
29
  confirmPassword: string;
30
30
  }>;
31
31
  export type ForgotPasswordSchema = z.infer<ReturnType<typeof createForgotPasswordSchema>>;
@@ -24,10 +24,17 @@ export interface CreateSessionInput__Token {
24
24
  export type CreateSessionInput = CreateSessionInput__UsernameAndPassword | CreateSessionInput__MobileNumber | CreateSessionInput__Maya | CreateSessionInput__Token;
25
25
  /**
26
26
  * Controls which auth endpoint is used to create a session.
27
- * - `default` -> `${AUTH_ENDPOINT}/sessions`
28
- * - `Inplay` -> `${AUTH_ENDPOINT}/v3/inplay/sessions`
27
+ * - `default` -> `${AUTH_ENDPOINT}/sessions` (or `/v3`/`/v4/sessions`, see `ApiVersion`)
28
+ * - `Inplay` -> `${AUTH_ENDPOINT}/v3/inplay/sessions` (no v4 variant exists)
29
29
  */
30
30
  export type VersionSession = 'default' | 'Inplay';
31
+ /**
32
+ * Applies `AuthService.createSession` version argument:
33
+ * - `1` -> the legacy flat-response endpoint
34
+ * - `3` / `4` -> fingerprint-aware endpoints (wrapped `{ data }` response);
35
+ * `4` is additionally cookie-aware for web sign-ins
36
+ */
37
+ export type ApiVersion = 1 | 3 | 4;
31
38
  export interface CreateSessionTwoFactorAuthDisabledMutation {
32
39
  session: {
33
40
  id: string;
@@ -52,7 +59,7 @@ export interface CreateSessionTwoFactorAuthEnabledMutation {
52
59
  authenticator: Authenticator;
53
60
  }
54
61
  export type CreateSessionMutation = CreateSessionTwoFactorAuthDisabledMutation | CreateSessionTwoFactorAuthEnabledMutation;
55
- export declare function createSession(input: CreateSessionInput, options?: HttpRequestOptions, versionSession?: VersionSession): Promise<CreateSessionMutation>;
62
+ export declare function createSession(input: CreateSessionInput, options?: HttpRequestOptions, versionSession?: VersionSession, version?: ApiVersion): Promise<CreateSessionMutation>;
56
63
  export declare function createSessionLibangan(input: CreateSessionInput__Libangan, options?: HttpRequestOptions): Promise<{
57
64
  session: {
58
65
  id: string;
@@ -1,11 +1,13 @@
1
- import { AUTH_ENDPOINT, FINGERPRINT_HEADER_KEY } from '../constants/index.js';
1
+ import { AUTH_ENDPOINT, FINGERPRINT_HEADER_KEY, PLATFORM_WEB_HEADER_KEY, } from '../constants/index.js';
2
2
  import { httpRequest } from './httpRequest.js';
3
3
  import { sha256 } from './sha256.js';
4
- const SESSION_ENDPOINTS = {
5
- default: '/sessions',
6
- Inplay: '/v3/inplay/sessions',
7
- };
8
- export async function createSession(input, options, versionSession = 'default') {
4
+ function getSessionEndpoint(versionSession, version) {
5
+ if (versionSession === 'Inplay')
6
+ return '/v3/inplay/sessions';
7
+ return version !== 1 ? `/v${version}/sessions` : '/sessions';
8
+ }
9
+ export async function createSession(input, options, versionSession = 'default', version = 1) {
10
+ const isWeb = new Headers(options?.headers).get(PLATFORM_WEB_HEADER_KEY) === 'true';
9
11
  const headers = new Headers();
10
12
  if (input.type === 'NAME_AND_PASSWORD') {
11
13
  const password = versionSession === 'Inplay'
@@ -37,21 +39,27 @@ export async function createSession(input, options, versionSession = 'default')
37
39
  const effectiveVersionSession = input.type === 'NAME_AND_PASSWORD' || input.type === 'MOBILE_NUMBER'
38
40
  ? versionSession
39
41
  : 'default';
40
- if (effectiveVersionSession !== 'Inplay' ||
41
- (input.type !== 'NAME_AND_PASSWORD' && input.type !== 'MOBILE_NUMBER')) {
42
+ headers.delete(PLATFORM_WEB_HEADER_KEY);
43
+ const requiresFingerprint = (effectiveVersionSession === 'Inplay' || version !== 1) &&
44
+ (input.type === 'NAME_AND_PASSWORD' || input.type === 'MOBILE_NUMBER');
45
+ if (!requiresFingerprint) {
42
46
  headers.delete(FINGERPRINT_HEADER_KEY);
43
47
  }
48
+ // Version 4 mirrors portal-sdk's `AuthService`: the auth server relies on
49
+ // its own cookie for web sign-ins, signalled via `?type=web`.
50
+ const queryParam = version === 4 && isWeb ? '?type=web' : '';
51
+ const endpoint = getSessionEndpoint(effectiveVersionSession, version);
44
52
  try {
45
- // The Inplay `/v3/inplay/sessions` endpoint wraps its payload in
46
- // `{ data: { ... } }` (same shape as `/v2/sessions`), while the
47
- // default `/sessions` endpoint returns the flat shape directly.
48
- // Unwrap the Inplay response so callers can treat both consistently
49
- // via the existing `CreateSessionMutation` union.
50
- if (effectiveVersionSession === 'Inplay') {
51
- const wrapped = await httpRequest.json(`${AUTH_ENDPOINT}${SESSION_ENDPOINTS[effectiveVersionSession]}`, {
53
+ // v1 against the default endpoint returns the payload flat; every
54
+ // other combination (Inplay, or version 3/4) wraps it in `{ data: { ... } }`.
55
+ // Unwrap those so callers can treat both consistently via the existing
56
+ // `CreateSessionMutation` union.
57
+ if (effectiveVersionSession === 'Inplay' || version !== 1) {
58
+ const wrapped = await httpRequest.json(`${AUTH_ENDPOINT}${endpoint}${queryParam}`, {
52
59
  ...options,
53
60
  method: 'POST',
54
61
  headers,
62
+ ...(version === 4 && { credentials: 'include' }),
55
63
  });
56
64
  if (wrapped.data.authenticator) {
57
65
  return {
@@ -64,7 +72,7 @@ export async function createSession(input, options, versionSession = 'default')
64
72
  refreshToken: wrapped.data.refreshToken,
65
73
  };
66
74
  }
67
- return await httpRequest.json(`${AUTH_ENDPOINT}${SESSION_ENDPOINTS[effectiveVersionSession]}`, {
75
+ return await httpRequest.json(`${AUTH_ENDPOINT}${endpoint}`, {
68
76
  ...options,
69
77
  method: 'POST',
70
78
  headers,
@@ -1,5 +1,5 @@
1
1
  import type { Simplify, SimplifyDeep } from 'type-fest';
2
- import type { BooleanFilterField, Bonus, Cashback, CashbackBonus, DateFilterField, Deposit, EnumFilterField, GameProvider, GameSession, GameType, InstapayBank, MayaSession, ObjectIdFilterField, PaginatedQueryResult, PlatformGame, PointsWallet, Promo, PromoType, StringFilterField, Wallet } from '../types';
2
+ import type { BooleanFilterField, Bonus, Cashback, CashbackBonus, DateFilterField, Deposit, EnumFilterField, GameProvider, GameSession, GameStatus, GameType, InstapayBank, MayaSession, ObjectIdFilterField, PaginatedQueryResult, PlatformGame, PointsWallet, Promo, PromoType, StringFilterField, Wallet } from '../types';
3
3
  import { type GraphQLRequestOptions } from './graphqlRequest';
4
4
  export interface PromosQuery {
5
5
  promos: Promo[];
@@ -711,6 +711,8 @@ export interface PlatformGamesQueryVariables {
711
711
  provider?: EnumFilterField<GameProvider>;
712
712
  hasFreeBet?: BooleanFilterField;
713
713
  hasJackpot?: BooleanFilterField;
714
+ status?: EnumFilterField<GameStatus>;
715
+ hidden?: BooleanFilterField;
714
716
  };
715
717
  }
716
718
  export interface PlatformGamesQuery {