@opexa/portal-components 0.0.85 → 0.0.87
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/useCreateGCashDepositMutation.js +2 -1
- package/dist/client/hooks/useCreateGCashWithdrawalMutation.js +2 -1
- package/dist/client/hooks/useCreateGameSessionMutation.js +2 -1
- package/dist/client/hooks/useCreateInstapayWithdrawalMutation.js +2 -1
- package/dist/client/hooks/useCreateMayaAppDepositMutation.js +2 -1
- package/dist/client/hooks/useCreateMayaAppWithdrawalMutation.js +2 -1
- package/dist/client/hooks/useCreateMayaDepositMutation.js +2 -1
- package/dist/client/hooks/useCreateMayaWithdrawalMutation.js +2 -1
- package/dist/client/hooks/useCreateOnlineBankDepositMutation.js +2 -1
- package/dist/client/hooks/useCreateQRPHDepositMutation.js +2 -1
- package/dist/components/Account/Account.d.ts +0 -2
- package/dist/components/Account/Account.js +10 -8
- package/dist/components/Account/AccountTrigger.d.ts +1 -2
- package/dist/components/Account/AccountTrigger.js +18 -6
- package/dist/components/Bonuses/BonusesTrigger.d.ts +1 -1
- package/dist/components/Bonuses/BonusesTrigger.js +3 -3
- package/dist/components/DepositWithdrawal/DepositWithdrawal.d.ts +1 -6
- package/dist/components/DepositWithdrawal/DepositWithdrawal.js +8 -19
- package/dist/components/DepositWithdrawal/DepositWithdrawalTrigger.d.ts +1 -1
- package/dist/components/DepositWithdrawal/DepositWithdrawalTrigger.js +12 -4
- package/dist/components/Jackpots/Jackpots.d.ts +3 -9
- package/dist/components/Jackpots/Jackpots.js +8 -2
- package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarousel.d.ts +20 -0
- package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarousel.js +64 -0
- package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselContext.d.ts +2 -0
- package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselContext.js +2 -0
- package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselItem.d.ts +9 -0
- package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselItem.js +107 -0
- package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselItem.module.css +184 -0
- package/dist/components/Jackpots/JackpotsList/JackpotsList.d.ts +11 -0
- package/dist/components/Jackpots/JackpotsList/JackpotsList.js +29 -0
- package/dist/components/Jackpots/JackpotsList/JackpotsListContext.d.ts +4 -0
- package/dist/components/Jackpots/JackpotsList/JackpotsListContext.js +3 -0
- package/dist/components/Jackpots/JackpotsList/JackpotsListItem.module.css +184 -0
- package/dist/components/Jackpots/JackpotsList/JackpotsListItemDesktop.d.ts +1 -0
- package/dist/components/Jackpots/JackpotsList/JackpotsListItemDesktop.js +44 -0
- package/dist/components/Jackpots/JackpotsList/JackpotsListItemGameProviders.d.ts +5 -0
- package/dist/components/Jackpots/JackpotsList/JackpotsListItemGameProviders.js +40 -0
- package/dist/components/Jackpots/JackpotsList/JackpotsListItemMobile.d.ts +1 -0
- package/dist/components/Jackpots/JackpotsList/JackpotsListItemMobile.js +45 -0
- package/dist/components/Jackpots/JackpotsList/JackpotsListItemRules.d.ts +2 -0
- package/dist/components/Jackpots/JackpotsList/JackpotsListItemRules.js +10 -0
- package/dist/components/Jackpots/JackpotsList/useJackpotsListItemData.d.ts +14 -0
- package/dist/components/Jackpots/JackpotsList/useJackpotsListItemData.js +92 -0
- package/dist/components/Messages/Message.d.ts +1 -4
- package/dist/components/Messages/Message.js +8 -9
- package/dist/components/Messages/MessageContext.d.ts +2 -0
- package/dist/components/Messages/MessageContext.js +2 -0
- package/dist/components/Messages/Messages.d.ts +0 -1
- package/dist/components/Messages/Messages.js +9 -8
- package/dist/components/Messages/MessagesTrigger.d.ts +1 -1
- package/dist/components/Messages/MessagesTrigger.js +8 -4
- package/dist/components/PortalProvider/Providers.js +1 -5
- package/dist/components/SignUp/SignUpForm.js +2 -1
- package/dist/components/Tournaments/Tournaments.d.ts +3 -7
- package/dist/components/Tournaments/Tournaments.js +8 -2
- package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarousel.d.ts +9 -0
- package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarousel.js +51 -0
- package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarouselContext.d.ts +2 -0
- package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarouselContext.js +2 -0
- package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarouselItem.d.ts +6 -0
- package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarouselItem.js +107 -0
- package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarouselItem.module.css +184 -0
- package/dist/components/Tournaments/TournamentsList/TournamentItem.module.css +184 -0
- package/dist/components/Tournaments/TournamentsList/TournamentsList.d.ts +9 -0
- package/dist/components/Tournaments/TournamentsList/TournamentsList.js +20 -0
- package/dist/components/Tournaments/TournamentsList/TournamentsListContext.d.ts +4 -0
- package/dist/components/Tournaments/TournamentsList/TournamentsListContext.js +3 -0
- package/dist/components/Tournaments/TournamentsList/TournamentsListItemDesktop.d.ts +1 -0
- package/dist/components/Tournaments/TournamentsList/TournamentsListItemDesktop.js +55 -0
- package/dist/components/Tournaments/TournamentsList/TournamentsListItemGameProviders.d.ts +5 -0
- package/dist/components/Tournaments/TournamentsList/TournamentsListItemGameProviders.js +37 -0
- package/dist/components/Tournaments/TournamentsList/TournamentsListItemMobile.d.ts +1 -0
- package/dist/components/Tournaments/TournamentsList/TournamentsListItemMobile.js +55 -0
- package/dist/components/Tournaments/TournamentsList/TournamentsListItemRules.d.ts +2 -0
- package/dist/components/Tournaments/TournamentsList/TournamentsListItemRules.js +9 -0
- package/dist/components/Tournaments/TournamentsList/useTournamentListItemData.d.ts +10 -0
- package/dist/components/Tournaments/TournamentsList/useTournamentListItemData.js +71 -0
- package/dist/components/index.d.ts +0 -2
- package/dist/components/index.js +0 -2
- package/dist/handlers.js +1 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.js +1 -0
- package/dist/services/ObjectId.d.ts +0 -14
- package/dist/services/ObjectId.js +62 -76
- package/dist/services/ObjectType.d.ts +10 -0
- package/dist/services/ObjectType.js +10 -0
- package/dist/services/index.d.ts +4 -3
- package/dist/services/index.js +4 -3
- package/dist/styles/theme.css +2 -2
- package/dist/ui/AlertDialog/AlertDialog.d.ts +89 -89
- package/dist/ui/AlertDialog/AlertDialog.js +2 -1
- package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +8 -8
- package/dist/ui/AlertDialog/alertDialog.recipe.js +1 -1
- package/dist/ui/Avatar/Avatar.d.ts +1 -1
- package/dist/ui/Avatar/Avatar.js +1 -1
- package/dist/ui/Avatar/avatar.recipe.js +1 -1
- package/dist/ui/Badge/Badge.js +1 -1
- package/dist/ui/Button/Button.js +1 -1
- package/dist/ui/Checkbox/Checkbox.d.ts +24 -24
- package/dist/ui/Checkbox/Checkbox.js +1 -1
- package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
- package/dist/ui/Checkbox/checkbox.recipe.js +1 -1
- package/dist/ui/Clipboard/Clipboard.d.ts +19 -19
- package/dist/ui/Clipboard/Clipboard.js +1 -1
- package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
- package/dist/ui/Clipboard/clipboard.recipe.js +1 -1
- package/dist/ui/Collapsible/Collapsible.d.ts +21 -21
- package/dist/ui/Collapsible/Collapsible.js +1 -1
- package/dist/ui/Collapsible/collapsible.recipe.d.ts +5 -5
- package/dist/ui/Collapsible/collapsible.recipe.js +1 -1
- package/dist/ui/Combobox/Combobox.d.ts +43 -43
- package/dist/ui/Combobox/Combobox.js +1 -1
- package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
- package/dist/ui/Combobox/combobox.recipe.js +1 -1
- package/dist/ui/DatePicker/DatePicker.d.ts +265 -265
- package/dist/ui/DatePicker/DatePicker.js +1 -1
- package/dist/ui/DatePicker/datePicker.recipe.d.ts +11 -11
- package/dist/ui/DatePicker/datePicker.recipe.js +1 -1
- package/dist/ui/Dialog/Dialog.d.ts +89 -89
- package/dist/ui/Dialog/Dialog.js +2 -1
- package/dist/ui/Dialog/dialog.recipe.d.ts +8 -8
- package/dist/ui/Dialog/dialog.recipe.js +1 -1
- package/dist/ui/Drawer/Drawer.d.ts +34 -34
- package/dist/ui/Drawer/Drawer.js +2 -1
- package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
- package/dist/ui/Drawer/drawer.recipe.js +1 -1
- package/dist/ui/Field/Field.d.ts +1 -1
- package/dist/ui/Field/Field.js +1 -1
- package/dist/ui/Field/field.recipe.js +1 -1
- package/dist/ui/IconButton/IconButton.js +1 -1
- package/dist/ui/NumberInput/NumberInput.d.ts +1 -1
- package/dist/ui/NumberInput/NumberInput.js +1 -1
- package/dist/ui/NumberInput/numberInput.recipe.js +1 -1
- package/dist/ui/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/ui/PasswordInput/PasswordInput.js +1 -1
- package/dist/ui/PasswordInput/passwordInput.recipe.js +1 -1
- package/dist/ui/PinInput/PinInput.d.ts +1 -1
- package/dist/ui/PinInput/PinInput.js +1 -1
- package/dist/ui/PinInput/pinInput.recipe.js +1 -1
- package/dist/ui/Popover/Popover.d.ts +56 -56
- package/dist/ui/Popover/Popover.js +1 -1
- package/dist/ui/Popover/popover.recipe.d.ts +5 -5
- package/dist/ui/Popover/popover.recipe.js +1 -1
- package/dist/ui/Progress/Progress.d.ts +1 -1
- package/dist/ui/Progress/Progress.js +1 -1
- package/dist/ui/Progress/progress.recipe.js +1 -1
- package/dist/ui/SegmentGroup/SegmentGroup.d.ts +1 -1
- package/dist/ui/SegmentGroup/SegmentGroup.js +1 -1
- package/dist/ui/SegmentGroup/segmentGroup.recipe.js +1 -1
- package/dist/ui/Select/Select.d.ts +46 -46
- package/dist/ui/Select/Select.js +1 -1
- package/dist/ui/Select/select.recipe.d.ts +3 -3
- package/dist/ui/Select/select.recipe.js +1 -1
- package/dist/ui/Table/Table.d.ts +21 -21
- package/dist/ui/Table/Table.js +1 -1
- package/dist/ui/Table/table.recipe.d.ts +3 -3
- package/dist/ui/Tabs/Tabs.d.ts +16 -16
- package/dist/ui/Tabs/Tabs.js +1 -1
- package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
- package/dist/ui/Tabs/tabs.recipe.js +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/isStyleEntries.d.ts +2 -0
- package/dist/utils/isStyleEntries.js +5 -0
- package/package.json +27 -30
- package/dist/utils/graphqlRequest.d.ts +0 -4
- package/dist/utils/graphqlRequest.js +0 -255
- package/dist/utils/httpRequest.d.ts +0 -6
- package/dist/utils/httpRequest.js +0 -87
- package/dist/utils/sha256.d.ts +0 -4
- package/dist/utils/sha256.js +0 -16
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { BYPASS_RECAPTCHA, PLATFORM_CODE, PLATFORM_ID, SITE_ID, TEST_PASS_HEADER_KEY, } from '../constants/index.js';
|
|
3
|
-
export async function graphqlRequest(url, query, variables, options) {
|
|
4
|
-
const headers = new Headers();
|
|
5
|
-
headers.set('Role', 'MEMBER');
|
|
6
|
-
headers.set('Site-ID', SITE_ID);
|
|
7
|
-
headers.set('Platform-ID', PLATFORM_ID);
|
|
8
|
-
headers.set('Platform-Code', PLATFORM_CODE);
|
|
9
|
-
headers.set('Accept', 'application/json');
|
|
10
|
-
headers.set('Content-Type', 'application/json');
|
|
11
|
-
new Headers(options?.headers).forEach((value, key) => {
|
|
12
|
-
headers.set(key, value);
|
|
13
|
-
});
|
|
14
|
-
if (BYPASS_RECAPTCHA) {
|
|
15
|
-
headers.set(TEST_PASS_HEADER_KEY, '');
|
|
16
|
-
}
|
|
17
|
-
const info = getOperationInfo(query);
|
|
18
|
-
const url_ = new URL(url);
|
|
19
|
-
if (info) {
|
|
20
|
-
url_.searchParams.set(`_${info.type}`, info.name);
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
const response = await fetch(url_, {
|
|
24
|
-
...options,
|
|
25
|
-
method: 'POST',
|
|
26
|
-
headers,
|
|
27
|
-
body: JSON.stringify({
|
|
28
|
-
query,
|
|
29
|
-
variables,
|
|
30
|
-
}),
|
|
31
|
-
});
|
|
32
|
-
if (response.status === 400) {
|
|
33
|
-
const error = new Error();
|
|
34
|
-
error.name = 'GraphQLRequestError';
|
|
35
|
-
error.message = 'Bad Request';
|
|
36
|
-
Error.captureStackTrace?.(error, graphqlRequest);
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
if (response.status === 401) {
|
|
40
|
-
const error = new Error();
|
|
41
|
-
error.name = 'GraphQLRequestError';
|
|
42
|
-
error.message = 'Unauthorized';
|
|
43
|
-
Error.captureStackTrace?.(error, graphqlRequest);
|
|
44
|
-
throw error;
|
|
45
|
-
}
|
|
46
|
-
if (response.status === 403) {
|
|
47
|
-
const error = new Error();
|
|
48
|
-
error.name = 'GraphQLRequestError';
|
|
49
|
-
error.message = 'Forbidden';
|
|
50
|
-
Error.captureStackTrace?.(error, graphqlRequest);
|
|
51
|
-
throw error;
|
|
52
|
-
}
|
|
53
|
-
if (!response.ok) {
|
|
54
|
-
const error = new Error();
|
|
55
|
-
error.name = 'GraphQLRequestError';
|
|
56
|
-
error.message = 'Network error';
|
|
57
|
-
Error.captureStackTrace?.(error, graphqlRequest);
|
|
58
|
-
throw error;
|
|
59
|
-
}
|
|
60
|
-
const obj = (await response.json());
|
|
61
|
-
if (!obj.errors?.length)
|
|
62
|
-
return obj.data;
|
|
63
|
-
const error = new Error();
|
|
64
|
-
if (obj.errors[0].extensions?.code === 'FORBIDDEN') {
|
|
65
|
-
error.name = 'GraphQLRequestError';
|
|
66
|
-
error.message = 'Forbidden';
|
|
67
|
-
}
|
|
68
|
-
else if (obj.errors[0].extensions?.code === 'ACCESS_TOKEN_EXPIRED') {
|
|
69
|
-
error.name = 'GraphQLRequestError';
|
|
70
|
-
error.message = 'Access Token Expired';
|
|
71
|
-
}
|
|
72
|
-
else if (obj.errors[0].extensions?.code === 'UNAUTHORIZED') {
|
|
73
|
-
error.name = 'GraphQLRequestError';
|
|
74
|
-
error.message = 'Unauthorized';
|
|
75
|
-
}
|
|
76
|
-
else if (obj.errors[0].extensions?.code === 'BAD_USER_INPUT') {
|
|
77
|
-
error.name = 'GraphQLRequestError';
|
|
78
|
-
error.message = 'Bad User Input';
|
|
79
|
-
}
|
|
80
|
-
else if (obj.errors[0].extensions?.code === 'BAD_REQUEST') {
|
|
81
|
-
error.name = 'GraphQLRequestError';
|
|
82
|
-
error.message = 'Bad Request';
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
error.name = 'GraphQLRequestError';
|
|
86
|
-
error.message = 'Internal Server Error';
|
|
87
|
-
}
|
|
88
|
-
Error.captureStackTrace?.(error, graphqlRequest);
|
|
89
|
-
throw error;
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
if (error instanceof Error) {
|
|
93
|
-
throw error;
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
const e = new Error();
|
|
97
|
-
e.name = 'GraphQLRequestError';
|
|
98
|
-
e.message = 'Network error';
|
|
99
|
-
Error.captureStackTrace?.(e, graphqlRequest);
|
|
100
|
-
throw e;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
export async function graphqlUpload(url, query, variables, options) {
|
|
105
|
-
const headers = new Headers();
|
|
106
|
-
new Headers(options?.headers).forEach((value, key) => {
|
|
107
|
-
headers.set(key, value);
|
|
108
|
-
});
|
|
109
|
-
headers.set('Role', 'MEMBER');
|
|
110
|
-
headers.set('Site-ID', SITE_ID);
|
|
111
|
-
headers.set('Platform-ID', PLATFORM_ID);
|
|
112
|
-
headers.set('Platform-Code', PLATFORM_CODE);
|
|
113
|
-
headers.delete('Content-Type');
|
|
114
|
-
if (BYPASS_RECAPTCHA) {
|
|
115
|
-
headers.set(TEST_PASS_HEADER_KEY, '');
|
|
116
|
-
}
|
|
117
|
-
const body = createUploadBody(query, variables);
|
|
118
|
-
const info = getOperationInfo(query);
|
|
119
|
-
const url_ = new URL(url);
|
|
120
|
-
if (info) {
|
|
121
|
-
url_.searchParams.set(`_${info.type}`, info.name);
|
|
122
|
-
}
|
|
123
|
-
try {
|
|
124
|
-
const response = await fetch(url_, {
|
|
125
|
-
...options,
|
|
126
|
-
method: 'POST',
|
|
127
|
-
headers,
|
|
128
|
-
body,
|
|
129
|
-
});
|
|
130
|
-
if (response.status === 400) {
|
|
131
|
-
const error = new Error();
|
|
132
|
-
error.name = 'GraphQLUploadError';
|
|
133
|
-
error.message = 'Bad Request';
|
|
134
|
-
Error.captureStackTrace?.(error, graphqlUpload);
|
|
135
|
-
throw error;
|
|
136
|
-
}
|
|
137
|
-
if (response.status === 401) {
|
|
138
|
-
const error = new Error();
|
|
139
|
-
error.name = 'GraphQLUploadError';
|
|
140
|
-
error.message = 'Unauthorized';
|
|
141
|
-
Error.captureStackTrace?.(error, graphqlUpload);
|
|
142
|
-
throw error;
|
|
143
|
-
}
|
|
144
|
-
if (response.status === 403) {
|
|
145
|
-
const error = new Error();
|
|
146
|
-
error.name = 'GraphQLUploadError';
|
|
147
|
-
error.message = 'Forbidden';
|
|
148
|
-
Error.captureStackTrace?.(error, graphqlUpload);
|
|
149
|
-
throw error;
|
|
150
|
-
}
|
|
151
|
-
if (!response.ok) {
|
|
152
|
-
const error = new Error();
|
|
153
|
-
error.name = 'GraphQLUploadError';
|
|
154
|
-
error.message = 'Failed to upload file';
|
|
155
|
-
Error.captureStackTrace?.(error, graphqlUpload);
|
|
156
|
-
throw error;
|
|
157
|
-
}
|
|
158
|
-
const obj = (await response.json());
|
|
159
|
-
if (!obj.errors?.length)
|
|
160
|
-
return obj.data;
|
|
161
|
-
const error = new Error();
|
|
162
|
-
if (obj.errors[0].extensions?.code === 'FORBIDDEN') {
|
|
163
|
-
error.name = 'GraphQLUploadError';
|
|
164
|
-
error.message = 'Forbidden';
|
|
165
|
-
}
|
|
166
|
-
else if (obj.errors[0].extensions?.code === 'ACCESS_TOKEN_EXPIRED') {
|
|
167
|
-
error.name = 'GraphQLUploadError';
|
|
168
|
-
error.message = 'Access Token Expired';
|
|
169
|
-
}
|
|
170
|
-
else if (obj.errors[0].extensions?.code === 'UNAUTHORIZED') {
|
|
171
|
-
error.name = 'GraphQLUploadError';
|
|
172
|
-
error.message = 'Unauthorized';
|
|
173
|
-
}
|
|
174
|
-
else if (obj.errors[0].extensions?.code === 'BAD_USER_INPUT') {
|
|
175
|
-
error.name = 'GraphQLUploadError';
|
|
176
|
-
error.message = 'Bad User Input';
|
|
177
|
-
}
|
|
178
|
-
else if (obj.errors[0].extensions?.code === 'BAD_REQUEST') {
|
|
179
|
-
error.name = 'GraphQLUploadError';
|
|
180
|
-
error.message = 'Bad Request';
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
error.name = 'GraphQLUploadError';
|
|
184
|
-
error.message = 'Internal Server Error';
|
|
185
|
-
}
|
|
186
|
-
Error.captureStackTrace?.(error, graphqlUpload);
|
|
187
|
-
throw error;
|
|
188
|
-
}
|
|
189
|
-
catch (error) {
|
|
190
|
-
if (error instanceof Error) {
|
|
191
|
-
throw error;
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
const error = new Error();
|
|
195
|
-
error.name = 'GraphQLUploadError';
|
|
196
|
-
error.message = 'Network error';
|
|
197
|
-
Error.captureStackTrace?.(error, graphqlUpload);
|
|
198
|
-
throw error;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
function getOperationInfo(query) {
|
|
203
|
-
const l = query.match(/(query|mutation)\s+(\w+)/);
|
|
204
|
-
if (!l)
|
|
205
|
-
return null;
|
|
206
|
-
const k = l.at(1);
|
|
207
|
-
const v = l.at(2);
|
|
208
|
-
return k && v ? { type: k, name: v } : null;
|
|
209
|
-
}
|
|
210
|
-
function createUploadBody(query, variables) {
|
|
211
|
-
const files = pair(variables).filter((o) => o.value instanceof File || o.value instanceof Blob);
|
|
212
|
-
const body = new FormData();
|
|
213
|
-
body.append('operations', JSON.stringify({
|
|
214
|
-
query,
|
|
215
|
-
variables,
|
|
216
|
-
}));
|
|
217
|
-
const map = {};
|
|
218
|
-
files.forEach((o, i) => {
|
|
219
|
-
map[i.toString()] = [`variables.${o.key.join('.')}`];
|
|
220
|
-
});
|
|
221
|
-
body.append('map', JSON.stringify(map));
|
|
222
|
-
files.forEach((o, i) => {
|
|
223
|
-
body.append(i.toString(), o.value);
|
|
224
|
-
});
|
|
225
|
-
return body;
|
|
226
|
-
}
|
|
227
|
-
function isPlainObject(value) {
|
|
228
|
-
return (Object.prototype.toString.call(value) === '[object Object]' &&
|
|
229
|
-
Object(value) === value);
|
|
230
|
-
}
|
|
231
|
-
function pair(value) {
|
|
232
|
-
const result = [];
|
|
233
|
-
function fn(o, parentKeys = []) {
|
|
234
|
-
for (const k in o) {
|
|
235
|
-
const v = o[k];
|
|
236
|
-
if (isPlainObject(v)) {
|
|
237
|
-
fn(v, [...parentKeys, k]);
|
|
238
|
-
}
|
|
239
|
-
else if (Array.isArray(v)) {
|
|
240
|
-
fn([...parentKeys, k].reduce((o, v, i) => {
|
|
241
|
-
o[i] = v;
|
|
242
|
-
return o;
|
|
243
|
-
}, {}));
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
result.push({
|
|
247
|
-
key: [...parentKeys, k],
|
|
248
|
-
value: v,
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
fn(value);
|
|
254
|
-
return result;
|
|
255
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export interface HttpRequestOptions extends RequestInit {
|
|
2
|
-
}
|
|
3
|
-
export declare function httpRequest(url: string, opts?: HttpRequestOptions): Promise<Response>;
|
|
4
|
-
export declare namespace httpRequest {
|
|
5
|
-
var json: <T>(url: string, opts?: HttpRequestOptions) => Promise<T>;
|
|
6
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { BYPASS_RECAPTCHA, PLATFORM_CODE, PLATFORM_ID, SITE_ID, TEST_PASS_HEADER_KEY, } from '../constants/index.js';
|
|
3
|
-
export async function httpRequest(url, opts = {}) {
|
|
4
|
-
const headers = new Headers(opts.headers);
|
|
5
|
-
headers.set('Role', 'Member');
|
|
6
|
-
headers.set('Site-ID', SITE_ID);
|
|
7
|
-
headers.set('Platform-ID', PLATFORM_ID);
|
|
8
|
-
headers.set('Platform-Code', PLATFORM_CODE);
|
|
9
|
-
new Headers(opts.headers).forEach((value, key) => {
|
|
10
|
-
headers.set(key, value);
|
|
11
|
-
});
|
|
12
|
-
if (BYPASS_RECAPTCHA) {
|
|
13
|
-
headers.set(TEST_PASS_HEADER_KEY, '');
|
|
14
|
-
}
|
|
15
|
-
const res = await fetch(url, {
|
|
16
|
-
...opts,
|
|
17
|
-
headers,
|
|
18
|
-
});
|
|
19
|
-
if (!res.ok) {
|
|
20
|
-
const code = KnownErrorSchema.parse(await res.json());
|
|
21
|
-
const exception = new Error();
|
|
22
|
-
exception.name = code ?? 'HttpRequestError';
|
|
23
|
-
exception.message = code
|
|
24
|
-
? getErrorMessage(code)
|
|
25
|
-
: `Error ${res.status}: ${res.statusText}`;
|
|
26
|
-
Error.captureStackTrace?.(exception, httpRequest.json);
|
|
27
|
-
throw exception;
|
|
28
|
-
}
|
|
29
|
-
return res;
|
|
30
|
-
}
|
|
31
|
-
httpRequest.json = async (url, opts = {}) => {
|
|
32
|
-
const headers = new Headers();
|
|
33
|
-
headers.set('Role', 'Member');
|
|
34
|
-
headers.set('Site-ID', SITE_ID);
|
|
35
|
-
headers.set('Platform-ID', PLATFORM_ID);
|
|
36
|
-
headers.set('Platform-Code', PLATFORM_CODE);
|
|
37
|
-
headers.set('Accept', 'application/json');
|
|
38
|
-
headers.set('Content-Type', 'application/json');
|
|
39
|
-
new Headers(opts.headers).forEach((value, key) => {
|
|
40
|
-
headers.set(key, value);
|
|
41
|
-
});
|
|
42
|
-
if (BYPASS_RECAPTCHA) {
|
|
43
|
-
headers.set(TEST_PASS_HEADER_KEY, '');
|
|
44
|
-
}
|
|
45
|
-
const response = await fetch(url, {
|
|
46
|
-
...opts,
|
|
47
|
-
headers,
|
|
48
|
-
});
|
|
49
|
-
if (!response.ok) {
|
|
50
|
-
const code = KnownErrorSchema.parse(await response.json());
|
|
51
|
-
const exception = new Error();
|
|
52
|
-
exception.name = code ?? 'HttpRequestError';
|
|
53
|
-
exception.message = code
|
|
54
|
-
? getErrorMessage(code)
|
|
55
|
-
: `Error ${response.status}: ${response.statusText}`;
|
|
56
|
-
Error.captureStackTrace?.(exception, httpRequest.json);
|
|
57
|
-
throw exception;
|
|
58
|
-
}
|
|
59
|
-
const json = await response.json();
|
|
60
|
-
return json;
|
|
61
|
-
};
|
|
62
|
-
const KnownErrorSchema = z
|
|
63
|
-
.object({
|
|
64
|
-
code: z.string().optional(),
|
|
65
|
-
message: z.string().optional(),
|
|
66
|
-
})
|
|
67
|
-
.nullable()
|
|
68
|
-
.catch(null)
|
|
69
|
-
.transform((v) => v?.code ?? v?.message ?? null);
|
|
70
|
-
function getErrorMessage(code) {
|
|
71
|
-
switch (code) {
|
|
72
|
-
case 'ACCOUNT_BLACKLISTED':
|
|
73
|
-
return 'Account is blacklisted';
|
|
74
|
-
case 'MEMBER_ACCOUNT_SUSPENDED':
|
|
75
|
-
return 'Account is suspended';
|
|
76
|
-
case 'INVALID_RECAPTCHA_RESPONSE':
|
|
77
|
-
return 'Invalid reCAPTCHA response';
|
|
78
|
-
case 'MEMBER_NOT_FOUND':
|
|
79
|
-
return 'Account not found';
|
|
80
|
-
case 'RATE_LIMIT_REACH':
|
|
81
|
-
return 'Rate limit exceeded';
|
|
82
|
-
case 'NOT_READY_TO_SEND_VERIFICATION_ERROR':
|
|
83
|
-
return 'Not ready to send verification code';
|
|
84
|
-
default:
|
|
85
|
-
return 'Something went wrong. Please try again later.';
|
|
86
|
-
}
|
|
87
|
-
}
|
package/dist/utils/sha256.d.ts
DELETED
package/dist/utils/sha256.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export async function sha256(input) {
|
|
2
|
-
/*
|
|
3
|
-
* crypto and other node apis are not available in edge runtime
|
|
4
|
-
* ref: https://vercel.com/docs/functions/runtimes/edge#check-if-you're-running-on-the-edge-runtime
|
|
5
|
-
*/
|
|
6
|
-
if (typeof EdgeRuntime === 'string') {
|
|
7
|
-
throw new Error("Cannot use 'sha256' in edge runtime");
|
|
8
|
-
}
|
|
9
|
-
if (typeof window === 'undefined') {
|
|
10
|
-
const crypto = await import('crypto');
|
|
11
|
-
return crypto.createHash('sha256').update(input).digest('hex');
|
|
12
|
-
}
|
|
13
|
-
return Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(input))))
|
|
14
|
-
.map((b) => b.toString(16).padStart(2, '0'))
|
|
15
|
-
.join('');
|
|
16
|
-
}
|