@opexa/portal-components 0.0.1121 → 0.0.1123

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 (91) hide show
  1. package/dist/__tests__/utils/mocks.d.ts +1 -1
  2. package/dist/client/hooks/useSignInMutation.d.ts +7 -2
  3. package/dist/client/hooks/useSignInMutation.js +3 -2
  4. package/dist/client/services/signIn.d.ts +2 -2
  5. package/dist/client/services/signIn.js +5 -1
  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/KYC/KYCReview.js +4 -33
  13. package/dist/components/SignIn/CrazyWin/MobileNumberSignIn.js +1 -0
  14. package/dist/components/SignIn/CrazyWin/NameAndPasswordSignIn.js +1 -0
  15. package/dist/components/SignIn/HappyBingo/MobileNumberSignIn.js +1 -0
  16. package/dist/components/SignIn/HappyBingo/NameAndPasswordSignIn.js +1 -0
  17. package/dist/components/SignIn/MobileNumberSignIn.js +1 -0
  18. package/dist/components/SignIn/MobileNumberSignInternational.js +1 -0
  19. package/dist/components/SignIn/NameAndPasswordSignIn.js +1 -0
  20. package/dist/components/SignIn/SignIn.lazy.d.ts +7 -0
  21. package/dist/components/SignIn/useSignIn.d.ts +2 -0
  22. package/dist/components/SignIn/useSignIn.js +11 -1
  23. package/dist/constants/HeaderKey.d.ts +1 -0
  24. package/dist/constants/HeaderKey.js +1 -0
  25. package/dist/handlers/postSession.js +4 -2
  26. package/dist/schemas/forgotPasswordSchema.d.ts +8 -8
  27. package/dist/services/auth.d.ts +7 -1
  28. package/dist/services/auth.js +6 -2
  29. package/dist/ui/AlertDialog/AlertDialog.d.ts +88 -88
  30. package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +8 -8
  31. package/dist/ui/Avatar/Avatar.d.ts +9 -9
  32. package/dist/ui/Avatar/avatar.recipe.d.ts +3 -3
  33. package/dist/ui/Badge/Badge.d.ts +12 -12
  34. package/dist/ui/Badge/badge.anatomy.d.ts +1 -1
  35. package/dist/ui/Badge/badge.recipe.d.ts +3 -3
  36. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  37. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  38. package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
  39. package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
  40. package/dist/ui/Collapsible/Collapsible.d.ts +20 -20
  41. package/dist/ui/Collapsible/collapsible.recipe.d.ts +5 -5
  42. package/dist/ui/Combobox/Combobox.d.ts +42 -42
  43. package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
  44. package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
  45. package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
  46. package/dist/ui/Dialog/Dialog.d.ts +33 -33
  47. package/dist/ui/Dialog/dialog.recipe.d.ts +3 -3
  48. package/dist/ui/Drawer/Drawer.d.ts +33 -33
  49. package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
  50. package/dist/ui/Field/Field.d.ts +21 -21
  51. package/dist/ui/Field/field.recipe.d.ts +3 -3
  52. package/dist/ui/Menu/Menu.d.ts +252 -252
  53. package/dist/ui/Menu/menu.recipe.d.ts +14 -14
  54. package/dist/ui/NumberInput/NumberInput.d.ts +24 -24
  55. package/dist/ui/NumberInput/numberInput.recipe.d.ts +3 -3
  56. package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
  57. package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
  58. package/dist/ui/PinInput/PinInput.d.ts +12 -12
  59. package/dist/ui/PinInput/pinInput.recipe.d.ts +3 -3
  60. package/dist/ui/Popover/Popover.d.ts +88 -88
  61. package/dist/ui/Popover/popover.recipe.d.ts +8 -8
  62. package/dist/ui/Progress/Progress.d.ts +27 -27
  63. package/dist/ui/Progress/progress.recipe.d.ts +3 -3
  64. package/dist/ui/QrCode/QrCode.d.ts +25 -25
  65. package/dist/ui/QrCode/qrCode.recipe.d.ts +5 -5
  66. package/dist/ui/SegmentGroup/SegmentGroup.d.ts +18 -18
  67. package/dist/ui/SegmentGroup/segmentGroup.recipe.d.ts +3 -3
  68. package/dist/ui/Select/Select.d.ts +45 -45
  69. package/dist/ui/Select/select.recipe.d.ts +3 -3
  70. package/dist/ui/Table/Table.d.ts +21 -21
  71. package/dist/ui/Table/table.anatomy.d.ts +1 -1
  72. package/dist/ui/Table/table.recipe.d.ts +3 -3
  73. package/dist/ui/Tabs/Tabs.d.ts +15 -15
  74. package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
  75. package/package.json +1 -1
  76. package/dist/client/hooks/useVerifyMobileNumber.d.ts +0 -3
  77. package/dist/client/hooks/useVerifyMobileNumber.js +0 -20
  78. package/dist/components/DepositWithdrawal/Deposit/AurixPayPayMayaDeposit/AurixPayGrabPayDeposit.d.ts +0 -1
  79. package/dist/components/DepositWithdrawal/Deposit/AurixPayPayMayaDeposit/AurixPayGrabPayDeposit.js +0 -241
  80. package/dist/components/SingleSignOn/SingleSignOn.d.ts +0 -4
  81. package/dist/components/SingleSignOn/SingleSignOn.js +0 -185
  82. package/dist/components/SingleSignOn/index.d.ts +0 -1
  83. package/dist/components/SingleSignOn/index.js +0 -1
  84. package/dist/components/UpdateMobileNumber/UpdateMobileNumber.d.ts +0 -3
  85. package/dist/components/UpdateMobileNumber/UpdateMobileNumber.js +0 -141
  86. package/dist/components/UpdateMobileNumber/index.d.ts +0 -1
  87. package/dist/components/UpdateMobileNumber/index.js +0 -1
  88. package/dist/lib/components/UpdateMobileNumber/UpdateMobileNumber.d.ts +0 -1
  89. package/dist/lib/components/UpdateMobileNumber/UpdateMobileNumber.js +0 -154
  90. package/dist/lib/components/UpdateMobileNumber/index.d.ts +0 -1
  91. package/dist/lib/components/UpdateMobileNumber/index.js +0 -1
