@opexa/portal-components 0.0.83 → 0.0.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/hooks/useAccountQuery.d.ts +1 -2
- package/dist/client/hooks/useAccountQuery.js +1 -4
- package/dist/client/hooks/useAuthenticateMutation.d.ts +1 -1
- package/dist/client/hooks/useAvailablePromosQuery.d.ts +2 -2
- package/dist/client/hooks/useAvailablePromosQuery.js +1 -4
- package/dist/client/hooks/useAvailableQuestsQuery.d.ts +1 -2
- package/dist/client/hooks/useAvailableQuestsQuery.js +1 -4
- package/dist/client/hooks/useBetRecordsQuery.d.ts +2 -2
- package/dist/client/hooks/useBetRecordsQuery.js +1 -4
- package/dist/client/hooks/useBonusQuery.d.ts +1 -2
- package/dist/client/hooks/useBonusQuery.js +3 -8
- package/dist/client/hooks/useBonusesQuery.d.ts +1 -2
- package/dist/client/hooks/useBonusesQuery.js +1 -4
- package/dist/client/hooks/useCashbackBonusQuery.d.ts +1 -2
- package/dist/client/hooks/useCashbackBonusQuery.js +1 -4
- package/dist/client/hooks/useCashbackBonusesQuery.d.ts +1 -2
- package/dist/client/hooks/useCashbackBonusesQuery.js +1 -4
- package/dist/client/hooks/useCashbackQuery.d.ts +1 -2
- package/dist/client/hooks/useCashbackQuery.js +3 -12
- package/dist/client/hooks/useCashbacksQuery.d.ts +1 -2
- package/dist/client/hooks/useCashbacksQuery.js +1 -6
- package/dist/client/hooks/useCheckInDailyCheckInQuestMutation.js +3 -6
- package/dist/client/hooks/useClaimCashbackBonusMutation.js +1 -4
- package/dist/client/hooks/useClaimSpotBonusMutation.js +1 -4
- package/dist/client/hooks/useCreateGCashDepositMutation.d.ts +2 -2
- package/dist/client/hooks/useCreateGCashDepositMutation.js +2 -7
- package/dist/client/hooks/useCreateGCashWithdrawalMutation.d.ts +1 -1
- package/dist/client/hooks/useCreateGCashWithdrawalMutation.js +2 -5
- package/dist/client/hooks/useCreateGameSessionMutation.d.ts +1 -2
- package/dist/client/hooks/useCreateGameSessionMutation.js +3 -11
- package/dist/client/hooks/useCreateInstapayWithdrawalMutation.d.ts +1 -1
- package/dist/client/hooks/useCreateInstapayWithdrawalMutation.js +2 -5
- package/dist/client/hooks/useCreateMayaAppDepositMutation.d.ts +2 -2
- package/dist/client/hooks/useCreateMayaAppDepositMutation.js +2 -7
- package/dist/client/hooks/useCreateMayaAppWithdrawalMutation.d.ts +1 -1
- package/dist/client/hooks/useCreateMayaAppWithdrawalMutation.js +2 -5
- package/dist/client/hooks/useCreateMayaDepositMutation.d.ts +2 -2
- package/dist/client/hooks/useCreateMayaDepositMutation.js +2 -7
- package/dist/client/hooks/useCreateMayaWithdrawalMutation.d.ts +1 -1
- package/dist/client/hooks/useCreateMayaWithdrawalMutation.js +2 -5
- package/dist/client/hooks/useCreateOnlineBankDepositMutation.d.ts +2 -2
- package/dist/client/hooks/useCreateOnlineBankDepositMutation.js +2 -7
- package/dist/client/hooks/useCreateQRPHDepositMutation.d.ts +3 -3
- package/dist/client/hooks/useCreateQRPHDepositMutation.js +2 -7
- package/dist/client/hooks/useDepositQuery.d.ts +1 -2
- package/dist/client/hooks/useDepositQuery.js +3 -5
- package/dist/client/hooks/useDepositRecordsQuery.d.ts +2 -2
- package/dist/client/hooks/useDepositRecordsQuery.js +1 -4
- package/dist/client/hooks/useDepositsCountQuery.js +3 -5
- package/dist/client/hooks/useEndGameSessionMutation.d.ts +1 -2
- package/dist/client/hooks/useEndGameSessionMutation.js +2 -6
- package/dist/client/hooks/useFavoriteGamesQuery.d.ts +1 -2
- package/dist/client/hooks/useFavoriteGamesQuery.js +3 -5
- package/dist/client/hooks/useGamesQuery.d.ts +2 -2
- package/dist/client/hooks/useGamesQuery.js +1 -7
- package/dist/client/hooks/useGlobalStore.d.ts +1 -1
- package/dist/client/hooks/useInfiniteQueryHelper.d.ts +1 -2
- package/dist/client/hooks/useInstapayBankListQuery.d.ts +1 -2
- package/dist/client/hooks/useInstapayBankListQuery.js +3 -5
- package/dist/client/hooks/useIsMayaSessionValidQuery.js +1 -4
- package/dist/client/hooks/useJackpotPayoutsQuery.d.ts +2 -2
- package/dist/client/hooks/useJackpotPayoutsQuery.js +2 -9
- package/dist/client/hooks/useJackpotsQuery.d.ts +2 -2
- package/dist/client/hooks/useJackpotsQuery.js +2 -9
- package/dist/client/hooks/useMarkGameAsFavoriteMutation.js +1 -4
- package/dist/client/hooks/useMarkMessageAsReadMutation.js +1 -4
- package/dist/client/hooks/useMemberVerificationQuery.d.ts +1 -2
- package/dist/client/hooks/useMemberVerificationQuery.js +1 -4
- package/dist/client/hooks/useMessagesQuery.d.ts +2 -2
- package/dist/client/hooks/useMessagesQuery.js +1 -4
- package/dist/client/hooks/usePaymentSettingsQuery.d.ts +1 -2
- package/dist/client/hooks/usePaymentSettingsQuery.js +1 -4
- package/dist/client/hooks/usePlatformQuery.d.ts +1 -2
- package/dist/client/hooks/usePlatformQuery.js +3 -8
- package/dist/client/hooks/useProfileCompletionQuery.d.ts +1 -2
- package/dist/client/hooks/useProfileCompletionQuery.js +1 -4
- package/dist/client/hooks/usePromoQuery.d.ts +1 -2
- package/dist/client/hooks/usePromoQuery.js +3 -12
- package/dist/client/hooks/usePromosQuery.d.ts +1 -2
- package/dist/client/hooks/usePromosQuery.js +2 -9
- package/dist/client/hooks/useSendVerificationCodeMutation.d.ts +1 -1
- package/dist/client/hooks/useSendVerificationCodeMutation.js +2 -8
- package/dist/client/hooks/useSessionQuery.js +2 -2
- package/dist/client/hooks/useSignInMutation.d.ts +1 -2
- package/dist/client/hooks/useSignUpMutation.d.ts +1 -1
- package/dist/client/hooks/useSignUpMutation.js +2 -11
- package/dist/client/hooks/useTopWinsQuery.d.ts +1 -2
- package/dist/client/hooks/useTopWinsQuery.js +3 -9
- package/dist/client/hooks/useTournamentsQuery.d.ts +2 -2
- package/dist/client/hooks/useTournamentsQuery.js +2 -9
- package/dist/client/hooks/useTransactionRecordsQuery.d.ts +2 -2
- package/dist/client/hooks/useTransactionRecordsQuery.js +1 -4
- package/dist/client/hooks/useUnmarkGameAsFavoriteMutation.js +1 -4
- package/dist/client/hooks/useUnreadMessagesCountQuery.d.ts +1 -1
- package/dist/client/hooks/useUnreadMessagesCountQuery.js +1 -4
- package/dist/client/hooks/useUpdateAccountMutation.d.ts +1 -1
- package/dist/client/hooks/useUpdateAccountMutation.js +1 -4
- package/dist/client/hooks/useWalletQuery.d.ts +1 -2
- package/dist/client/hooks/useWalletQuery.js +3 -10
- package/dist/client/hooks/useWithdrawalRecordsQuery.d.ts +2 -2
- package/dist/client/hooks/useWithdrawalRecordsQuery.js +1 -4
- package/dist/client/services/authenticate.d.ts +3 -2
- package/dist/client/services/authenticate.js +5 -12
- package/dist/client/services/getSession.d.ts +2 -1
- package/dist/client/services/getSession.js +4 -11
- package/dist/client/services/signIn.d.ts +4 -2
- package/dist/client/services/signIn.js +6 -13
- package/dist/client/services/signOut.d.ts +2 -1
- package/dist/client/services/signOut.js +15 -13
- package/dist/components/AccountSecurity/AccountSecurity.js +2 -25
- package/dist/components/BetRecords/BetRecords.d.ts +1 -1
- package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/useOnlineBankDeposit.d.ts +1 -1
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/useQRPHDeposit.d.ts +1 -1
- package/dist/components/GameLaunch/GameLaunchTrigger.d.ts +1 -1
- package/dist/components/GameProviders/GameProvidersCarousel.d.ts +1 -2
- package/dist/components/GameProviders/GameProvidersList.d.ts +1 -2
- package/dist/components/Games/GamesCarousel.d.ts +1 -1
- package/dist/components/Games/GamesContext.d.ts +1 -1
- package/dist/components/Games/GamesList.d.ts +1 -1
- package/dist/components/GamesSearch/GamesSearch.d.ts +1 -1
- package/dist/components/JackpotCounter/JackpotCounterItem.d.ts +1 -1
- package/dist/components/JackpotCounter/JackpotCounterItem.module.css +184 -184
- package/dist/components/Jackpots/Jackpots.d.ts +1 -1
- package/dist/components/Jackpots/JackpotsContext.d.ts +1 -1
- package/dist/components/Jackpots/useJackpotData.d.ts +2 -2
- package/dist/components/Jackpots/useJackpotData.js +0 -1
- package/dist/components/Messages/Message.d.ts +4 -0
- package/dist/components/Messages/{MessageItem.js → Message.js} +2 -2
- package/dist/components/Messages/MessageTrigger.d.ts +1 -1
- package/dist/components/Messages/Messages.js +2 -2
- package/dist/components/Messages/utils.d.ts +1 -1
- package/dist/components/Promos/Cashback.d.ts +1 -1
- package/dist/components/Promos/Promo.d.ts +1 -1
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.d.ts +1 -1
- package/dist/components/Quests/OnboardingQuest/OnboardingQuest.d.ts +1 -1
- package/dist/components/Quests/WageringQuest/WageringQuest.d.ts +1 -1
- package/dist/components/Search/Search.d.ts +1 -2
- package/dist/components/SignUp/SignUpForm.js +1 -1
- package/dist/components/TournamentCounter/TournamentCounterItem.d.ts +1 -1
- package/dist/components/Tournaments/Tournaments.d.ts +1 -1
- package/dist/components/Tournaments/TournamentsContext.d.ts +1 -1
- package/dist/components/Tournaments/useTournamentData.js +0 -1
- package/dist/components/TransactionRecords/DepositRecordsTable.js +0 -1
- package/dist/components/TransactionRecords/TableFilters.d.ts +1 -2
- package/dist/constants/endpoints.d.ts +10 -0
- package/dist/constants/endpoints.js +41 -0
- package/dist/constants/gameProviders.d.ts +1 -2
- package/dist/constants/gameTypes.d.ts +1 -2
- package/dist/constants/headerKeys.d.ts +1 -0
- package/dist/constants/headerKeys.js +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +1 -0
- package/dist/constants/secretQuestions.d.ts +1 -1
- package/dist/handlers.js +2 -12
- package/dist/middleware.d.ts +1 -1
- package/dist/middleware.js +2 -3
- package/dist/server/services/authenticate.d.ts +1 -1
- package/dist/server/services/authenticate.js +3 -8
- package/dist/server/services/signIn.d.ts +2 -1
- package/dist/server/services/signIn.js +3 -8
- package/dist/server/services/signOut.js +2 -3
- package/dist/server/utils/prefetchAccountQuery.js +1 -4
- package/dist/server/utils/prefetchAvailablePromosQuery.d.ts +1 -1
- package/dist/server/utils/prefetchAvailablePromosQuery.js +1 -4
- package/dist/server/utils/prefetchAvailableQuestsQuery.js +1 -4
- package/dist/server/utils/prefetchBetRecordsQuery.d.ts +1 -1
- package/dist/server/utils/prefetchBetRecordsQuery.js +1 -4
- package/dist/server/utils/prefetchBonusQuery.js +3 -8
- package/dist/server/utils/prefetchBonusesQuery.js +1 -4
- package/dist/server/utils/prefetchCashbackBonusQuery.js +1 -4
- package/dist/server/utils/prefetchCashbackBonusesQuery.js +1 -4
- package/dist/server/utils/prefetchCashbackQuery.js +3 -12
- package/dist/server/utils/prefetchCashbacksQuery.js +1 -6
- package/dist/server/utils/prefetchDepositQuery.js +3 -5
- package/dist/server/utils/prefetchDepositRecordsQuery.d.ts +1 -1
- package/dist/server/utils/prefetchDepositRecordsQuery.js +1 -4
- package/dist/server/utils/prefetchDepositsCountQuery.js +3 -5
- package/dist/server/utils/prefetchFavoriteGamesQuery.js +3 -5
- package/dist/server/utils/prefetchGamesQuery.d.ts +1 -1
- package/dist/server/utils/prefetchGamesQuery.js +2 -10
- package/dist/server/utils/prefetchInstapayBankListQuery.js +3 -5
- package/dist/server/utils/prefetchIsMayaSessionValidQuery.js +1 -4
- package/dist/server/utils/prefetchJackpotsQuery.d.ts +1 -1
- package/dist/server/utils/prefetchJackpotsQuery.js +2 -9
- package/dist/server/utils/prefetchMemberVerificationQuery.js +1 -4
- package/dist/server/utils/prefetchPaymentSettingsQuery.js +1 -4
- package/dist/server/utils/prefetchPlatformQuery.js +2 -9
- package/dist/server/utils/prefetchProfileCompletionQuery.js +1 -4
- package/dist/server/utils/prefetchPromoQuery.js +3 -12
- package/dist/server/utils/prefetchPromosQuery.js +2 -9
- package/dist/server/utils/prefetchTopWinsQuery.js +2 -9
- package/dist/server/utils/prefetchTournamentsQuery.d.ts +1 -1
- package/dist/server/utils/prefetchTournamentsQuery.js +2 -9
- package/dist/server/utils/prefetchTransactionRecordsQuery.d.ts +1 -1
- package/dist/server/utils/prefetchTransactionRecordsQuery.js +1 -4
- package/dist/server/utils/prefetchUnreadMessagesCountQuery.d.ts +1 -1
- package/dist/server/utils/prefetchUnreadMessagesCountQuery.js +1 -4
- package/dist/server/utils/prefetchWalletQuery.js +3 -5
- package/dist/server/utils/prefetchWithdrawalRecordsQuery.d.ts +1 -1
- package/dist/server/utils/prefetchWithdrawalRecordsQuery.js +1 -4
- package/dist/services/ObjectId.d.ts +24 -0
- package/dist/services/ObjectId.js +86 -0
- package/dist/services/account.service.d.ts +341 -0
- package/dist/services/account.service.js +233 -0
- package/dist/services/auth.service.d.ts +80 -0
- package/dist/services/auth.service.js +152 -0
- package/dist/services/cmsPortal.service.d.ts +43 -0
- package/dist/services/cmsPortal.service.js +148 -0
- package/dist/services/file.service.d.ts +33 -0
- package/dist/services/file.service.js +18 -0
- package/dist/services/game.service.d.ts +44 -0
- package/dist/services/game.service.js +33 -0
- package/dist/services/graphqlRequest.d.ts +4 -0
- package/dist/services/graphqlRequest.js +255 -0
- package/dist/services/httpRequest.d.ts +23 -0
- package/dist/services/httpRequest.js +93 -0
- package/dist/services/index.d.ts +12 -0
- package/dist/services/index.js +12 -0
- package/dist/services/portal.service.d.ts +37 -0
- package/dist/services/portal.service.js +44 -0
- package/dist/services/queries.d.ts +115 -0
- package/dist/services/queries.js +2319 -0
- package/dist/services/report.service.d.ts +203 -0
- package/dist/services/report.service.js +64 -0
- package/dist/services/sha256.d.ts +4 -0
- package/dist/services/sha256.js +16 -0
- package/dist/services/trigger.service.d.ts +88 -0
- package/dist/services/trigger.service.js +84 -0
- package/dist/services/wallet.service.d.ts +463 -0
- package/dist/services/wallet.service.js +357 -0
- package/dist/styles/theme.css +697 -697
- package/dist/types/index.d.ts +752 -6
- package/dist/ui/AlertDialog/AlertDialog.d.ts +88 -88
- package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +8 -8
- package/dist/ui/Badge/Badge.d.ts +12 -12
- package/dist/ui/Badge/badge.recipe.d.ts +3 -3
- package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
- package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
- package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
- package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
- package/dist/ui/Collapsible/Collapsible.d.ts +20 -20
- package/dist/ui/Collapsible/collapsible.recipe.d.ts +5 -5
- package/dist/ui/Combobox/Combobox.d.ts +42 -42
- package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
- package/dist/ui/DatePicker/DatePicker.d.ts +264 -264
- package/dist/ui/DatePicker/datePicker.recipe.d.ts +11 -11
- package/dist/ui/Dialog/Dialog.d.ts +88 -88
- package/dist/ui/Dialog/dialog.recipe.d.ts +8 -8
- package/dist/ui/Drawer/Drawer.d.ts +33 -33
- package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
- package/dist/ui/Popover/Popover.d.ts +55 -55
- package/dist/ui/Popover/popover.recipe.d.ts +5 -5
- package/dist/ui/Progress/Progress.d.ts +27 -27
- package/dist/ui/Progress/progress.recipe.d.ts +3 -3
- package/dist/ui/SegmentGroup/SegmentGroup.d.ts +18 -18
- package/dist/ui/SegmentGroup/segmentGroup.recipe.d.ts +3 -3
- package/dist/ui/Select/Select.d.ts +45 -45
- package/dist/ui/Select/select.recipe.d.ts +3 -3
- package/dist/ui/Table/Table.d.ts +21 -21
- package/dist/ui/Table/table.recipe.d.ts +3 -3
- package/dist/ui/Tabs/Tabs.d.ts +15 -15
- package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
- package/dist/utils/getGameImageUrl.d.ts +1 -1
- package/dist/utils/getGameImageUrl.js +3 -5
- package/dist/utils/getGameProviderData.d.ts +1 -2
- package/dist/utils/getGameTypeData.d.ts +1 -2
- package/dist/utils/graphqlRequest.d.ts +4 -0
- package/dist/utils/graphqlRequest.js +255 -0
- package/dist/utils/httpRequest.d.ts +6 -0
- package/dist/utils/httpRequest.js +87 -0
- package/dist/utils/queryKeys.d.ts +1 -1
- package/dist/utils/sha256.d.ts +4 -0
- package/dist/utils/sha256.js +16 -0
- package/package.json +166 -160
- package/dist/components/Games/GameContext.d.ts +0 -2
- package/dist/components/Games/GameContext.js +0 -2
- package/dist/components/Jackpots/JackpotItemDesktop.d.ts +0 -9
- package/dist/components/Jackpots/JackpotItemDesktop.js +0 -43
- package/dist/components/Jackpots/JackpotItemMobile.d.ts +0 -9
- package/dist/components/Jackpots/JackpotItemMobile.js +0 -44
- package/dist/components/Jackpots/useJackpotItemData.d.ts +0 -20
- package/dist/components/Jackpots/useJackpotItemData.js +0 -87
- package/dist/components/Messages/MessageItem.d.ts +0 -4
- package/dist/components/Tournaments/TournamentItemDesktop.d.ts +0 -7
- package/dist/components/Tournaments/TournamentItemDesktop.js +0 -56
- package/dist/components/Tournaments/TournamentItemMobile.d.ts +0 -7
- package/dist/components/Tournaments/TournamentItemMobile.js +0 -54
- package/dist/components/Tournaments/useTournamentItemData.d.ts +0 -16
- package/dist/components/Tournaments/useTournamentItemData.js +0 -64
- package/dist/images/hacksaw-gaming.png +0 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { cache } from 'react';
|
|
2
|
+
import { ACCOUNT_GRAPHQL_ENDPOINT } from '../constants/index.js';
|
|
3
|
+
import { graphqlRequest } from './graphqlRequest.js';
|
|
4
|
+
import { ANNOUNCEMENTS, CREATE_MEMBER_VERIFICATION, CREATE_MEMBER_VERIFICATION__NEXT, DELETE_MEMBER_ACCOUNT, GOOGLE_CLIENT_ID, MEMBER_ACCOUNT, MEMBER_VERIFICATION, PAYMENT_SETTINGS, POINTS_CLUB_SETTINGS, PROFILE_COMPLETION, REFERRAL_CODE, REGISTER_MAYA_MEMBER_ACCOUNT, REGISTER_MEMBER_ACCOUNT, REGISTER_MEMBER_ACCOUNT__NEXT, REGISTER_MEMBER_ACCOUNT_BY_MOBILE_NUMBER, REGISTER_MEMBER_ACCOUNT_BY_NAME, REGISTER_MEMBER_ACCOUNT_VIA_MOBILE, RESET_PASSWORD, UPDATE_MEMBER_ACCOUNT, UPDATE_MEMBER_VERIFICATION, UPDATE_REFERRAL_CODE, VERIFY_MOBILE_NUMBER, } from './queries.js';
|
|
5
|
+
import { sha256 } from './sha256.js';
|
|
6
|
+
export const getMemberAccount = cache(async (options) => {
|
|
7
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, MEMBER_ACCOUNT, undefined, options);
|
|
8
|
+
return res.memberAccount;
|
|
9
|
+
});
|
|
10
|
+
export const registerMemberAccount = async (input, options) => {
|
|
11
|
+
const { password, referralCode, verificationCode, ...rest } = input;
|
|
12
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, REGISTER_MEMBER_ACCOUNT, {
|
|
13
|
+
input: {
|
|
14
|
+
password: await sha256(password),
|
|
15
|
+
...rest,
|
|
16
|
+
},
|
|
17
|
+
referralCode,
|
|
18
|
+
verificationCode,
|
|
19
|
+
}, options);
|
|
20
|
+
if (res.registerMemberAccount) {
|
|
21
|
+
const error = new Error();
|
|
22
|
+
error.name = res.registerMemberAccount.name;
|
|
23
|
+
error.message = res.registerMemberAccount.message;
|
|
24
|
+
Error.captureStackTrace?.(error, registerMemberAccount);
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export const registerMemberAccountViaMobile = async (input, options) => {
|
|
29
|
+
const { verificationCode, referralCode, ...rest } = input;
|
|
30
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, REGISTER_MEMBER_ACCOUNT_VIA_MOBILE, {
|
|
31
|
+
input: {
|
|
32
|
+
...rest,
|
|
33
|
+
},
|
|
34
|
+
referralCode,
|
|
35
|
+
verificationCode,
|
|
36
|
+
}, options);
|
|
37
|
+
if (res.registerMemberAccountViaMobile) {
|
|
38
|
+
const error = new Error();
|
|
39
|
+
error.name = res.registerMemberAccountViaMobile.name;
|
|
40
|
+
error.message = res.registerMemberAccountViaMobile.message;
|
|
41
|
+
Error.captureStackTrace?.(error, registerMemberAccountViaMobile);
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export const registerMemberAccountByMobileNumber = async (input, options) => {
|
|
46
|
+
const { password, mobileNumberVerificationCode, ...rest } = input;
|
|
47
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, REGISTER_MEMBER_ACCOUNT_BY_MOBILE_NUMBER, {
|
|
48
|
+
input: {
|
|
49
|
+
password: await sha256(password),
|
|
50
|
+
...rest,
|
|
51
|
+
},
|
|
52
|
+
mobileNumberVerificationCode,
|
|
53
|
+
}, options);
|
|
54
|
+
if (res.registerMemberAccountByMobileNumber) {
|
|
55
|
+
const error = new Error();
|
|
56
|
+
error.name = res.registerMemberAccountByMobileNumber.name;
|
|
57
|
+
error.message = res.registerMemberAccountByMobileNumber.message;
|
|
58
|
+
Error.captureStackTrace?.(error, registerMemberAccountByMobileNumber);
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
export const registerMemberAccount__next = async (input, options) => {
|
|
63
|
+
const { password, ...rest } = input;
|
|
64
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, REGISTER_MEMBER_ACCOUNT__NEXT, {
|
|
65
|
+
input: {
|
|
66
|
+
password: await sha256(password),
|
|
67
|
+
...rest,
|
|
68
|
+
},
|
|
69
|
+
}, options);
|
|
70
|
+
if (res.registerMemberAccount) {
|
|
71
|
+
const error = new Error();
|
|
72
|
+
error.name = res.registerMemberAccount.name;
|
|
73
|
+
error.message = res.registerMemberAccount.message;
|
|
74
|
+
Error.captureStackTrace?.(error, registerMemberAccount__next);
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
export const registerMemberAccountByName = async (input, options) => {
|
|
79
|
+
const { password, ...rest } = input;
|
|
80
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, REGISTER_MEMBER_ACCOUNT_BY_NAME, {
|
|
81
|
+
input: {
|
|
82
|
+
password: await sha256(password),
|
|
83
|
+
...rest,
|
|
84
|
+
},
|
|
85
|
+
}, options);
|
|
86
|
+
if (res.registerMemberAccountByName) {
|
|
87
|
+
const error = new Error();
|
|
88
|
+
error.name = res.registerMemberAccountByName.name;
|
|
89
|
+
error.message = res.registerMemberAccountByName.message;
|
|
90
|
+
Error.captureStackTrace?.(error, registerMemberAccountByName);
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
export const updateMemberAccount = async (id, data, options) => {
|
|
95
|
+
const { password, secretAnswer, ...rest } = data;
|
|
96
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, UPDATE_MEMBER_ACCOUNT, {
|
|
97
|
+
input: {
|
|
98
|
+
id,
|
|
99
|
+
data: {
|
|
100
|
+
password: password ? await sha256(password) : undefined,
|
|
101
|
+
secretAnswer: secretAnswer ? await sha256(secretAnswer) : undefined,
|
|
102
|
+
...rest,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
}, options);
|
|
106
|
+
if (res.updateMemberAccount) {
|
|
107
|
+
const error = new Error();
|
|
108
|
+
error.name = res.updateMemberAccount.name;
|
|
109
|
+
error.message = res.updateMemberAccount.message;
|
|
110
|
+
Error.captureStackTrace?.(error, updateMemberAccount);
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
export const deleteMemberAccount = async (id, options) => {
|
|
115
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, DELETE_MEMBER_ACCOUNT, { input: { id } }, options);
|
|
116
|
+
if (!res.deleteMemberAccount) {
|
|
117
|
+
const error = new Error();
|
|
118
|
+
error.name = 'DeleteMemberAccountError';
|
|
119
|
+
error.message = 'Failed to delete member account';
|
|
120
|
+
Error.captureStackTrace?.(error, deleteMemberAccount);
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
export const resetPassword = async (input, options) => {
|
|
125
|
+
const { newPassword, verificationCode, ...rest } = input;
|
|
126
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, RESET_PASSWORD, {
|
|
127
|
+
input: {
|
|
128
|
+
newPassword: await sha256(newPassword),
|
|
129
|
+
...rest,
|
|
130
|
+
},
|
|
131
|
+
verificationCode,
|
|
132
|
+
}, options);
|
|
133
|
+
if (res.resetPassword) {
|
|
134
|
+
const error = new Error();
|
|
135
|
+
error.name = res.resetPassword.name;
|
|
136
|
+
error.message = res.resetPassword.message;
|
|
137
|
+
Error.captureStackTrace?.(error, resetPassword);
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
export const getProfileCompletion = cache(async (options) => {
|
|
142
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, PROFILE_COMPLETION, undefined, options);
|
|
143
|
+
return res.profileCompletion;
|
|
144
|
+
});
|
|
145
|
+
export const getPaymentSettings = cache(async (options) => {
|
|
146
|
+
return await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, PAYMENT_SETTINGS, undefined, options);
|
|
147
|
+
});
|
|
148
|
+
export const verifyMobileNumber = async (verificationCode, options) => {
|
|
149
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, VERIFY_MOBILE_NUMBER, { input: { verificationCode } }, options);
|
|
150
|
+
if (res.verifyMobileNumber) {
|
|
151
|
+
const error = new Error();
|
|
152
|
+
error.name = res.verifyMobileNumber.name;
|
|
153
|
+
error.message = res.verifyMobileNumber.message;
|
|
154
|
+
Error.captureStackTrace?.(error, verifyMobileNumber);
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
export const createMemberVerification = async (input, options) => {
|
|
159
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, CREATE_MEMBER_VERIFICATION, { input }, options);
|
|
160
|
+
if (res.createMemberVerification) {
|
|
161
|
+
const error = new Error();
|
|
162
|
+
error.name = res.createMemberVerification.name;
|
|
163
|
+
error.message = res.createMemberVerification.message;
|
|
164
|
+
Error.captureStackTrace?.(error, createMemberVerification);
|
|
165
|
+
throw error;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
export const createMemberVerification__next = async (input, options) => {
|
|
169
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, CREATE_MEMBER_VERIFICATION__NEXT, { input }, options);
|
|
170
|
+
if (res.createMemberVerification) {
|
|
171
|
+
const error = new Error();
|
|
172
|
+
error.name = res.createMemberVerification.name;
|
|
173
|
+
error.message = res.createMemberVerification.message;
|
|
174
|
+
Error.captureStackTrace?.(error, createMemberVerification__next);
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
export const updateMemberVerification = async (id, data, options) => {
|
|
179
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, UPDATE_MEMBER_VERIFICATION, { input: { id, data } }, options);
|
|
180
|
+
if (res.updateMemberVerification) {
|
|
181
|
+
const error = new Error();
|
|
182
|
+
error.name = res.updateMemberVerification.name;
|
|
183
|
+
error.message = res.updateMemberVerification.message;
|
|
184
|
+
Error.captureStackTrace?.(error, updateMemberVerification);
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
export const getMemberVerification = cache(async (options) => {
|
|
189
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, MEMBER_VERIFICATION, undefined, options);
|
|
190
|
+
return res.memberAccount.verification ?? null;
|
|
191
|
+
});
|
|
192
|
+
export const getAnnouncements = cache(async (input, options) => {
|
|
193
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, ANNOUNCEMENTS, input, options);
|
|
194
|
+
return res.announcements;
|
|
195
|
+
});
|
|
196
|
+
export const registerMayaMemberAccount = async (input, options) => {
|
|
197
|
+
const { password, ...rest } = input;
|
|
198
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, REGISTER_MAYA_MEMBER_ACCOUNT, {
|
|
199
|
+
input: {
|
|
200
|
+
password: await sha256(password),
|
|
201
|
+
...rest,
|
|
202
|
+
},
|
|
203
|
+
}, options);
|
|
204
|
+
if (res.registerMayaMemberAccount) {
|
|
205
|
+
const error = new Error();
|
|
206
|
+
error.name = res.registerMayaMemberAccount.name;
|
|
207
|
+
error.message = res.registerMayaMemberAccount.message;
|
|
208
|
+
Error.captureStackTrace?.(error, registerMayaMemberAccount);
|
|
209
|
+
throw error;
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
export const getReferralCode = cache(async (options) => {
|
|
213
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, REFERRAL_CODE, undefined, options);
|
|
214
|
+
return res.referralCode ?? null;
|
|
215
|
+
});
|
|
216
|
+
export const updateReferralCode = async (code, options) => {
|
|
217
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, UPDATE_REFERRAL_CODE, { input: { code } }, options);
|
|
218
|
+
if (res.updateReferralCode) {
|
|
219
|
+
const error = new Error();
|
|
220
|
+
error.name = res.updateReferralCode.name;
|
|
221
|
+
error.message = res.updateReferralCode.message;
|
|
222
|
+
Error.captureStackTrace?.(error, updateReferralCode);
|
|
223
|
+
throw error;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
export const getPointsClubSettings = cache(async (options) => {
|
|
227
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, POINTS_CLUB_SETTINGS, undefined, options);
|
|
228
|
+
return res.pointsClubSettings ?? null;
|
|
229
|
+
});
|
|
230
|
+
export const getGoogleClientId = cache(async (options) => {
|
|
231
|
+
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, GOOGLE_CLIENT_ID, undefined, options);
|
|
232
|
+
return res.googleClientId ?? null;
|
|
233
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Authenticator } from '../types';
|
|
2
|
+
import { type HttpRequestOptions } from './httpRequest';
|
|
3
|
+
export interface CreateSessionInput__UsernameAndPassword {
|
|
4
|
+
type: 'NAME_AND_PASSWORD';
|
|
5
|
+
name: string;
|
|
6
|
+
password: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CreateSessionInput__MobileNumber {
|
|
9
|
+
type: 'MOBILE_NUMBER';
|
|
10
|
+
mobileNumber: string;
|
|
11
|
+
verificationCode: string;
|
|
12
|
+
}
|
|
13
|
+
export interface CreateSessionInput__Maya {
|
|
14
|
+
type: 'MAYA';
|
|
15
|
+
session: string;
|
|
16
|
+
}
|
|
17
|
+
export interface CreateSessionInput__Libangan {
|
|
18
|
+
type: 'LIBANGAN';
|
|
19
|
+
session: string;
|
|
20
|
+
}
|
|
21
|
+
export interface CreateSessionInput__Token {
|
|
22
|
+
type: 'SOCIALS' | 'CABINET' | 'SINGLE_USE_TOKEN';
|
|
23
|
+
token: string;
|
|
24
|
+
}
|
|
25
|
+
export type CreateSessionInput = CreateSessionInput__UsernameAndPassword | CreateSessionInput__MobileNumber | CreateSessionInput__Maya | CreateSessionInput__Libangan | CreateSessionInput__Token;
|
|
26
|
+
export interface CreateSessionTwoFactorAuthDisabledMutation {
|
|
27
|
+
session: {
|
|
28
|
+
id: string;
|
|
29
|
+
dateTimeCreated: string;
|
|
30
|
+
};
|
|
31
|
+
accessToken: string;
|
|
32
|
+
refreshToken: string;
|
|
33
|
+
authenticator?: never;
|
|
34
|
+
}
|
|
35
|
+
export interface CreateSessionTwoFactorAuthEnabledMutation {
|
|
36
|
+
authenticator: Authenticator;
|
|
37
|
+
}
|
|
38
|
+
export type CreateSessionMutation = CreateSessionTwoFactorAuthDisabledMutation | CreateSessionTwoFactorAuthEnabledMutation;
|
|
39
|
+
export declare function createSession(input: CreateSessionInput, options?: HttpRequestOptions): Promise<CreateSessionMutation>;
|
|
40
|
+
export interface AuthenticateInput__SecurityQuestion {
|
|
41
|
+
type: 'SECURITY_QUESTION';
|
|
42
|
+
token: string;
|
|
43
|
+
secretAnswer: string;
|
|
44
|
+
}
|
|
45
|
+
export interface AuthenticateMutation extends RefreshSessionMutation {
|
|
46
|
+
}
|
|
47
|
+
export type AuthenticateInput = AuthenticateInput__SecurityQuestion;
|
|
48
|
+
export declare function authenticate(input: AuthenticateInput, options?: HttpRequestOptions): Promise<AuthenticateMutation>;
|
|
49
|
+
export interface RefreshSessionMutation extends Omit<CreateSessionTwoFactorAuthDisabledMutation, 'authenticator'> {
|
|
50
|
+
}
|
|
51
|
+
export declare function refreshSession(options?: HttpRequestOptions): Promise<RefreshSessionMutation>;
|
|
52
|
+
export declare function destroySession(options?: HttpRequestOptions): Promise<void>;
|
|
53
|
+
export declare function verifySession(options?: HttpRequestOptions): Promise<boolean>;
|
|
54
|
+
export interface SendVerificationCodeInput {
|
|
55
|
+
strict?: boolean;
|
|
56
|
+
channel: 'SMS' | 'EMAIL';
|
|
57
|
+
recipient: string;
|
|
58
|
+
}
|
|
59
|
+
export declare function sendVerificationCode(input: SendVerificationCodeInput, options?: HttpRequestOptions): Promise<{
|
|
60
|
+
json<T>(): Promise<T>;
|
|
61
|
+
headers: Headers;
|
|
62
|
+
ok: boolean;
|
|
63
|
+
redirected: boolean;
|
|
64
|
+
status: number;
|
|
65
|
+
statusText: string;
|
|
66
|
+
type: ResponseType;
|
|
67
|
+
url: string;
|
|
68
|
+
clone(): Response;
|
|
69
|
+
body: ReadableStream<Uint8Array> | null;
|
|
70
|
+
bodyUsed: boolean;
|
|
71
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
72
|
+
blob(): Promise<Blob>;
|
|
73
|
+
bytes(): Promise<Uint8Array>;
|
|
74
|
+
formData(): Promise<FormData>;
|
|
75
|
+
text(): Promise<string>;
|
|
76
|
+
}>;
|
|
77
|
+
export interface CreateSingleUseTokenMutation {
|
|
78
|
+
token: string;
|
|
79
|
+
}
|
|
80
|
+
export declare function createSingleUseToken(options?: HttpRequestOptions): Promise<CreateSingleUseTokenMutation>;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { AUTH_ENDPOINT } from '../constants/index.js';
|
|
2
|
+
import { httpRequest } from './httpRequest.js';
|
|
3
|
+
import { sha256 } from './sha256.js';
|
|
4
|
+
export async function createSession(input, options) {
|
|
5
|
+
const headers = new Headers();
|
|
6
|
+
if (input.type === 'NAME_AND_PASSWORD') {
|
|
7
|
+
const password = await sha256(input.password);
|
|
8
|
+
headers.set('Authorization', `Basic ${Buffer.from(`${input.name}:${password}`).toString('base64')}`);
|
|
9
|
+
}
|
|
10
|
+
if (input.type === 'MOBILE_NUMBER') {
|
|
11
|
+
headers.set('Authorization', `MobileNumberOTP ${Buffer.from(`${input.mobileNumber}:${input.verificationCode}`).toString('base64')}`);
|
|
12
|
+
}
|
|
13
|
+
if (input.type === 'MAYA') {
|
|
14
|
+
headers.set('Authorization', `MayaSession ${input.session}`);
|
|
15
|
+
}
|
|
16
|
+
if (input.type === 'LIBANGAN') {
|
|
17
|
+
headers.set('Authorization', `Libangan ${input.session}`);
|
|
18
|
+
}
|
|
19
|
+
if (input.type === 'SOCIALS') {
|
|
20
|
+
headers.set('Authorization', `Token ${input.token}`);
|
|
21
|
+
}
|
|
22
|
+
if (input.type === 'CABINET') {
|
|
23
|
+
headers.set('Authorization', `Opexa-Cabinet-Token ${input.token}`);
|
|
24
|
+
}
|
|
25
|
+
if (input.type === 'SINGLE_USE_TOKEN') {
|
|
26
|
+
headers.set('Authorization', `Single-Use-Token ${input.token}`);
|
|
27
|
+
}
|
|
28
|
+
new Headers(options?.headers).forEach((value, key) => {
|
|
29
|
+
headers.set(key, value);
|
|
30
|
+
});
|
|
31
|
+
try {
|
|
32
|
+
return await httpRequest.json(input.type === 'LIBANGAN'
|
|
33
|
+
? `${AUTH_ENDPOINT}/v2/sessions`
|
|
34
|
+
: `${AUTH_ENDPOINT}/sessions`, {
|
|
35
|
+
...options,
|
|
36
|
+
method: 'POST',
|
|
37
|
+
headers,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
if (e instanceof Error) {
|
|
42
|
+
throw e;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const error = new Error();
|
|
46
|
+
error.name = 'AccountNotFoundError';
|
|
47
|
+
error.message = 'Account not found';
|
|
48
|
+
Error.captureStackTrace?.(error, createSession);
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export async function authenticate(input, options) {
|
|
54
|
+
if (input.type === 'SECURITY_QUESTION') {
|
|
55
|
+
try {
|
|
56
|
+
return await httpRequest.json(`${AUTH_ENDPOINT}/session/${input.token}/authenticate`, {
|
|
57
|
+
...options,
|
|
58
|
+
method: 'POST',
|
|
59
|
+
body: JSON.stringify({
|
|
60
|
+
secretAnswer: await sha256(input.secretAnswer),
|
|
61
|
+
}),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
if (e instanceof Error) {
|
|
66
|
+
throw e;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const error = new Error();
|
|
70
|
+
error.name = 'AccountNotFoundError';
|
|
71
|
+
error.message = 'Account not found';
|
|
72
|
+
Error.captureStackTrace?.(error, authenticate);
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
throw new Error("Invalid input 'type'");
|
|
78
|
+
}
|
|
79
|
+
export async function refreshSession(options) {
|
|
80
|
+
try {
|
|
81
|
+
return await httpRequest.json(`${AUTH_ENDPOINT}/session:refresh`, {
|
|
82
|
+
...options,
|
|
83
|
+
method: 'POST',
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
if (e instanceof Error) {
|
|
88
|
+
throw e;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const error = new Error();
|
|
92
|
+
error.name = 'AccountNotFoundError';
|
|
93
|
+
error.message = 'Account not found';
|
|
94
|
+
Error.captureStackTrace?.(error, refreshSession);
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export async function destroySession(options) {
|
|
100
|
+
try {
|
|
101
|
+
await httpRequest(`${AUTH_ENDPOINT}/session`, {
|
|
102
|
+
...options,
|
|
103
|
+
method: 'DELETE',
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
/* ignore */
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export async function verifySession(options) {
|
|
111
|
+
try {
|
|
112
|
+
const res = await httpRequest(`${AUTH_ENDPOINT}/session`, options);
|
|
113
|
+
return res.ok;
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
/* Assume session is still valid for unknown errors like Network */
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
export async function sendVerificationCode(input, options) {
|
|
121
|
+
const { strict, ...rest } = input;
|
|
122
|
+
const headers = new Headers();
|
|
123
|
+
headers.set('Accept', 'application/json');
|
|
124
|
+
headers.set('Content-Type', 'application/json');
|
|
125
|
+
new Headers(options?.headers).forEach((value, key) => {
|
|
126
|
+
headers.set(key, value);
|
|
127
|
+
});
|
|
128
|
+
return httpRequest(`${AUTH_ENDPOINT}/otps`, {
|
|
129
|
+
...options,
|
|
130
|
+
method: 'POST',
|
|
131
|
+
headers,
|
|
132
|
+
body: JSON.stringify({
|
|
133
|
+
verificationType: strict ? 'MEMBER' : undefined,
|
|
134
|
+
...rest,
|
|
135
|
+
}),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
export async function createSingleUseToken(options) {
|
|
139
|
+
try {
|
|
140
|
+
return await httpRequest.json(`${AUTH_ENDPOINT}/token`, {
|
|
141
|
+
...options,
|
|
142
|
+
method: 'POST',
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
const error = new Error();
|
|
147
|
+
error.name = 'InvalidTokenError';
|
|
148
|
+
error.message = 'Invalid token';
|
|
149
|
+
Error.captureStackTrace?.(error, createSingleUseToken);
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { SimplifyDeep } from 'type-fest';
|
|
2
|
+
import type { EnumFilterField, Game, GameProvider, GameTag, GameType, ObjectIdFilterField, PaginatedQueryResult, Site, SortOrder } from '../types';
|
|
3
|
+
import { type HttpRequestOptions } from './httpRequest';
|
|
4
|
+
export interface SiteQuery {
|
|
5
|
+
data: Site;
|
|
6
|
+
}
|
|
7
|
+
export declare const getSite: (id: string, options?: HttpRequestOptions) => Promise<Site | null>;
|
|
8
|
+
export interface GamesQueryVariables {
|
|
9
|
+
after?: string;
|
|
10
|
+
first?: number;
|
|
11
|
+
search?: string;
|
|
12
|
+
filter?: {
|
|
13
|
+
tags?: EnumFilterField<GameTag>;
|
|
14
|
+
type?: EnumFilterField<GameType>;
|
|
15
|
+
provider?: EnumFilterField<GameProvider>;
|
|
16
|
+
reference?: ObjectIdFilterField;
|
|
17
|
+
};
|
|
18
|
+
sort?: SortOrder;
|
|
19
|
+
}
|
|
20
|
+
export interface GamesQuery {
|
|
21
|
+
data: Game[];
|
|
22
|
+
next?: string | null;
|
|
23
|
+
totalCount?: number | null;
|
|
24
|
+
}
|
|
25
|
+
export type GamesInput = SimplifyDeep<GamesQueryVariables>;
|
|
26
|
+
export declare function getGames(input?: GamesInput, options?: HttpRequestOptions): Promise<PaginatedQueryResult<Game>>;
|
|
27
|
+
export interface GamesQueryVariables__Next {
|
|
28
|
+
after?: string;
|
|
29
|
+
first?: number;
|
|
30
|
+
search?: string;
|
|
31
|
+
filter?: {
|
|
32
|
+
tags?: EnumFilterField<GameTag>;
|
|
33
|
+
type?: EnumFilterField<GameType>;
|
|
34
|
+
provider?: EnumFilterField<GameProvider>;
|
|
35
|
+
reference?: ObjectIdFilterField;
|
|
36
|
+
};
|
|
37
|
+
sort?: {
|
|
38
|
+
order: SortOrder;
|
|
39
|
+
context: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export type GamesInput__Next = SimplifyDeep<GamesQueryVariables__Next>;
|
|
43
|
+
export declare const getGames__next: (input?: GamesInput__Next, options?: HttpRequestOptions) => Promise<PaginatedQueryResult<Game>>;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { cache } from 'react';
|
|
2
|
+
import { CMS_PORTAL_ENDPOINT } from '../constants/index.js';
|
|
3
|
+
import { httpRequest } from './httpRequest.js';
|
|
4
|
+
export const getSite = cache(async (id, options) => {
|
|
5
|
+
try {
|
|
6
|
+
const { data } = await httpRequest.json(`${CMS_PORTAL_ENDPOINT}/v1/sites/${id}`, options);
|
|
7
|
+
return data ?? null;
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
export async function getGames(input, options) {
|
|
14
|
+
const search = new URLSearchParams();
|
|
15
|
+
if (input?.first)
|
|
16
|
+
search.set('first', input.first.toString());
|
|
17
|
+
if (input?.after)
|
|
18
|
+
search.set('after', input.after);
|
|
19
|
+
if (input?.search)
|
|
20
|
+
search.set('search', input.search);
|
|
21
|
+
if (input?.filter?.type?.equal)
|
|
22
|
+
search.set('filter[type][eq]', input.filter.type.equal);
|
|
23
|
+
if (input?.filter?.type?.notEqual)
|
|
24
|
+
search.set('filter[type][neq]', input.filter.type.notEqual);
|
|
25
|
+
if (input?.filter?.type?.in)
|
|
26
|
+
search.set('filter[type][in]', input.filter.type.in.join(','));
|
|
27
|
+
if (input?.filter?.type?.notIn)
|
|
28
|
+
search.set('filter[type][nin]', input.filter.type.notIn.join(','));
|
|
29
|
+
if (input?.filter?.provider?.equal)
|
|
30
|
+
search.set('filter[provider][eq]', input.filter.provider.equal);
|
|
31
|
+
if (input?.filter?.provider?.notEqual)
|
|
32
|
+
search.set('filter[provider][neq]', input.filter.provider.notEqual);
|
|
33
|
+
if (input?.filter?.provider?.in)
|
|
34
|
+
search.set('filter[provider][in]', input.filter.provider.in.join(','));
|
|
35
|
+
if (input?.filter?.provider?.notIn)
|
|
36
|
+
search.set('filter[provider][nin]', input.filter.provider.notIn.join(','));
|
|
37
|
+
if (input?.filter?.tags?.equal)
|
|
38
|
+
search.set('filter[tags][eq]', input.filter.tags.equal.toLowerCase());
|
|
39
|
+
if (input?.filter?.tags?.notEqual)
|
|
40
|
+
search.set('filter[tags][neq]', input.filter.tags.notEqual.toLowerCase());
|
|
41
|
+
if (input?.filter?.tags?.in)
|
|
42
|
+
search.set('filter[tags][in]', input.filter.tags.in.map((v) => v.toLowerCase()).join(','));
|
|
43
|
+
if (input?.filter?.tags?.notIn)
|
|
44
|
+
search.set('filter[tags][nin]', input.filter.tags.notIn.map((v) => v.toLowerCase()).join(','));
|
|
45
|
+
if (input?.filter?.reference?.equal)
|
|
46
|
+
search.set('filter[reference][eq]', input.filter.reference.equal);
|
|
47
|
+
if (input?.filter?.reference?.notEqual)
|
|
48
|
+
search.set('filter[reference][neq]', input.filter.reference.notEqual);
|
|
49
|
+
if (input?.filter?.reference?.in)
|
|
50
|
+
search.set('filter[reference][in]', input.filter.reference.in.join(','));
|
|
51
|
+
if (input?.filter?.reference?.notIn)
|
|
52
|
+
search.set('filter[reference][nin]', input.filter.reference.notIn.join(','));
|
|
53
|
+
if (input?.sort)
|
|
54
|
+
search.set('sort[order]', input.sort);
|
|
55
|
+
try {
|
|
56
|
+
const res = await httpRequest.json(`${CMS_PORTAL_ENDPOINT}/v1/games?${search.toString()}`, options);
|
|
57
|
+
return {
|
|
58
|
+
edges: res.data.map((node) => ({
|
|
59
|
+
node,
|
|
60
|
+
cursor: node.cursor,
|
|
61
|
+
})),
|
|
62
|
+
totalCount: res.totalCount ?? 0,
|
|
63
|
+
pageInfo: {
|
|
64
|
+
hasNextPage: Boolean(res.next),
|
|
65
|
+
endCursor: res.next,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return {
|
|
71
|
+
edges: [],
|
|
72
|
+
totalCount: 0,
|
|
73
|
+
pageInfo: {
|
|
74
|
+
hasNextPage: false,
|
|
75
|
+
endCursor: null,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export const getGames__next = cache(async (input, options) => {
|
|
81
|
+
const search = new URLSearchParams();
|
|
82
|
+
if (input?.first)
|
|
83
|
+
search.set('first', input.first.toString());
|
|
84
|
+
if (input?.after)
|
|
85
|
+
search.set('after', input.after);
|
|
86
|
+
if (input?.search)
|
|
87
|
+
search.set('search', input.search);
|
|
88
|
+
if (input?.filter?.type?.equal)
|
|
89
|
+
search.set('filter[type][eq]', input.filter.type.equal);
|
|
90
|
+
if (input?.filter?.type?.notEqual)
|
|
91
|
+
search.set('filter[type][neq]', input.filter.type.notEqual);
|
|
92
|
+
if (input?.filter?.type?.in)
|
|
93
|
+
search.set('filter[type][in]', input.filter.type.in.join(','));
|
|
94
|
+
if (input?.filter?.type?.notIn)
|
|
95
|
+
search.set('filter[type][nin]', input.filter.type.notIn.join(','));
|
|
96
|
+
if (input?.filter?.provider?.equal)
|
|
97
|
+
search.set('filter[provider][eq]', input.filter.provider.equal);
|
|
98
|
+
if (input?.filter?.provider?.notEqual)
|
|
99
|
+
search.set('filter[provider][neq]', input.filter.provider.notEqual);
|
|
100
|
+
if (input?.filter?.provider?.in)
|
|
101
|
+
search.set('filter[provider][in]', input.filter.provider.in.join(','));
|
|
102
|
+
if (input?.filter?.provider?.notIn)
|
|
103
|
+
search.set('filter[provider][nin]', input.filter.provider.notIn.join(','));
|
|
104
|
+
if (input?.filter?.tags?.equal)
|
|
105
|
+
search.set('filter[tags][eq]', input.filter.tags.equal.toLowerCase());
|
|
106
|
+
if (input?.filter?.tags?.notEqual)
|
|
107
|
+
search.set('filter[tags][neq]', input.filter.tags.notEqual.toLowerCase());
|
|
108
|
+
if (input?.filter?.tags?.in)
|
|
109
|
+
search.set('filter[tags][in]', input.filter.tags.in.map((v) => v.toLowerCase()).join(','));
|
|
110
|
+
if (input?.filter?.tags?.notIn)
|
|
111
|
+
search.set('filter[tags][nin]', input.filter.tags.notIn.map((v) => v.toLowerCase()).join(','));
|
|
112
|
+
if (input?.filter?.reference?.equal)
|
|
113
|
+
search.set('filter[reference][eq]', input.filter.reference.equal);
|
|
114
|
+
if (input?.filter?.reference?.notEqual)
|
|
115
|
+
search.set('filter[reference][neq]', input.filter.reference.notEqual);
|
|
116
|
+
if (input?.filter?.reference?.in)
|
|
117
|
+
search.set('filter[reference][in]', input.filter.reference.in.join(','));
|
|
118
|
+
if (input?.filter?.reference?.notIn)
|
|
119
|
+
search.set('filter[reference][nin]', input.filter.reference.notIn.join(','));
|
|
120
|
+
if (input?.sort) {
|
|
121
|
+
search.set('sort[order]', input.sort.order);
|
|
122
|
+
search.set('sort[context]', input.sort.context.toLowerCase());
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
const res = await httpRequest.json(`${CMS_PORTAL_ENDPOINT}/v2/games?${search.toString()}`, options);
|
|
126
|
+
return {
|
|
127
|
+
edges: res.data.map((node) => ({
|
|
128
|
+
node,
|
|
129
|
+
cursor: node.cursor,
|
|
130
|
+
})),
|
|
131
|
+
totalCount: res.totalCount ?? 0,
|
|
132
|
+
pageInfo: {
|
|
133
|
+
endCursor: res.next,
|
|
134
|
+
hasNextPage: Boolean(res.next),
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return {
|
|
140
|
+
edges: [],
|
|
141
|
+
totalCount: 0,
|
|
142
|
+
pageInfo: {
|
|
143
|
+
hasNextPage: false,
|
|
144
|
+
endCursor: null,
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { File } from '../types';
|
|
2
|
+
import { type GraphQLRequestOptions } from './graphqlRequest';
|
|
3
|
+
export interface FileQuery {
|
|
4
|
+
node?: File | null;
|
|
5
|
+
}
|
|
6
|
+
export interface FileQueryVariables {
|
|
7
|
+
id: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const getFile: (id: string, options?: GraphQLRequestOptions) => Promise<File | null>;
|
|
10
|
+
export type UploadPrivateImageFileError = {
|
|
11
|
+
name: 'FileFormatNotSupportedError';
|
|
12
|
+
message: string;
|
|
13
|
+
} | {
|
|
14
|
+
name: 'FileNameTooLongError';
|
|
15
|
+
message: string;
|
|
16
|
+
} | {
|
|
17
|
+
name: 'FileSizeTooBigError';
|
|
18
|
+
message: string;
|
|
19
|
+
};
|
|
20
|
+
export interface UploadPrivateImageFileMutation {
|
|
21
|
+
uploadPrivateImageFile?: null | UploadPrivateImageFileError;
|
|
22
|
+
}
|
|
23
|
+
export interface UploadPrivateImageFileMutationVariables {
|
|
24
|
+
input: {
|
|
25
|
+
id: string;
|
|
26
|
+
file: globalThis.File;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface UploadPrivateImageFileInput {
|
|
30
|
+
id: string;
|
|
31
|
+
file: globalThis.File;
|
|
32
|
+
}
|
|
33
|
+
export declare const uploadPrivateImageFile: (input: UploadPrivateImageFileInput, options?: GraphQLRequestOptions) => Promise<void>;
|