@@ -165,7 +165,7 @@ export declare function createMockSignOutMutation(): {
165
165
  */
166
166
  export declare function createMockMemberVerificationQuery(status?: 'VERIFIED' | 'PENDING' | 'REJECTED' | 'MISSING' | 'APPROVED', isLoading?: boolean): {
167
167
  data: {
168
- status: "VERIFIED" | "PENDING" | "REJECTED" | "MISSING" | "APPROVED";
168
+ status: "PENDING" | "APPROVED" | "REJECTED" | "VERIFIED" | "MISSING";
169
169
  };
170
170
  isLoading: boolean;
171
171
  isError: boolean;
@@ -1,3 +1,8 @@
1
- import type { Authenticator, Mutation } from '../../types';
1
+ import { type UseMutationResult } from '@tanstack/react-query';
2
+ import type { VersionSession } from '../../services/auth';
3
+ import type { Authenticator, MutationConfig } from '../../types';
2
4
  import { type SignInInput } from '../services/signIn';
3
- export declare const useSignInMutation: Mutation<Authenticator | null, SignInInput>;
5
+ export interface UseSignInMutationOptions extends MutationConfig<Authenticator | null, SignInInput> {
6
+ versionSession?: VersionSession;
7
+ }
8
+ export declare const useSignInMutation: (options?: UseSignInMutationOptions) => UseMutationResult<Authenticator | null, Error, SignInInput>;
@@ -7,9 +7,10 @@ import { getSignInMutationKey } from '../../utils/mutationKeys.js';
7
7
  import { getSessionQueryKey } from '../../utils/queryKeys.js';
8
8
  import { getSession } from '../services/getSession.js';
9
9
  import { signIn } from '../services/signIn.js';
10
- export const useSignInMutation = (config) => {
10
+ export const useSignInMutation = (options) => {
11
11
  const queryClient = getQueryClient();
12
12
  const recaptcha = useReCaptcha();
13
+ const { versionSession, ...config } = options ?? {};
13
14
  return useMutation({
14
15
  ...config,
15
16
  mutationKey: getSignInMutationKey(),
@@ -30,7 +31,7 @@ export const useSignInMutation = (config) => {
30
31
  ? { Channel: 'ANDROID' }
31
32
  : { Channel: 'IOS' }),
32
33
  },
33
- });
34
+ }, versionSession);
34
35
  if (!authenticator) {
35
36
  await queryClient.invalidateQueries({
36
37
  queryKey: getSessionQueryKey(),
@@ -1,5 +1,5 @@
1
- import type { CreateSessionInput } from '../../services/auth';
1
+ import type { 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): Promise<Authenticator | null>;
5
+ export declare function signIn(input: SignInInput, options?: HttpRequestOptions, versionSession?: VersionSession): Promise<Authenticator | null>;
@@ -1,9 +1,13 @@
1
1
  import { Capacitor } from '@capacitor/core';
2
+ import { SESSION_VERSION_HEADER_KEY } from '../../constants/index.js';
2
3
  import { httpRequest, } from '../../services/httpRequest.js';
3
4
  const platform = Capacitor.getPlatform();
4
- export async function signIn(input, options) {
5
+ export async function signIn(input, options, versionSession = 'default') {
6
+ const headers = new Headers(options?.headers);
7
+ headers.set(SESSION_VERSION_HEADER_KEY, versionSession);
5
8
  const res = await httpRequest.json('/api/sessions', {
6
9
  ...options,
10
+ headers,
7
11
  body: JSON.stringify(input),
8
12
  method: 'POST',
9
13
  });
@@ -1,6 +1,6 @@
1
1
  export declare const AurixPayQRPHDepositContext: (props: {
2
2
  value: {
3
- status: "idle" | "failed" | "generating-qr-code" | "qr-code-generated" | "confirmed";
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" | "failed" | "generating-qr-code" | "qr-code-generated" | "confirmed";
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" | "failed" | "generating-qr-code" | "qr-code-generated" | "confirmed";
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" | "failed" | "generating-qr-code" | "qr-code-generated" | "confirmed";
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" | "failed" | "generating-qr-code" | "qr-code-generated" | "confirmed";
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" | "failed" | "generating-qr-code" | "qr-code-generated" | "confirmed";
8
+ status: "idle" | "generating-qr-code" | "qr-code-generated" | "failed" | "confirmed";
9
9
  deposit: Deposit | null;
10
10
  errorMessage: {
11
11
  name: string;
@@ -1,12 +1,8 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import Image from 'next/image';
4
- import { useState } from 'react';
5
4
  import { useShallow } from 'zustand/shallow';
6
- import { useFeatureFlag } from '../../client/hooks/useFeatureFlag.js';
7
5
  import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
8
- import { getSession } from '../../client/services/getSession.js';
9
- import { toaster } from '../../client/utils/toaster.js';
10
6
  import cinePopLogo from '../../images/cinepop-logo.png';
11
7
  import dearUtolLogo from '../../images/dear-utol-logo.png';
12
8
  import mariasDiary from '../../images/marias-diary-logo.png';
@@ -15,35 +11,10 @@ import { Dialog } from '../../ui/Dialog/index.js';
15
11
  import { Portal } from '../../ui/Portal/index.js';
16
12
  export function KYCReview() {
17
13
  const { kycReview } = useGlobalStore(useShallow((s) => ({ kycReview: s.kycReview })));
18
- const [isLoading, setIsLoading] = useState(false);
19
- const featureFlag = useFeatureFlag();
20
- const isDialogOpen = kycReview.open && featureFlag.enabled;
21
- return (_jsx(Dialog.Root, { open: isDialogOpen, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { className: "flex items-center", children: _jsxs(Dialog.Content, { className: "flex w-[375px] flex-col items-center justify-between space-y-4 rounded-lg bg-[#232443] p-6 text-center", children: [_jsxs("div", { className: "flex flex-col items-center", children: [_jsx("div", { className: "mb-4 h-7 w-7 animate-spin rounded-full border-4 border-[#101730] border-t-[#F05027]" }), _jsx("div", { className: "font-semibold text-[#F5F5F6] text-lg", children: "Thanks for your submission." }), _jsxs("div", { className: "mt-1 text-[#CECFD2] text-sm", children: ["We\u2019re now ", '', _jsxs("span", { className: "text-[#F96B47]", children: ["reviewing your KYC information ", ''] }), "and will notify you once the verification is complete."] }), _jsx("div", { className: "mt-6 text-[#CECFD2] text-sm", children: "In the meantime, you can watch your favorite series on CinePop!" })] }), _jsxs("div", { className: "pt-3", children: [_jsx(Image, { src: cinePopLogo, alt: "cine poplogo", width: 151, height: 24, className: "mx-auto mb-2 h-auto w-[151px]" }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Image, { src: secretConfessionsLogo, alt: "secret confessions logo", width: 104, height: 53, className: "h-auto w-[104px]" }), _jsx(Image, { src: dearUtolLogo, alt: "dear utol logo", width: 105, height: 53, className: "h-auto w-[105px]" }), _jsx(Image, { src: mariasDiary, alt: "maria's diary logo", width: 104, height: 53, className: "h-auto w-[104px]" })] })] }), _jsx("button", { disabled: isLoading, type: "button", className: "h-[44px] w-full rounded-md font-semibold", style: {
14
+ return (_jsx(Dialog.Root, { open: kycReview.open, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { className: "flex items-center", children: _jsxs(Dialog.Content, { className: "flex w-[375px] flex-col items-center justify-between space-y-4 border bg-[#232443] p-6 text-center", children: [_jsxs("div", { className: "flex flex-col items-center", children: [_jsx("div", { className: "mb-4 h-7 w-7 animate-spin rounded-full border-4 border-[#101730] border-t-[#F05027]" }), _jsx("div", { className: "font-semibold text-[#F5F5F6] text-lg", children: "Thanks for your submission." }), _jsxs("div", { className: "mt-1 text-[#CECFD2] text-sm", children: ["We\u2019re now ", '', _jsxs("span", { className: "text-[#F96B47]", children: ["reviewing your KYC information ", ''] }), "and will notify you once the verification is complete."] }), _jsx("div", { className: "mt-6 text-[#CECFD2] text-sm", children: "In the meantime, you can watch your favorite series on CinePop!" })] }), _jsxs("div", { className: "pt-3", children: [_jsx(Image, { src: cinePopLogo, alt: "cine poplogo", width: 151, height: 24, className: "mx-auto mb-2 h-auto w-[151px]" }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Image, { src: secretConfessionsLogo, alt: "secret confessions logo", width: 104, height: 53, className: "h-auto w-[104px]" }), _jsx(Image, { src: dearUtolLogo, alt: "dear utol logo", width: 105, height: 53, className: "h-auto w-[105px]" }), _jsx(Image, { src: mariasDiary, alt: "maria's diary logo", width: 104, height: 53, className: "h-auto w-[104px]" })] })] }), _jsx("button", { type: "button", className: "h-[44px] w-full rounded-md font-semibold", style: {
22
15
  background: 'linear-gradient(90deg, #9333E8 0%, #D92778 100%)',
23
- }, onClick: async () => {
24
- const session = await getSession();
25
- setIsLoading(true);
26
- try {
27
- const response = await fetch('https://auth.development.opexa.io/v1/sso/cinepop', {
28
- method: 'POST',
29
- headers: {
30
- AUTHORIZATION: `Bearer ${session.token}`,
31
- 'PLATFORM-ID': 'Z892',
32
- 'Content-Type': 'application/json',
33
- },
34
- });
35
- const data = (await response.json());
36
- window.open(data.data.redirectionUrl, '_blank');
37
- }
38
- catch {
39
- toaster.error({
40
- title: 'Failed to redirect',
41
- description: 'Unable to open CinePop. Please try again.',
42
- });
43
- }
44
- finally {
45
- setIsLoading(false);
46
- kycReview.setOpen(false);
47
- }
16
+ }, onClick: () => {
17
+ window.open('https://cinepop.film/', '_blank');
18
+ kycReview.setOpen(false);
48
19
  }, children: "Watch Cinepop" })] }) })] }) }));
49
20
  }
@@ -45,6 +45,7 @@ export function MobileNumberSignIn() {
45
45
  disclaimer: ctx.disclaimer,
46
46
  })));
47
47
  const signInMutation = useSignInMutation({
48
+ versionSession: signInProps.versionSession,
48
49
  onSuccess: async () => {
49
50
  step1Form.reset();
50
51
  step2Form.reset();
@@ -45,6 +45,7 @@ export function NameAndPasswordSignIn() {
45
45
  disclaimer: ctx.disclaimer,
46
46
  })));
47
47
  const signInMutation = useSignInMutation({
48
+ versionSession: signInProps.versionSession,
48
49
  onSuccess: async (authenticator) => {
49
50
  if (authenticator) {
50
51
  context.setStep(2);
@@ -46,6 +46,7 @@ export function MobileNumberSignIn() {
46
46
  disclaimer: ctx.disclaimer,
47
47
  })));
48
48
  const signInMutation = useSignInMutation({
49
+ versionSession: signInProps.versionSession,
49
50
  onSuccess: async () => {
50
51
  step1Form.reset();
51
52
  step2Form.reset();
@@ -42,6 +42,7 @@ export function NameAndPasswordSignIn() {
42
42
  disclaimer: ctx.disclaimer,
43
43
  })));
44
44
  const signInMutation = useSignInMutation({
45
+ versionSession: signInProps.versionSession,
45
46
  onSuccess: async (authenticator) => {
46
47
  if (authenticator) {
47
48
  context.setStep(2);
@@ -53,6 +53,7 @@ export function MobileNumberSignIn() {
53
53
  termsOfUse: ctx.termsOfUse,
54
54
  })));
55
55
  const signInMutation = useSignInMutation({
56
+ versionSession: signInProps.versionSession,
56
57
  onSuccess: async () => {
57
58
  step1Form.reset();
58
59
  step2Form.reset();
@@ -80,6 +80,7 @@ export function MobileNumberSignInInternational() {
80
80
  disclaimer: ctx.disclaimer,
81
81
  })));
82
82
  const signInMutation = useSignInMutation({
83
+ versionSession: signInProps.versionSession,
83
84
  onSuccess: async () => {
84
85
  step1Form.reset();
85
86
  step2Form.reset();
@@ -55,6 +55,7 @@ export function NameAndPasswordSignIn() {
55
55
  })));
56
56
  const [formType, setFormType] = useState('NAME_AND_PASSWORD');
57
57
  const signInMutation = useSignInMutation({
58
+ versionSession: signInProps.versionSession,
58
59
  onSuccess: async (authenticator) => {
59
60
  if (authenticator) {
60
61
  context.setStep(2);
@@ -1,5 +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
4
  import type { CountryCode } from '../../utils/countries/types';
4
5
  import { type UseSignInProps } from './useSignIn';
5
6
  export interface ClassNameEntries {
@@ -24,5 +25,11 @@ export interface SignInProps extends UseSignInProps {
24
25
  shouldShowResponsibleGamingReminder?: boolean;
25
26
  shouldShowDisclaimer?: boolean;
26
27
  variant?: 'crazywin' | 'happybingo';
28
+ /**
29
+ * Selects which auth session endpoint the sign-in flow targets.
30
+ * - `default` (default): `${AUTH_ENDPOINT}/sessions`
31
+ * - `Inplay`: `${AUTH_ENDPOINT}/v3/inplay/sessions`
32
+ */
33
+ versionSession?: VersionSession;
27
34
  }
28
35
  export declare function SignIn(props: SignInProps): import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,10 @@
1
1
  export type SignInStep = 1 | 2 | (number & {});
2
2
  export type SignInType = 'NAME_AND_PASSWORD' | 'MOBILE_NUMBER';
3
+ export type SignInActiveTab = 'Mobile' | 'Username';
3
4
  export interface UseSignInProps {
4
5
  types?: SignInType[];
5
6
  defaultType?: SignInType;
7
+ defaultActiveTab?: SignInActiveTab;
6
8
  }
7
9
  export interface UseSignInReturn {
8
10
  step: SignInStep;
@@ -1,10 +1,20 @@
1
1
  import { useState } from 'react';
2
+ const ACTIVE_TAB_TYPE_MAP = {
3
+ Mobile: 'MOBILE_NUMBER',
4
+ Username: 'NAME_AND_PASSWORD',
5
+ };
2
6
  export function useSignIn(props) {
3
7
  const types = !props?.types?.length
4
8
  ? ['MOBILE_NUMBER', 'NAME_AND_PASSWORD']
5
9
  : props.types;
10
+ const defaultActiveType = props?.defaultActiveTab
11
+ ? ACTIVE_TAB_TYPE_MAP[props.defaultActiveTab]
12
+ : props?.defaultType ?? ACTIVE_TAB_TYPE_MAP.Mobile;
13
+ const initialType = types.includes(defaultActiveType)
14
+ ? defaultActiveType
15
+ : types[0];
6
16
  const [step, setStep] = useState(1);
7
- const [type, setType] = useState(props?.defaultType ?? types[0]);
17
+ const [type, setType] = useState(initialType);
8
18
  return {
9
19
  step,
10
20
  setStep,
@@ -1,3 +1,4 @@
1
1
  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
+ export declare const SESSION_VERSION_HEADER_KEY: string;
@@ -1,3 +1,4 @@
1
1
  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
+ export const SESSION_VERSION_HEADER_KEY = 'X-Session-Version';
@@ -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, 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({
@@ -41,6 +41,8 @@ export async function postSession(request) {
41
41
  }
42
42
  const recaptcha = request.headers.get(RECAPTCHA_HEADER_KEY);
43
43
  const domain = request.headers.get(DOMAIN_HEADER_KEY);
44
+ const versionSessionHeader = request.headers.get(SESSION_VERSION_HEADER_KEY);
45
+ const versionSession = versionSessionHeader === 'Inplay' ? 'Inplay' : 'default';
44
46
  try {
45
47
  const res = await createSession(parsed.data, {
46
48
  headers: {
@@ -58,7 +60,7 @@ export async function postSession(request) {
58
60
  }),
59
61
  ...(channel && { Channel: channel }),
60
62
  },
61
- });
63
+ }, versionSession);
62
64
  if (res.authenticator) {
63
65
  return NextResponse.json({
64
66
  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>>;
@@ -22,6 +22,12 @@ export interface CreateSessionInput__Token {
22
22
  token: string;
23
23
  }
24
24
  export type CreateSessionInput = CreateSessionInput__UsernameAndPassword | CreateSessionInput__MobileNumber | CreateSessionInput__Maya | CreateSessionInput__Token;
25
+ /**
26
+ * Controls which auth endpoint is used to create a session.
27
+ * - `default` -> `${AUTH_ENDPOINT}/sessions`
28
+ * - `Inplay` -> `${AUTH_ENDPOINT}/v3/inplay/sessions`
29
+ */
30
+ export type VersionSession = 'default' | 'Inplay';
25
31
  export interface CreateSessionTwoFactorAuthDisabledMutation {
26
32
  session: {
27
33
  id: string;
@@ -46,7 +52,7 @@ export interface CreateSessionTwoFactorAuthEnabledMutation {
46
52
  authenticator: Authenticator;
47
53
  }
48
54
  export type CreateSessionMutation = CreateSessionTwoFactorAuthDisabledMutation | CreateSessionTwoFactorAuthEnabledMutation;
49
- export declare function createSession(input: CreateSessionInput, options?: HttpRequestOptions): Promise<CreateSessionMutation>;
55
+ export declare function createSession(input: CreateSessionInput, options?: HttpRequestOptions, versionSession?: VersionSession): Promise<CreateSessionMutation>;
50
56
  export declare function createSessionLibangan(input: CreateSessionInput__Libangan, options?: HttpRequestOptions): Promise<{
51
57
  session: {
52
58
  id: string;
@@ -1,7 +1,11 @@
1
1
  import { AUTH_ENDPOINT } from '../constants/index.js';
2
2
  import { httpRequest } from './httpRequest.js';
3
3
  import { sha256 } from './sha256.js';
4
- export async function createSession(input, options) {
4
+ const SESSION_ENDPOINTS = {
5
+ default: '/sessions',
6
+ Inplay: '/v3/inplay/sessions',
7
+ };
8
+ export async function createSession(input, options, versionSession = 'default') {
5
9
  const headers = new Headers();
6
10
  if (input.type === 'NAME_AND_PASSWORD') {
7
11
  const password = await sha256(input.password);
@@ -26,7 +30,7 @@ export async function createSession(input, options) {
26
30
  headers.set(key, value);
27
31
  });
28
32
  try {
29
- return await httpRequest.json(`${AUTH_ENDPOINT}/sessions`, {
33
+ return await httpRequest.json(`${AUTH_ENDPOINT}${SESSION_ENDPOINTS[versionSession]}`, {
30
34
  ...options,
31
35
  method: 'POST',
32
36
  headers,