steamutils 1.4.50 → 1.4.51

Sign up to get free protection for your applications and to get access to all the features.
Files changed (234) hide show
  1. package/.idea/codeStyles/Project.xml +0 -1
  2. package/.idea/gbrowser_project.xml +11 -0
  3. package/.idea/git_toolbox_blame.xml +6 -0
  4. package/.idea/git_toolbox_prj.xml +15 -0
  5. package/.prettierrc.json +3 -3
  6. package/SteamClient.js +2718 -2718
  7. package/_steamproto.js +33 -33
  8. package/axios.js +84 -84
  9. package/bufferHelpers.js +115 -115
  10. package/cheerio.js +103 -103
  11. package/const.js +458 -451
  12. package/create_proto.js +96 -96
  13. package/create_remote_file.js +66 -66
  14. package/helpers/protos.js +48 -48
  15. package/index.js +7746 -7746
  16. package/package.json +1 -1
  17. package/protos/csgo/base_gcmessages.proto +553 -553
  18. package/protos/csgo/base_gcmessages_csgo.proto +547 -547
  19. package/protos/csgo/c_peer2peer_netmessages.proto +55 -55
  20. package/protos/csgo/clientmessages.proto +48 -48
  21. package/protos/csgo/connectionless_netmessages.proto +17 -17
  22. package/protos/csgo/cs_gameevents.proto +35 -35
  23. package/protos/csgo/cs_usercmd.proto +34 -34
  24. package/protos/csgo/cstrike15_gcmessages.proto +1431 -1431
  25. package/protos/csgo/cstrike15_usermessages.proto +592 -592
  26. package/protos/csgo/demo.proto +165 -165
  27. package/protos/csgo/econ_gcmessages.proto +219 -219
  28. package/protos/csgo/enums_clientserver.proto +1529 -1529
  29. package/protos/csgo/fatdemo.proto +125 -125
  30. package/protos/csgo/gameevents.proto +120 -120
  31. package/protos/csgo/gcsdk_gcmessages.proto +323 -323
  32. package/protos/csgo/gcsystemmsgs.proto +243 -243
  33. package/protos/csgo/netmessages.proto +618 -618
  34. package/protos/csgo/networkbasetypes.proto +246 -246
  35. package/protos/csgo/networksystem_protomessages.proto +17 -17
  36. package/protos/csgo/steamdatagram_messages_auth.proto +65 -65
  37. package/protos/csgo/steamdatagram_messages_sdr.proto +534 -534
  38. package/protos/csgo/steammessages_cloud.steamworkssdk.proto +68 -68
  39. package/protos/csgo/steammessages_gamenetworkingui.proto +61 -61
  40. package/protos/csgo/steammessages_helprequest.steamworkssdk.proto +22 -22
  41. package/protos/csgo/steammessages_oauth.steamworkssdk.proto +18 -18
  42. package/protos/csgo/steammessages_player.steamworkssdk.proto +254 -254
  43. package/protos/csgo/steammessages_publishedfile.steamworkssdk.proto +233 -233
  44. package/protos/csgo/steamnetworkingsockets_messages.proto +205 -205
  45. package/protos/csgo/steamnetworkingsockets_messages_certs.proto +39 -39
  46. package/protos/csgo/steamnetworkingsockets_messages_udp.proto +75 -75
  47. package/protos/csgo/te.proto +259 -259
  48. package/protos/csgo/uifontfile_format.proto +13 -13
  49. package/protos/csgo/usercmd.proto +39 -39
  50. package/protos/csgo/usermessages.proto +752 -752
  51. package/protos/google/protobuf/descriptor.proto +281 -281
  52. package/protos/steam/clientmetrics.proto +45 -45
  53. package/protos/steam/content_manifest.proto +62 -62
  54. package/protos/steam/contenthubs.proto +41 -41
  55. package/protos/steam/encrypted_app_ticket.proto +10 -10
  56. package/protos/steam/enums.proto +501 -501
  57. package/protos/steam/enums_clientserver.proto +1508 -1508
  58. package/protos/steam/enums_productinfo.proto +14 -14
  59. package/protos/steam/htmlmessages.proto +1039 -1039
  60. package/protos/steam/offline_ticket.proto +8 -8
  61. package/protos/steam/steamdatagram_messages_auth.proto +65 -65
  62. package/protos/steam/steamdatagram_messages_sdr.proto +533 -533
  63. package/protos/steam/steammessages_accounthardware.steamclient.proto +167 -167
  64. package/protos/steam/steammessages_appoverview.proto +204 -204
  65. package/protos/steam/steammessages_auth.steamclient.proto +375 -375
  66. package/protos/steam/steammessages_broadcast.steamclient.proto +618 -618
  67. package/protos/steam/steammessages_chat.steamclient.proto +1070 -1070
  68. package/protos/steam/steammessages_client_objects.proto +649 -649
  69. package/protos/steam/steammessages_clientlanp2p.proto +43 -43
  70. package/protos/steam/steammessages_clientmetrics.steamclient.proto +192 -192
  71. package/protos/steam/steammessages_clientnotificationtypes.proto +250 -250
  72. package/protos/steam/steammessages_clientserver.proto +392 -392
  73. package/protos/steam/steammessages_clientserver_2.proto +771 -771
  74. package/protos/steam/steammessages_clientserver_appinfo.proto +131 -131
  75. package/protos/steam/steammessages_clientserver_friends.proto +260 -260
  76. package/protos/steam/steammessages_clientserver_gameservers.proto +159 -159
  77. package/protos/steam/steammessages_clientserver_lbs.proto +70 -70
  78. package/protos/steam/steammessages_clientserver_login.proto +167 -167
  79. package/protos/steam/steammessages_clientserver_mms.proto +233 -233
  80. package/protos/steam/steammessages_clientserver_ucm.proto +207 -207
  81. package/protos/steam/steammessages_clientserver_uds.proto +125 -125
  82. package/protos/steam/steammessages_clientserver_ufs.proto +45 -45
  83. package/protos/steam/steammessages_clientserver_userstats.proto +80 -80
  84. package/protos/steam/steammessages_cloud.steamclient.proto +422 -422
  85. package/protos/steam/steammessages_contentsystem.steamclient.proto +123 -123
  86. package/protos/steam/steammessages_credentials.steamclient.proto +96 -96
  87. package/protos/steam/steammessages_datapublisher.steamclient.proto +102 -102
  88. package/protos/steam/steammessages_depotbuilder.steamclient.proto +99 -99
  89. package/protos/steam/steammessages_deviceauth.steamclient.proto +169 -169
  90. package/protos/steam/steammessages_econ.steamclient.proto +137 -137
  91. package/protos/steam/steammessages_familygroups.steamclient.proto +441 -441
  92. package/protos/steam/steammessages_friendmessages.steamclient.proto +141 -141
  93. package/protos/steam/steammessages_gamenetworking.steamclient.proto +25 -25
  94. package/protos/steam/steammessages_gamenetworkingui.proto +61 -61
  95. package/protos/steam/steammessages_gamenotifications.steamclient.proto +131 -131
  96. package/protos/steam/steammessages_gameservers.steamclient.proto +136 -136
  97. package/protos/steam/steammessages_hiddevices.proto +157 -157
  98. package/protos/steam/steammessages_inventory.steamclient.proto +172 -172
  99. package/protos/steam/steammessages_linkfilter.steamclient.proto +39 -39
  100. package/protos/steam/steammessages_lobbymatchmaking.steamclient.proto +29 -29
  101. package/protos/steam/steammessages_market.steamclient.proto +22 -22
  102. package/protos/steam/steammessages_marketingmessages.steamclient.proto +273 -273
  103. package/protos/steam/steammessages_offline.steamclient.proto +33 -33
  104. package/protos/steam/steammessages_parental.steamclient.proto +262 -262
  105. package/protos/steam/steammessages_parties.steamclient.proto +75 -75
  106. package/protos/steam/steammessages_partnerapps.steamclient.proto +106 -106
  107. package/protos/steam/steammessages_player.steamclient.proto +915 -915
  108. package/protos/steam/steammessages_publishedfile.steamclient.proto +737 -737
  109. package/protos/steam/steammessages_qms.steamclient.proto +111 -111
  110. package/protos/steam/steammessages_remoteclient.proto +100 -100
  111. package/protos/steam/steammessages_remoteclient_discovery.proto +244 -244
  112. package/protos/steam/steammessages_remoteclient_service.steamclient.proto +31 -31
  113. package/protos/steam/steammessages_remoteclient_service_messages.proto +217 -217
  114. package/protos/steam/steammessages_remoteplay.proto +975 -975
  115. package/protos/steam/steammessages_secrets.steamclient.proto +35 -35
  116. package/protos/steam/steammessages_shader.steamclient.proto +89 -89
  117. package/protos/steam/steammessages_site_license.steamclient.proto +103 -103
  118. package/protos/steam/steammessages_sitelicenseclient.proto +38 -38
  119. package/protos/steam/steammessages_siteserverui.proto +130 -130
  120. package/protos/steam/steammessages_steamtv.steamclient.proto +533 -533
  121. package/protos/steam/steammessages_store.steamclient.proto +404 -404
  122. package/protos/steam/steammessages_storebrowse.steamclient.proto +457 -457
  123. package/protos/steam/steammessages_timedtrial.steamclient.proto +40 -40
  124. package/protos/steam/steammessages_twofactor.steamclient.proto +157 -157
  125. package/protos/steam/steammessages_unified_test.steamclient.proto +51 -51
  126. package/protos/steam/steammessages_useraccount.steamclient.proto +211 -211
  127. package/protos/steam/steammessages_vac.steamclient.proto +37 -37
  128. package/protos/steam/steammessages_video.steamclient.proto +68 -68
  129. package/protos/steam/steammessages_virtualcontroller.proto +138 -138
  130. package/protos/steam/steammessages_workshop.steamclient.proto +19 -19
  131. package/protos/steam/steamnetworkingsockets_messages.proto +205 -205
  132. package/protos/steam/steamnetworkingsockets_messages_certs.proto +39 -39
  133. package/protos/steam/steamnetworkingsockets_messages_udp.proto +75 -75
  134. package/protos/steam/webuimessages_achievements.proto +29 -29
  135. package/protos/steam/webuimessages_gamenotes.proto +21 -21
  136. package/protos/steam/webuimessages_gamescope.proto +57 -57
  137. package/protos/steam/webuimessages_steamengine.proto +41 -41
  138. package/protos/steam/webuimessages_steamos.proto +114 -114
  139. package/protos/steam/webuimessages_storagedevicemanager.proto +110 -110
  140. package/protos/steam/webuimessages_systemmanager.proto +17 -17
  141. package/protos/steam/webuimessages_transport.proto +22 -22
  142. package/protos/steam/webuimessages_transportvalidation.proto +111 -111
  143. package/protos/webui/common.proto +4024 -4024
  144. package/protos/webui/service_accountcart.proto +153 -153
  145. package/protos/webui/service_accountlinking.proto +27 -27
  146. package/protos/webui/service_accountprivacy.proto +42 -42
  147. package/protos/webui/service_accountprivateapps.proto +34 -34
  148. package/protos/webui/service_auction.proto +97 -97
  149. package/protos/webui/service_authentication.proto +222 -222
  150. package/protos/webui/service_authenticationsupport.proto +74 -74
  151. package/protos/webui/service_broadcast.proto +562 -562
  152. package/protos/webui/service_chat.proto +11 -11
  153. package/protos/webui/service_chatroom.proto +810 -810
  154. package/protos/webui/service_chatusability.proto +107 -107
  155. package/protos/webui/service_checkout.proto +84 -84
  156. package/protos/webui/service_clan.proto +41 -41
  157. package/protos/webui/service_clanchatrooms.proto +25 -25
  158. package/protos/webui/service_clanfaqs.proto +202 -202
  159. package/protos/webui/service_clientcomm.proto +151 -151
  160. package/protos/webui/service_clientmetrics.proto +22 -22
  161. package/protos/webui/service_cloud.proto +222 -222
  162. package/protos/webui/service_cloudconfigstore.proto +51 -51
  163. package/protos/webui/service_cloudgaming.proto +30 -30
  164. package/protos/webui/service_community.proto +365 -365
  165. package/protos/webui/service_dailydeal.proto +89 -89
  166. package/protos/webui/service_econ.proto +134 -134
  167. package/protos/webui/service_embedded.proto +24 -24
  168. package/protos/webui/service_experimentservice.proto +6 -6
  169. package/protos/webui/service_familygroups.proto +355 -355
  170. package/protos/webui/service_fovasvideo.proto +15 -15
  171. package/protos/webui/service_friendmessages.proto +133 -133
  172. package/protos/webui/service_friendslist.proto +70 -70
  173. package/protos/webui/service_gamenotes.proto +15 -15
  174. package/protos/webui/service_gamerecording.proto +265 -265
  175. package/protos/webui/service_gamerecordingclip.proto +85 -85
  176. package/protos/webui/service_gamerecordingdebug.proto +52 -52
  177. package/protos/webui/service_helprequestlogs.proto +16 -16
  178. package/protos/webui/service_loyaltyrewards.proto +252 -252
  179. package/protos/webui/service_marketingmessages.proto +215 -215
  180. package/protos/webui/service_mobileapp.proto +18 -18
  181. package/protos/webui/service_mobileauth.proto +24 -24
  182. package/protos/webui/service_mobiledevice.proto +26 -26
  183. package/protos/webui/service_mobileperaccount.proto +31 -31
  184. package/protos/webui/service_news.proto +110 -110
  185. package/protos/webui/service_parental.proto +258 -258
  186. package/protos/webui/service_partnermembershipinvite.proto +34 -34
  187. package/protos/webui/service_partnerstorebrowse.proto +28 -28
  188. package/protos/webui/service_phone.proto +51 -51
  189. package/protos/webui/service_physicalgoods.proto +15 -15
  190. package/protos/webui/service_player.proto +918 -918
  191. package/protos/webui/service_promotioneventinvites.proto +109 -109
  192. package/protos/webui/service_promotionplanning.proto +186 -186
  193. package/protos/webui/service_promotionstats.proto +23 -23
  194. package/protos/webui/service_publishedfile.proto +714 -714
  195. package/protos/webui/service_publishing.proto +200 -200
  196. package/protos/webui/service_quest.proto +127 -127
  197. package/protos/webui/service_salefeature.proto +373 -373
  198. package/protos/webui/service_saleitemrewards.proto +54 -54
  199. package/protos/webui/service_shoppingcart.proto +152 -152
  200. package/protos/webui/service_steamawards.proto +76 -76
  201. package/protos/webui/service_steamcharts.proto +75 -75
  202. package/protos/webui/service_steamengine.proto +36 -36
  203. package/protos/webui/service_steamlearn.proto +876 -876
  204. package/protos/webui/service_steamnotification.proto +73 -73
  205. package/protos/webui/service_steamtv.proto +495 -495
  206. package/protos/webui/service_steamvrvoicechat.proto +67 -67
  207. package/protos/webui/service_steamvrwebrtc.proto +48 -48
  208. package/protos/webui/service_storagedevicemanager.proto +104 -104
  209. package/protos/webui/service_store.proto +359 -359
  210. package/protos/webui/service_storeappsimilarity.proto +76 -76
  211. package/protos/webui/service_storebrowse.proto +103 -103
  212. package/protos/webui/service_storemarketing.proto +44 -44
  213. package/protos/webui/service_storequery.proto +103 -103
  214. package/protos/webui/service_storesales.proto +87 -87
  215. package/protos/webui/service_storetopsellers.proto +44 -44
  216. package/protos/webui/service_systemmanager.proto +11 -11
  217. package/protos/webui/service_test_transporterror.proto +6 -6
  218. package/protos/webui/service_transportauth.proto +17 -17
  219. package/protos/webui/service_transportvalidation.proto +69 -69
  220. package/protos/webui/service_twofactor.proto +170 -170
  221. package/protos/webui/service_useraccount.proto +142 -142
  222. package/protos/webui/service_usergameactivity.proto +34 -34
  223. package/protos/webui/service_usergamenotes.proto +70 -70
  224. package/protos/webui/service_usernews.proto +68 -68
  225. package/protos/webui/service_userreviews.proto +97 -97
  226. package/protos/webui/service_video.proto +50 -50
  227. package/protos/webui/service_videoclip.proto +62 -62
  228. package/protos/webui/service_voicechat.proto +139 -139
  229. package/protos/webui/service_webrtc.proto +52 -52
  230. package/remote.js +6784 -6784
  231. package/steamproto.js +34 -34
  232. package/utils.js +986 -872
  233. package/.idea/deployment.xml +0 -14
  234. package/full_steamproto.js +0 -35
package/utils.js CHANGED
@@ -1,872 +1,986 @@
1
- import { EAuthTokenPlatformType, LoginApprover, LoginSession } from "steam-session";
2
- import moment from "moment";
3
-
4
- const isBrowser = typeof window !== "undefined";
5
- const g_rgCurrencyData = {
6
- USD: {
7
- strCode: "USD",
8
- eCurrencyCode: 1,
9
- strSymbol: "$",
10
- bSymbolIsPrefix: true,
11
- bWholeUnitsOnly: false,
12
- strDecimalSymbol: ".",
13
- strThousandsSeparator: ",",
14
- strSymbolAndNumberSeparator: "",
15
- },
16
- GBP: {
17
- strCode: "GBP",
18
- eCurrencyCode: 2,
19
- strSymbol: "\u00a3",
20
- bSymbolIsPrefix: true,
21
- bWholeUnitsOnly: false,
22
- strDecimalSymbol: ".",
23
- strThousandsSeparator: ",",
24
- strSymbolAndNumberSeparator: "",
25
- },
26
- EUR: {
27
- strCode: "EUR",
28
- eCurrencyCode: 3,
29
- strSymbol: "\u20ac",
30
- bSymbolIsPrefix: false,
31
- bWholeUnitsOnly: false,
32
- strDecimalSymbol: ",",
33
- strThousandsSeparator: " ",
34
- strSymbolAndNumberSeparator: "",
35
- },
36
- CHF: {
37
- strCode: "CHF",
38
- eCurrencyCode: 4,
39
- strSymbol: "CHF",
40
- bSymbolIsPrefix: true,
41
- bWholeUnitsOnly: false,
42
- strDecimalSymbol: ".",
43
- strThousandsSeparator: " ",
44
- strSymbolAndNumberSeparator: " ",
45
- },
46
- RUB: {
47
- strCode: "RUB",
48
- eCurrencyCode: 5,
49
- strSymbol: "p\u0443\u0431.",
50
- bSymbolIsPrefix: false,
51
- bWholeUnitsOnly: true,
52
- strDecimalSymbol: ",",
53
- strThousandsSeparator: "",
54
- strSymbolAndNumberSeparator: " ",
55
- },
56
- BRL: {
57
- strCode: "BRL",
58
- eCurrencyCode: 7,
59
- strSymbol: "R$",
60
- bSymbolIsPrefix: true,
61
- bWholeUnitsOnly: false,
62
- strDecimalSymbol: ",",
63
- strThousandsSeparator: ".",
64
- strSymbolAndNumberSeparator: " ",
65
- },
66
- JPY: {
67
- strCode: "JPY",
68
- eCurrencyCode: 8,
69
- strSymbol: "\u00a5",
70
- bSymbolIsPrefix: true,
71
- bWholeUnitsOnly: true,
72
- strDecimalSymbol: ".",
73
- strThousandsSeparator: ",",
74
- strSymbolAndNumberSeparator: " ",
75
- },
76
- NOK: {
77
- strCode: "NOK",
78
- eCurrencyCode: 9,
79
- strSymbol: "kr",
80
- bSymbolIsPrefix: false,
81
- bWholeUnitsOnly: false,
82
- strDecimalSymbol: ",",
83
- strThousandsSeparator: ".",
84
- strSymbolAndNumberSeparator: " ",
85
- },
86
- IDR: {
87
- strCode: "IDR",
88
- eCurrencyCode: 10,
89
- strSymbol: "Rp",
90
- bSymbolIsPrefix: true,
91
- bWholeUnitsOnly: true,
92
- strDecimalSymbol: ".",
93
- strThousandsSeparator: " ",
94
- strSymbolAndNumberSeparator: " ",
95
- },
96
- MYR: {
97
- strCode: "MYR",
98
- eCurrencyCode: 11,
99
- strSymbol: "RM",
100
- bSymbolIsPrefix: true,
101
- bWholeUnitsOnly: false,
102
- strDecimalSymbol: ".",
103
- strThousandsSeparator: ",",
104
- strSymbolAndNumberSeparator: "",
105
- },
106
- PHP: {
107
- strCode: "PHP",
108
- eCurrencyCode: 12,
109
- strSymbol: "P",
110
- bSymbolIsPrefix: true,
111
- bWholeUnitsOnly: false,
112
- strDecimalSymbol: ".",
113
- strThousandsSeparator: ",",
114
- strSymbolAndNumberSeparator: "",
115
- },
116
- SGD: {
117
- strCode: "SGD",
118
- eCurrencyCode: 13,
119
- strSymbol: "S$",
120
- bSymbolIsPrefix: true,
121
- bWholeUnitsOnly: false,
122
- strDecimalSymbol: ".",
123
- strThousandsSeparator: ",",
124
- strSymbolAndNumberSeparator: "",
125
- },
126
- THB: {
127
- strCode: "THB",
128
- eCurrencyCode: 14,
129
- strSymbol: "\u0e3f",
130
- bSymbolIsPrefix: true,
131
- bWholeUnitsOnly: false,
132
- strDecimalSymbol: ".",
133
- strThousandsSeparator: ",",
134
- strSymbolAndNumberSeparator: "",
135
- },
136
- VND: {
137
- strCode: "VND",
138
- eCurrencyCode: 15,
139
- strSymbol: "\u20ab",
140
- bSymbolIsPrefix: false,
141
- bWholeUnitsOnly: true,
142
- strDecimalSymbol: ",",
143
- strThousandsSeparator: ".",
144
- strSymbolAndNumberSeparator: "",
145
- },
146
- KRW: {
147
- strCode: "KRW",
148
- eCurrencyCode: 16,
149
- strSymbol: "\u20a9",
150
- bSymbolIsPrefix: true,
151
- bWholeUnitsOnly: true,
152
- strDecimalSymbol: ".",
153
- strThousandsSeparator: ",",
154
- strSymbolAndNumberSeparator: " ",
155
- },
156
- TRY: {
157
- strCode: "TRY",
158
- eCurrencyCode: 17,
159
- strSymbol: "TL",
160
- bSymbolIsPrefix: false,
161
- bWholeUnitsOnly: false,
162
- strDecimalSymbol: ",",
163
- strThousandsSeparator: ".",
164
- strSymbolAndNumberSeparator: " ",
165
- },
166
- UAH: {
167
- strCode: "UAH",
168
- eCurrencyCode: 18,
169
- strSymbol: "\u20b4",
170
- bSymbolIsPrefix: false,
171
- bWholeUnitsOnly: true,
172
- strDecimalSymbol: ",",
173
- strThousandsSeparator: " ",
174
- strSymbolAndNumberSeparator: "",
175
- },
176
- MXN: {
177
- strCode: "MXN",
178
- eCurrencyCode: 19,
179
- strSymbol: "Mex$",
180
- bSymbolIsPrefix: true,
181
- bWholeUnitsOnly: false,
182
- strDecimalSymbol: ".",
183
- strThousandsSeparator: ",",
184
- strSymbolAndNumberSeparator: " ",
185
- },
186
- CAD: {
187
- strCode: "CAD",
188
- eCurrencyCode: 20,
189
- strSymbol: "CDN$",
190
- bSymbolIsPrefix: true,
191
- bWholeUnitsOnly: false,
192
- strDecimalSymbol: ".",
193
- strThousandsSeparator: ",",
194
- strSymbolAndNumberSeparator: " ",
195
- },
196
- AUD: {
197
- strCode: "AUD",
198
- eCurrencyCode: 21,
199
- strSymbol: "A$",
200
- bSymbolIsPrefix: true,
201
- bWholeUnitsOnly: false,
202
- strDecimalSymbol: ".",
203
- strThousandsSeparator: ",",
204
- strSymbolAndNumberSeparator: " ",
205
- },
206
- NZD: {
207
- strCode: "NZD",
208
- eCurrencyCode: 22,
209
- strSymbol: "NZ$",
210
- bSymbolIsPrefix: true,
211
- bWholeUnitsOnly: false,
212
- strDecimalSymbol: ".",
213
- strThousandsSeparator: ",",
214
- strSymbolAndNumberSeparator: " ",
215
- },
216
- PLN: {
217
- strCode: "PLN",
218
- eCurrencyCode: 6,
219
- strSymbol: "z\u0142",
220
- bSymbolIsPrefix: false,
221
- bWholeUnitsOnly: false,
222
- strDecimalSymbol: ",",
223
- strThousandsSeparator: " ",
224
- strSymbolAndNumberSeparator: "",
225
- },
226
- CNY: {
227
- strCode: "CNY",
228
- eCurrencyCode: 23,
229
- strSymbol: "\u00a5",
230
- bSymbolIsPrefix: true,
231
- bWholeUnitsOnly: false,
232
- strDecimalSymbol: ".",
233
- strThousandsSeparator: ",",
234
- strSymbolAndNumberSeparator: " ",
235
- },
236
- INR: {
237
- strCode: "INR",
238
- eCurrencyCode: 24,
239
- strSymbol: "\u20b9",
240
- bSymbolIsPrefix: true,
241
- bWholeUnitsOnly: true,
242
- strDecimalSymbol: ".",
243
- strThousandsSeparator: ",",
244
- strSymbolAndNumberSeparator: " ",
245
- },
246
- CLP: {
247
- strCode: "CLP",
248
- eCurrencyCode: 25,
249
- strSymbol: "CLP$",
250
- bSymbolIsPrefix: true,
251
- bWholeUnitsOnly: true,
252
- strDecimalSymbol: ",",
253
- strThousandsSeparator: ".",
254
- strSymbolAndNumberSeparator: " ",
255
- },
256
- PEN: {
257
- strCode: "PEN",
258
- eCurrencyCode: 26,
259
- strSymbol: "S/.",
260
- bSymbolIsPrefix: true,
261
- bWholeUnitsOnly: false,
262
- strDecimalSymbol: ".",
263
- strThousandsSeparator: ",",
264
- strSymbolAndNumberSeparator: "",
265
- },
266
- COP: {
267
- strCode: "COP",
268
- eCurrencyCode: 27,
269
- strSymbol: "COL$",
270
- bSymbolIsPrefix: true,
271
- bWholeUnitsOnly: true,
272
- strDecimalSymbol: ",",
273
- strThousandsSeparator: ".",
274
- strSymbolAndNumberSeparator: " ",
275
- },
276
- ZAR: {
277
- strCode: "ZAR",
278
- eCurrencyCode: 28,
279
- strSymbol: "R",
280
- bSymbolIsPrefix: true,
281
- bWholeUnitsOnly: false,
282
- strDecimalSymbol: ".",
283
- strThousandsSeparator: " ",
284
- strSymbolAndNumberSeparator: " ",
285
- },
286
- HKD: {
287
- strCode: "HKD",
288
- eCurrencyCode: 29,
289
- strSymbol: "HK$",
290
- bSymbolIsPrefix: true,
291
- bWholeUnitsOnly: false,
292
- strDecimalSymbol: ".",
293
- strThousandsSeparator: ",",
294
- strSymbolAndNumberSeparator: " ",
295
- },
296
- TWD: {
297
- strCode: "TWD",
298
- eCurrencyCode: 30,
299
- strSymbol: "NT$",
300
- bSymbolIsPrefix: true,
301
- bWholeUnitsOnly: true,
302
- strDecimalSymbol: ".",
303
- strThousandsSeparator: ",",
304
- strSymbolAndNumberSeparator: " ",
305
- },
306
- SAR: {
307
- strCode: "SAR",
308
- eCurrencyCode: 31,
309
- strSymbol: "SR",
310
- bSymbolIsPrefix: false,
311
- bWholeUnitsOnly: false,
312
- strDecimalSymbol: ".",
313
- strThousandsSeparator: ",",
314
- strSymbolAndNumberSeparator: " ",
315
- },
316
- AED: {
317
- strCode: "AED",
318
- eCurrencyCode: 32,
319
- strSymbol: "AED",
320
- bSymbolIsPrefix: false,
321
- bWholeUnitsOnly: false,
322
- strDecimalSymbol: ".",
323
- strThousandsSeparator: ",",
324
- strSymbolAndNumberSeparator: " ",
325
- },
326
- SEK: {
327
- strCode: "SEK",
328
- eCurrencyCode: 33,
329
- strSymbol: "kr",
330
- bSymbolIsPrefix: false,
331
- bWholeUnitsOnly: false,
332
- strDecimalSymbol: ".",
333
- strThousandsSeparator: ",",
334
- strSymbolAndNumberSeparator: " ",
335
- },
336
- ARS: {
337
- strCode: "ARS",
338
- eCurrencyCode: 34,
339
- strSymbol: "ARS$",
340
- bSymbolIsPrefix: true,
341
- bWholeUnitsOnly: false,
342
- strDecimalSymbol: ",",
343
- strThousandsSeparator: ".",
344
- strSymbolAndNumberSeparator: " ",
345
- },
346
- ILS: {
347
- strCode: "ILS",
348
- eCurrencyCode: 35,
349
- strSymbol: "\u20aa",
350
- bSymbolIsPrefix: true,
351
- bWholeUnitsOnly: false,
352
- strDecimalSymbol: ".",
353
- strThousandsSeparator: ",",
354
- strSymbolAndNumberSeparator: "",
355
- },
356
- BYN: {
357
- strCode: "BYN",
358
- eCurrencyCode: 36,
359
- strSymbol: "Br",
360
- bSymbolIsPrefix: true,
361
- bWholeUnitsOnly: false,
362
- strDecimalSymbol: ".",
363
- strThousandsSeparator: ",",
364
- strSymbolAndNumberSeparator: "",
365
- },
366
- KZT: {
367
- strCode: "KZT",
368
- eCurrencyCode: 37,
369
- strSymbol: "\u20b8",
370
- bSymbolIsPrefix: false,
371
- bWholeUnitsOnly: true,
372
- strDecimalSymbol: ",",
373
- strThousandsSeparator: " ",
374
- strSymbolAndNumberSeparator: "",
375
- },
376
- KWD: {
377
- strCode: "KWD",
378
- eCurrencyCode: 38,
379
- strSymbol: "KD",
380
- bSymbolIsPrefix: false,
381
- bWholeUnitsOnly: false,
382
- strDecimalSymbol: ".",
383
- strThousandsSeparator: ",",
384
- strSymbolAndNumberSeparator: " ",
385
- },
386
- QAR: {
387
- strCode: "QAR",
388
- eCurrencyCode: 39,
389
- strSymbol: "QR",
390
- bSymbolIsPrefix: false,
391
- bWholeUnitsOnly: false,
392
- strDecimalSymbol: ".",
393
- strThousandsSeparator: ",",
394
- strSymbolAndNumberSeparator: " ",
395
- },
396
- CRC: {
397
- strCode: "CRC",
398
- eCurrencyCode: 40,
399
- strSymbol: "\u20a1",
400
- bSymbolIsPrefix: true,
401
- bWholeUnitsOnly: true,
402
- strDecimalSymbol: ",",
403
- strThousandsSeparator: ".",
404
- strSymbolAndNumberSeparator: "",
405
- },
406
- UYU: {
407
- strCode: "UYU",
408
- eCurrencyCode: 41,
409
- strSymbol: "$U",
410
- bSymbolIsPrefix: true,
411
- bWholeUnitsOnly: true,
412
- strDecimalSymbol: ",",
413
- strThousandsSeparator: ".",
414
- strSymbolAndNumberSeparator: "",
415
- },
416
- BGN: {
417
- strCode: "BGN",
418
- eCurrencyCode: 42,
419
- strSymbol: "\u043b\u0432",
420
- bSymbolIsPrefix: false,
421
- bWholeUnitsOnly: false,
422
- strDecimalSymbol: ".",
423
- strThousandsSeparator: ",",
424
- strSymbolAndNumberSeparator: " ",
425
- },
426
- HRK: {
427
- strCode: "HRK",
428
- eCurrencyCode: 43,
429
- strSymbol: "kn",
430
- bSymbolIsPrefix: false,
431
- bWholeUnitsOnly: false,
432
- strDecimalSymbol: ".",
433
- strThousandsSeparator: ",",
434
- strSymbolAndNumberSeparator: " ",
435
- },
436
- CZK: {
437
- strCode: "CZK",
438
- eCurrencyCode: 44,
439
- strSymbol: "K\u010d",
440
- bSymbolIsPrefix: false,
441
- bWholeUnitsOnly: false,
442
- strDecimalSymbol: ".",
443
- strThousandsSeparator: ",",
444
- strSymbolAndNumberSeparator: " ",
445
- },
446
- DKK: {
447
- strCode: "DKK",
448
- eCurrencyCode: 45,
449
- strSymbol: "kr.",
450
- bSymbolIsPrefix: false,
451
- bWholeUnitsOnly: false,
452
- strDecimalSymbol: ".",
453
- strThousandsSeparator: ",",
454
- strSymbolAndNumberSeparator: " ",
455
- },
456
- HUF: {
457
- strCode: "HUF",
458
- eCurrencyCode: 46,
459
- strSymbol: "Ft",
460
- bSymbolIsPrefix: false,
461
- bWholeUnitsOnly: false,
462
- strDecimalSymbol: ".",
463
- strThousandsSeparator: ",",
464
- strSymbolAndNumberSeparator: " ",
465
- },
466
- RON: {
467
- strCode: "RON",
468
- eCurrencyCode: 47,
469
- strSymbol: "lei",
470
- bSymbolIsPrefix: false,
471
- bWholeUnitsOnly: false,
472
- strDecimalSymbol: ".",
473
- strThousandsSeparator: ",",
474
- strSymbolAndNumberSeparator: " ",
475
- },
476
- RMB: {
477
- strCode: "RMB",
478
- eCurrencyCode: 9000,
479
- strSymbol: "\u5200\u5e01",
480
- bSymbolIsPrefix: false,
481
- bWholeUnitsOnly: true,
482
- strDecimalSymbol: ".",
483
- strThousandsSeparator: "",
484
- strSymbolAndNumberSeparator: " ",
485
- },
486
- NXP: {
487
- strCode: "NXP",
488
- eCurrencyCode: 9001,
489
- strSymbol: "\uc6d0",
490
- bSymbolIsPrefix: false,
491
- bWholeUnitsOnly: true,
492
- strDecimalSymbol: ".",
493
- strThousandsSeparator: ",",
494
- strSymbolAndNumberSeparator: "",
495
- },
496
- };
497
- const g_rgWalletInfo = {
498
- wallet_currency: 15,
499
- wallet_country: "VN",
500
- wallet_state: "",
501
- wallet_fee: "1",
502
- wallet_fee_minimum: "1",
503
- wallet_fee_percent: "0.05",
504
- wallet_publisher_fee_percent_default: "0.10",
505
- wallet_fee_base: "0",
506
- wallet_balance: "6540490",
507
- wallet_delayed_balance: "0",
508
- wallet_max_balance: "4500000000",
509
- wallet_trade_max_balance: "4049999616",
510
- success: 1,
511
- rwgrsn: -2,
512
- };
513
-
514
- export const sleep = (ms) => {
515
- return new Promise((resolve) => {
516
- setTimeout(resolve, ms);
517
- });
518
- };
519
-
520
- export const sleepRandom = async (startMs, endMs) => {
521
- return await sleep(Math.random() * (endMs - startMs) + startMs);
522
- };
523
-
524
- /**
525
- * const audioTrack = stream.getAudioTracks()[0]
526
- * const videoStream = UserMedia.createBlankVideoTrack()
527
- * videoStream.addTrack(audioTrack)
528
- * stream = videoStream
529
- * **/
530
- export const createBlankVideoTrack = (opts = {}) => {
531
- const { width = 1920, height = 1080 } = opts;
532
-
533
- const canvas = Object.assign(document.createElement("canvas"), {
534
- width,
535
- height,
536
- });
537
-
538
- canvas.getContext("2d").fillRect(0, 0, width, height);
539
-
540
- return canvas.captureStream();
541
- };
542
-
543
- const minDate = new Date(0),
544
- maxDate = new Date(parseInt("ffffffff", 16) * 1000);
545
-
546
- export function objectIdFromDate(date) {
547
- if (date < minDate || date > maxDate) {
548
- return `Error: date must be between ${minDate.getFullYear()} and ${maxDate.getFullYear()}`;
549
- }
550
- var pad = "00000000";
551
- var hexSeconds = Math.floor(date.getTime() / 1000).toString(16);
552
- return `${pad.substring(0, pad.length - hexSeconds.length) + hexSeconds}0000000000000000`;
553
- }
554
-
555
- export function dateFromObjectId(objectId) {
556
- return new Date(parseInt(objectId.substring(0, 8), 16) * 1000);
557
- }
558
-
559
- export function console_log(...args) {
560
- const params = [];
561
- params.push(new Date().toUTCString());
562
- const errorStack = new Error().stack;
563
- const fnName = errorStack
564
- .split("\n")
565
- .map((e) => e?.trim())
566
- .filter((e) => e.startsWith("at") && !e.startsWith("at console_log") && !e.startsWith("at processTicksAndRejections"))[0]
567
- .substr(3);
568
- params.push(fnName);
569
- console.log(
570
- params
571
- .filter(Boolean)
572
- .map((p) => `[${p.trim()}]`)
573
- .join(" "),
574
- ...args,
575
- );
576
- }
577
-
578
- export function removeSpaceKeys(object) {
579
- //mutate object
580
- if (!object || Array.isArray(object)) {
581
- return object;
582
- }
583
-
584
- Object.entries(object).forEach(([key, value]) => {
585
- const newKey = key.replaceAll(/[^a-zA-Z0-9]/gi, "_");
586
- if (newKey !== key) {
587
- delete object[key];
588
- object[newKey] = value;
589
- }
590
- });
591
- return object;
592
- }
593
-
594
- export function getCleanObject(object) {
595
- //like removeSpaceKeys but not mutate object
596
- if (!object || Array.isArray(object)) {
597
- return object;
598
- }
599
-
600
- const newObject = {};
601
- Object.entries(object).forEach(([key, value]) => {
602
- const newKey = key.replaceAll(/[^a-zA-Z0-9]/gi, "_");
603
- newObject[newKey] = value;
604
- });
605
- return newObject;
606
- }
607
-
608
- export function JSON_parse(data) {
609
- try {
610
- return JSON.parse(data);
611
- } catch (e) {
612
- return null;
613
- }
614
- }
615
-
616
- export function JSON_stringify(data) {
617
- try {
618
- return JSON.stringify(data);
619
- } catch (e) {
620
- return null;
621
- }
622
- }
623
-
624
- export async function throttle(fn, delay) {
625
- let canFire = true;
626
- let queue = [];
627
-
628
- async function pop() {
629
- if (queue.length < 1) return;
630
-
631
- const [that, args] = queue.pop();
632
- await fn.apply(that, args);
633
- canFire = false;
634
- setTimeout(async () => {
635
- canFire = true;
636
- await pop();
637
- }, delay);
638
- }
639
-
640
- async function push() {
641
- queue.push([this, arguments]);
642
- if (canFire) {
643
- await pop();
644
- }
645
- }
646
-
647
- push.cancel = () => {
648
- queue = [];
649
- };
650
-
651
- return push;
652
- }
653
-
654
- export const secretAsBuffer = (sharedSecret) => {
655
- if (Buffer.isBuffer(sharedSecret)) {
656
- return sharedSecret;
657
- }
658
-
659
- if (sharedSecret.match(/^[0-9a-f]{40}$/i)) {
660
- // Looks like it's hex
661
- return Buffer.from(sharedSecret, "hex");
662
- }
663
-
664
- // It must be base64
665
- return Buffer.from(sharedSecret, "base64");
666
- };
667
-
668
- export function decodeLoginQrUrl(qrUrl) {
669
- if (!qrUrl || typeof qrUrl !== "string") {
670
- return null;
671
- }
672
- const match = qrUrl.match(/^https?:\/\/s\.team\/q\/(\d+)\/(\d+)(\?|$)/);
673
- if (!match) {
674
- console.log("Invalid QR code URL");
675
- return null;
676
- }
677
-
678
- return { clientId: match[2], version: parseInt(match[1], 10) };
679
- }
680
-
681
- export function decodeJwt(jwt) {
682
- try {
683
- const parts = jwt.split(".");
684
- if (parts.length !== 3) {
685
- console.err("decodeJwt Error", new Error("Invalid JWT"));
686
- return;
687
- }
688
-
689
- const standardBase64 = parts[1].replace(/-/g, "+").replace(/_/g, "/");
690
- return JSON.parse(Buffer.from(standardBase64, "base64").toString("utf8"));
691
- } catch (e) {
692
- console.error("decodeJwt Error", e);
693
- }
694
- }
695
-
696
- export async function renewRefreshToken({ refreshToken, accessToken }) {
697
- try {
698
- const { aud } = decodeJwt(accessToken);
699
- let platformType = EAuthTokenPlatformType.SteamClient;
700
- if (aud.includes("mobile")) {
701
- platformType = EAuthTokenPlatformType.MobileApp;
702
- } else if (aud.includes("client")) {
703
- platformType = EAuthTokenPlatformType.SteamClient;
704
- } else if (aud.includes("web")) {
705
- platformType = EAuthTokenPlatformType.WebBrowser;
706
- }
707
- const session = new LoginSession(platformType);
708
- session.refreshToken = refreshToken;
709
- await session.refreshAccessToken();
710
- const cookie = (await session.getWebCookies())?.join?.(";");
711
- return {
712
- cookie,
713
- accessToken: session.accessToken,
714
- accessTokenDecoded: decodeJwt(session.accessToken),
715
- };
716
- } catch (e) {
717
- console.error("renewRefreshToken Error", e);
718
- }
719
- }
720
-
721
- export async function approveLogin({ steamId, url, sharedSecret, accessToken, shouldApprove }) {
722
- try {
723
- const approver = new LoginApprover(accessToken, sharedSecret, {});
724
- const sessionInfo = await approver.getAuthSessionInfo(url);
725
- sessionInfo.steamId = steamId;
726
-
727
- if (typeof shouldApprove === "function" && !shouldApprove(sessionInfo)) {
728
- return;
729
- }
730
-
731
- await approver.approveAuthSession({
732
- qrChallengeUrl: url,
733
- approve: true,
734
- });
735
-
736
- return {
737
- steamId,
738
- sessionInfo,
739
- };
740
- } catch (error) {
741
- console.error("approveLogin Error", error);
742
- return {
743
- steamId,
744
- error,
745
- };
746
- }
747
- }
748
-
749
- export function getBonusXpTimeRefresh() {
750
- let resetDay = moment.utc().startOf("isoWeek").add(2, "days").add(1, "hours");
751
- while (moment().isAfter(resetDay)) {
752
- resetDay = resetDay.add(7, "days");
753
- }
754
- if (moment().isBefore(resetDay)) {
755
- resetDay = resetDay.subtract(7, "days");
756
- }
757
- return resetDay;
758
- }
759
-
760
- export function estimateNextXp(currentXp, xpEarned) {
761
- //estimate next xp
762
- let bonusTime = 1;
763
- if (xpEarned < 4500) {
764
- bonusTime = 4;
765
- } else if (xpEarned < 7500) {
766
- bonusTime = 2;
767
- } else if (xpEarned < 11200) {
768
- bonusTime = 1;
769
- } else {
770
- bonusTime = 0.175;
771
- }
772
-
773
- const nextXp = 30 * 13 * bonusTime;
774
- return nextXp + currentXp;
775
- }
776
-
777
- export function formatMarketCurrency(valueInCents, currencyCode = getMarketCurrencyCode(g_rgWalletInfo.wallet_currency), countryCode) {
778
- if (!valueInCents && valueInCents !== 0) {
779
- return "";
780
- }
781
-
782
- let currencyFormat = (valueInCents / 100).toFixed(2);
783
-
784
- if (g_rgCurrencyData[currencyCode]) {
785
- const currencyData = g_rgCurrencyData[currencyCode];
786
- if (isCurrencyWholeUnits(currencyCode)) {
787
- currencyFormat = currencyFormat.replace(".00", "");
788
- }
789
-
790
- if (currencyData.strDecimalSymbol !== ".") {
791
- currencyFormat = currencyFormat.replace(".", currencyData.strDecimalSymbol);
792
- }
793
-
794
- const currencySymbol = getMarketCurrencySymbol(currencyCode);
795
- const currencyReturn = isCurrencySymbolBeforeValue(currencyCode) ? currencySymbol + currencyData.strSymbolAndNumberSeparator + currencyFormat : currencyFormat + currencyData.strSymbolAndNumberSeparator + currencySymbol;
796
-
797
- if (currencyCode === "USD" && typeof countryCode != "undefined" && countryCode != "US") {
798
- return `${currencyReturn} USD`;
799
- } else if (currencyCode === "EUR") {
800
- return currencyReturn.replace(",00", ",--");
801
- } else {
802
- return currencyReturn;
803
- }
804
- } else {
805
- return `${currencyFormat} ${currencyCode}`;
806
- }
807
- }
808
-
809
- export function getMarketPriceValueAsInt(strAmount) {
810
- let nAmount;
811
- if (!strAmount) {
812
- return 0;
813
- }
814
-
815
- // Users may enter either comma or period for the decimal mark and digit group separators.
816
- strAmount = strAmount.replace(/,/g, ".");
817
-
818
- // strip the currency symbol, set .-- to .00
819
- strAmount = strAmount.replace(getMarketCurrencySymbol(getMarketCurrencyCode(g_rgWalletInfo.wallet_currency)), "").replace(".--", ".00");
820
-
821
- // strip spaces
822
- strAmount = strAmount.replace(/ /g, "");
823
-
824
- // Remove all but the last period so that entries like "1,147.6" work
825
- if (strAmount.includes(".")) {
826
- var splitAmount = strAmount.split(".");
827
- var strLastSegment = splitAmount[splitAmount.length - 1];
828
-
829
- if (!isNaN(strLastSegment) && strLastSegment.length == 3 && splitAmount[splitAmount.length - 2] != "0") {
830
- // Looks like the user only entered thousands separators. Remove all commas and periods.
831
- // Ensures an entry like "1,147" is not treated as "1.147"
832
- //
833
- // Users may be surprised to find that "1.147" is treated as "1,147". "1.147" is either an error or the user
834
- // really did mean one thousand one hundred and forty seven since no currencies can be split into more than
835
- // hundredths. If it was an error, the user should notice in the next step of the dialog and can go back and
836
- // correct it. If they happen to not notice, it is better that we list the item at a higher price than
837
- // intended instead of lower than intended (which we would have done if we accepted the 1.147 value as is).
838
- strAmount = splitAmount.join("");
839
- } else {
840
- strAmount = `${splitAmount.slice(0, -1).join("")}.${strLastSegment}`;
841
- }
842
- }
843
-
844
- let flAmount = parseFloat(strAmount) * 100;
845
- nAmount = Math.floor(isNaN(flAmount) ? 0 : flAmount + 0.000001); // round down
846
-
847
- nAmount = Math.max(nAmount, 0);
848
- return nAmount;
849
- }
850
-
851
- export function isCurrencyWholeUnits(currencyCode) {
852
- return g_rgCurrencyData[currencyCode] && g_rgCurrencyData[currencyCode].bWholeUnitsOnly && currencyCode !== "RUB";
853
- }
854
-
855
- export function isCurrencySymbolBeforeValue(currencyCode) {
856
- return g_rgCurrencyData[currencyCode] && g_rgCurrencyData[currencyCode].bSymbolIsPrefix;
857
- }
858
-
859
- // Return the symbol to use for a currency
860
- export function getMarketCurrencySymbol(currencyCode) {
861
- return g_rgCurrencyData[currencyCode]?.strSymbol ?? currencyCode;
862
- }
863
-
864
- export function getMarketCurrencyCode(currencyId) {
865
- currencyId = parseInt(currencyId);
866
- for (const code in g_rgCurrencyData) {
867
- if (g_rgCurrencyData[code].eCurrencyCode === currencyId) {
868
- return code;
869
- }
870
- }
871
- return "Unknown";
872
- }
1
+ import moment from "moment";
2
+ import SteamTotp from "steam-totp";
3
+ import { EAuthTokenPlatformType } from "./const.js";
4
+
5
+ const isBrowser = typeof window !== "undefined";
6
+ const g_rgCurrencyData = {
7
+ USD: {
8
+ strCode: "USD",
9
+ eCurrencyCode: 1,
10
+ strSymbol: "$",
11
+ bSymbolIsPrefix: true,
12
+ bWholeUnitsOnly: false,
13
+ strDecimalSymbol: ".",
14
+ strThousandsSeparator: ",",
15
+ strSymbolAndNumberSeparator: "",
16
+ },
17
+ GBP: {
18
+ strCode: "GBP",
19
+ eCurrencyCode: 2,
20
+ strSymbol: "\u00a3",
21
+ bSymbolIsPrefix: true,
22
+ bWholeUnitsOnly: false,
23
+ strDecimalSymbol: ".",
24
+ strThousandsSeparator: ",",
25
+ strSymbolAndNumberSeparator: "",
26
+ },
27
+ EUR: {
28
+ strCode: "EUR",
29
+ eCurrencyCode: 3,
30
+ strSymbol: "\u20ac",
31
+ bSymbolIsPrefix: false,
32
+ bWholeUnitsOnly: false,
33
+ strDecimalSymbol: ",",
34
+ strThousandsSeparator: " ",
35
+ strSymbolAndNumberSeparator: "",
36
+ },
37
+ CHF: {
38
+ strCode: "CHF",
39
+ eCurrencyCode: 4,
40
+ strSymbol: "CHF",
41
+ bSymbolIsPrefix: true,
42
+ bWholeUnitsOnly: false,
43
+ strDecimalSymbol: ".",
44
+ strThousandsSeparator: " ",
45
+ strSymbolAndNumberSeparator: " ",
46
+ },
47
+ RUB: {
48
+ strCode: "RUB",
49
+ eCurrencyCode: 5,
50
+ strSymbol: "p\u0443\u0431.",
51
+ bSymbolIsPrefix: false,
52
+ bWholeUnitsOnly: true,
53
+ strDecimalSymbol: ",",
54
+ strThousandsSeparator: "",
55
+ strSymbolAndNumberSeparator: " ",
56
+ },
57
+ BRL: {
58
+ strCode: "BRL",
59
+ eCurrencyCode: 7,
60
+ strSymbol: "R$",
61
+ bSymbolIsPrefix: true,
62
+ bWholeUnitsOnly: false,
63
+ strDecimalSymbol: ",",
64
+ strThousandsSeparator: ".",
65
+ strSymbolAndNumberSeparator: " ",
66
+ },
67
+ JPY: {
68
+ strCode: "JPY",
69
+ eCurrencyCode: 8,
70
+ strSymbol: "\u00a5",
71
+ bSymbolIsPrefix: true,
72
+ bWholeUnitsOnly: true,
73
+ strDecimalSymbol: ".",
74
+ strThousandsSeparator: ",",
75
+ strSymbolAndNumberSeparator: " ",
76
+ },
77
+ NOK: {
78
+ strCode: "NOK",
79
+ eCurrencyCode: 9,
80
+ strSymbol: "kr",
81
+ bSymbolIsPrefix: false,
82
+ bWholeUnitsOnly: false,
83
+ strDecimalSymbol: ",",
84
+ strThousandsSeparator: ".",
85
+ strSymbolAndNumberSeparator: " ",
86
+ },
87
+ IDR: {
88
+ strCode: "IDR",
89
+ eCurrencyCode: 10,
90
+ strSymbol: "Rp",
91
+ bSymbolIsPrefix: true,
92
+ bWholeUnitsOnly: true,
93
+ strDecimalSymbol: ".",
94
+ strThousandsSeparator: " ",
95
+ strSymbolAndNumberSeparator: " ",
96
+ },
97
+ MYR: {
98
+ strCode: "MYR",
99
+ eCurrencyCode: 11,
100
+ strSymbol: "RM",
101
+ bSymbolIsPrefix: true,
102
+ bWholeUnitsOnly: false,
103
+ strDecimalSymbol: ".",
104
+ strThousandsSeparator: ",",
105
+ strSymbolAndNumberSeparator: "",
106
+ },
107
+ PHP: {
108
+ strCode: "PHP",
109
+ eCurrencyCode: 12,
110
+ strSymbol: "P",
111
+ bSymbolIsPrefix: true,
112
+ bWholeUnitsOnly: false,
113
+ strDecimalSymbol: ".",
114
+ strThousandsSeparator: ",",
115
+ strSymbolAndNumberSeparator: "",
116
+ },
117
+ SGD: {
118
+ strCode: "SGD",
119
+ eCurrencyCode: 13,
120
+ strSymbol: "S$",
121
+ bSymbolIsPrefix: true,
122
+ bWholeUnitsOnly: false,
123
+ strDecimalSymbol: ".",
124
+ strThousandsSeparator: ",",
125
+ strSymbolAndNumberSeparator: "",
126
+ },
127
+ THB: {
128
+ strCode: "THB",
129
+ eCurrencyCode: 14,
130
+ strSymbol: "\u0e3f",
131
+ bSymbolIsPrefix: true,
132
+ bWholeUnitsOnly: false,
133
+ strDecimalSymbol: ".",
134
+ strThousandsSeparator: ",",
135
+ strSymbolAndNumberSeparator: "",
136
+ },
137
+ VND: {
138
+ strCode: "VND",
139
+ eCurrencyCode: 15,
140
+ strSymbol: "\u20ab",
141
+ bSymbolIsPrefix: false,
142
+ bWholeUnitsOnly: true,
143
+ strDecimalSymbol: ",",
144
+ strThousandsSeparator: ".",
145
+ strSymbolAndNumberSeparator: "",
146
+ },
147
+ KRW: {
148
+ strCode: "KRW",
149
+ eCurrencyCode: 16,
150
+ strSymbol: "\u20a9",
151
+ bSymbolIsPrefix: true,
152
+ bWholeUnitsOnly: true,
153
+ strDecimalSymbol: ".",
154
+ strThousandsSeparator: ",",
155
+ strSymbolAndNumberSeparator: " ",
156
+ },
157
+ TRY: {
158
+ strCode: "TRY",
159
+ eCurrencyCode: 17,
160
+ strSymbol: "TL",
161
+ bSymbolIsPrefix: false,
162
+ bWholeUnitsOnly: false,
163
+ strDecimalSymbol: ",",
164
+ strThousandsSeparator: ".",
165
+ strSymbolAndNumberSeparator: " ",
166
+ },
167
+ UAH: {
168
+ strCode: "UAH",
169
+ eCurrencyCode: 18,
170
+ strSymbol: "\u20b4",
171
+ bSymbolIsPrefix: false,
172
+ bWholeUnitsOnly: true,
173
+ strDecimalSymbol: ",",
174
+ strThousandsSeparator: " ",
175
+ strSymbolAndNumberSeparator: "",
176
+ },
177
+ MXN: {
178
+ strCode: "MXN",
179
+ eCurrencyCode: 19,
180
+ strSymbol: "Mex$",
181
+ bSymbolIsPrefix: true,
182
+ bWholeUnitsOnly: false,
183
+ strDecimalSymbol: ".",
184
+ strThousandsSeparator: ",",
185
+ strSymbolAndNumberSeparator: " ",
186
+ },
187
+ CAD: {
188
+ strCode: "CAD",
189
+ eCurrencyCode: 20,
190
+ strSymbol: "CDN$",
191
+ bSymbolIsPrefix: true,
192
+ bWholeUnitsOnly: false,
193
+ strDecimalSymbol: ".",
194
+ strThousandsSeparator: ",",
195
+ strSymbolAndNumberSeparator: " ",
196
+ },
197
+ AUD: {
198
+ strCode: "AUD",
199
+ eCurrencyCode: 21,
200
+ strSymbol: "A$",
201
+ bSymbolIsPrefix: true,
202
+ bWholeUnitsOnly: false,
203
+ strDecimalSymbol: ".",
204
+ strThousandsSeparator: ",",
205
+ strSymbolAndNumberSeparator: " ",
206
+ },
207
+ NZD: {
208
+ strCode: "NZD",
209
+ eCurrencyCode: 22,
210
+ strSymbol: "NZ$",
211
+ bSymbolIsPrefix: true,
212
+ bWholeUnitsOnly: false,
213
+ strDecimalSymbol: ".",
214
+ strThousandsSeparator: ",",
215
+ strSymbolAndNumberSeparator: " ",
216
+ },
217
+ PLN: {
218
+ strCode: "PLN",
219
+ eCurrencyCode: 6,
220
+ strSymbol: "z\u0142",
221
+ bSymbolIsPrefix: false,
222
+ bWholeUnitsOnly: false,
223
+ strDecimalSymbol: ",",
224
+ strThousandsSeparator: " ",
225
+ strSymbolAndNumberSeparator: "",
226
+ },
227
+ CNY: {
228
+ strCode: "CNY",
229
+ eCurrencyCode: 23,
230
+ strSymbol: "\u00a5",
231
+ bSymbolIsPrefix: true,
232
+ bWholeUnitsOnly: false,
233
+ strDecimalSymbol: ".",
234
+ strThousandsSeparator: ",",
235
+ strSymbolAndNumberSeparator: " ",
236
+ },
237
+ INR: {
238
+ strCode: "INR",
239
+ eCurrencyCode: 24,
240
+ strSymbol: "\u20b9",
241
+ bSymbolIsPrefix: true,
242
+ bWholeUnitsOnly: true,
243
+ strDecimalSymbol: ".",
244
+ strThousandsSeparator: ",",
245
+ strSymbolAndNumberSeparator: " ",
246
+ },
247
+ CLP: {
248
+ strCode: "CLP",
249
+ eCurrencyCode: 25,
250
+ strSymbol: "CLP$",
251
+ bSymbolIsPrefix: true,
252
+ bWholeUnitsOnly: true,
253
+ strDecimalSymbol: ",",
254
+ strThousandsSeparator: ".",
255
+ strSymbolAndNumberSeparator: " ",
256
+ },
257
+ PEN: {
258
+ strCode: "PEN",
259
+ eCurrencyCode: 26,
260
+ strSymbol: "S/.",
261
+ bSymbolIsPrefix: true,
262
+ bWholeUnitsOnly: false,
263
+ strDecimalSymbol: ".",
264
+ strThousandsSeparator: ",",
265
+ strSymbolAndNumberSeparator: "",
266
+ },
267
+ COP: {
268
+ strCode: "COP",
269
+ eCurrencyCode: 27,
270
+ strSymbol: "COL$",
271
+ bSymbolIsPrefix: true,
272
+ bWholeUnitsOnly: true,
273
+ strDecimalSymbol: ",",
274
+ strThousandsSeparator: ".",
275
+ strSymbolAndNumberSeparator: " ",
276
+ },
277
+ ZAR: {
278
+ strCode: "ZAR",
279
+ eCurrencyCode: 28,
280
+ strSymbol: "R",
281
+ bSymbolIsPrefix: true,
282
+ bWholeUnitsOnly: false,
283
+ strDecimalSymbol: ".",
284
+ strThousandsSeparator: " ",
285
+ strSymbolAndNumberSeparator: " ",
286
+ },
287
+ HKD: {
288
+ strCode: "HKD",
289
+ eCurrencyCode: 29,
290
+ strSymbol: "HK$",
291
+ bSymbolIsPrefix: true,
292
+ bWholeUnitsOnly: false,
293
+ strDecimalSymbol: ".",
294
+ strThousandsSeparator: ",",
295
+ strSymbolAndNumberSeparator: " ",
296
+ },
297
+ TWD: {
298
+ strCode: "TWD",
299
+ eCurrencyCode: 30,
300
+ strSymbol: "NT$",
301
+ bSymbolIsPrefix: true,
302
+ bWholeUnitsOnly: true,
303
+ strDecimalSymbol: ".",
304
+ strThousandsSeparator: ",",
305
+ strSymbolAndNumberSeparator: " ",
306
+ },
307
+ SAR: {
308
+ strCode: "SAR",
309
+ eCurrencyCode: 31,
310
+ strSymbol: "SR",
311
+ bSymbolIsPrefix: false,
312
+ bWholeUnitsOnly: false,
313
+ strDecimalSymbol: ".",
314
+ strThousandsSeparator: ",",
315
+ strSymbolAndNumberSeparator: " ",
316
+ },
317
+ AED: {
318
+ strCode: "AED",
319
+ eCurrencyCode: 32,
320
+ strSymbol: "AED",
321
+ bSymbolIsPrefix: false,
322
+ bWholeUnitsOnly: false,
323
+ strDecimalSymbol: ".",
324
+ strThousandsSeparator: ",",
325
+ strSymbolAndNumberSeparator: " ",
326
+ },
327
+ SEK: {
328
+ strCode: "SEK",
329
+ eCurrencyCode: 33,
330
+ strSymbol: "kr",
331
+ bSymbolIsPrefix: false,
332
+ bWholeUnitsOnly: false,
333
+ strDecimalSymbol: ".",
334
+ strThousandsSeparator: ",",
335
+ strSymbolAndNumberSeparator: " ",
336
+ },
337
+ ARS: {
338
+ strCode: "ARS",
339
+ eCurrencyCode: 34,
340
+ strSymbol: "ARS$",
341
+ bSymbolIsPrefix: true,
342
+ bWholeUnitsOnly: false,
343
+ strDecimalSymbol: ",",
344
+ strThousandsSeparator: ".",
345
+ strSymbolAndNumberSeparator: " ",
346
+ },
347
+ ILS: {
348
+ strCode: "ILS",
349
+ eCurrencyCode: 35,
350
+ strSymbol: "\u20aa",
351
+ bSymbolIsPrefix: true,
352
+ bWholeUnitsOnly: false,
353
+ strDecimalSymbol: ".",
354
+ strThousandsSeparator: ",",
355
+ strSymbolAndNumberSeparator: "",
356
+ },
357
+ BYN: {
358
+ strCode: "BYN",
359
+ eCurrencyCode: 36,
360
+ strSymbol: "Br",
361
+ bSymbolIsPrefix: true,
362
+ bWholeUnitsOnly: false,
363
+ strDecimalSymbol: ".",
364
+ strThousandsSeparator: ",",
365
+ strSymbolAndNumberSeparator: "",
366
+ },
367
+ KZT: {
368
+ strCode: "KZT",
369
+ eCurrencyCode: 37,
370
+ strSymbol: "\u20b8",
371
+ bSymbolIsPrefix: false,
372
+ bWholeUnitsOnly: true,
373
+ strDecimalSymbol: ",",
374
+ strThousandsSeparator: " ",
375
+ strSymbolAndNumberSeparator: "",
376
+ },
377
+ KWD: {
378
+ strCode: "KWD",
379
+ eCurrencyCode: 38,
380
+ strSymbol: "KD",
381
+ bSymbolIsPrefix: false,
382
+ bWholeUnitsOnly: false,
383
+ strDecimalSymbol: ".",
384
+ strThousandsSeparator: ",",
385
+ strSymbolAndNumberSeparator: " ",
386
+ },
387
+ QAR: {
388
+ strCode: "QAR",
389
+ eCurrencyCode: 39,
390
+ strSymbol: "QR",
391
+ bSymbolIsPrefix: false,
392
+ bWholeUnitsOnly: false,
393
+ strDecimalSymbol: ".",
394
+ strThousandsSeparator: ",",
395
+ strSymbolAndNumberSeparator: " ",
396
+ },
397
+ CRC: {
398
+ strCode: "CRC",
399
+ eCurrencyCode: 40,
400
+ strSymbol: "\u20a1",
401
+ bSymbolIsPrefix: true,
402
+ bWholeUnitsOnly: true,
403
+ strDecimalSymbol: ",",
404
+ strThousandsSeparator: ".",
405
+ strSymbolAndNumberSeparator: "",
406
+ },
407
+ UYU: {
408
+ strCode: "UYU",
409
+ eCurrencyCode: 41,
410
+ strSymbol: "$U",
411
+ bSymbolIsPrefix: true,
412
+ bWholeUnitsOnly: true,
413
+ strDecimalSymbol: ",",
414
+ strThousandsSeparator: ".",
415
+ strSymbolAndNumberSeparator: "",
416
+ },
417
+ BGN: {
418
+ strCode: "BGN",
419
+ eCurrencyCode: 42,
420
+ strSymbol: "\u043b\u0432",
421
+ bSymbolIsPrefix: false,
422
+ bWholeUnitsOnly: false,
423
+ strDecimalSymbol: ".",
424
+ strThousandsSeparator: ",",
425
+ strSymbolAndNumberSeparator: " ",
426
+ },
427
+ HRK: {
428
+ strCode: "HRK",
429
+ eCurrencyCode: 43,
430
+ strSymbol: "kn",
431
+ bSymbolIsPrefix: false,
432
+ bWholeUnitsOnly: false,
433
+ strDecimalSymbol: ".",
434
+ strThousandsSeparator: ",",
435
+ strSymbolAndNumberSeparator: " ",
436
+ },
437
+ CZK: {
438
+ strCode: "CZK",
439
+ eCurrencyCode: 44,
440
+ strSymbol: "K\u010d",
441
+ bSymbolIsPrefix: false,
442
+ bWholeUnitsOnly: false,
443
+ strDecimalSymbol: ".",
444
+ strThousandsSeparator: ",",
445
+ strSymbolAndNumberSeparator: " ",
446
+ },
447
+ DKK: {
448
+ strCode: "DKK",
449
+ eCurrencyCode: 45,
450
+ strSymbol: "kr.",
451
+ bSymbolIsPrefix: false,
452
+ bWholeUnitsOnly: false,
453
+ strDecimalSymbol: ".",
454
+ strThousandsSeparator: ",",
455
+ strSymbolAndNumberSeparator: " ",
456
+ },
457
+ HUF: {
458
+ strCode: "HUF",
459
+ eCurrencyCode: 46,
460
+ strSymbol: "Ft",
461
+ bSymbolIsPrefix: false,
462
+ bWholeUnitsOnly: false,
463
+ strDecimalSymbol: ".",
464
+ strThousandsSeparator: ",",
465
+ strSymbolAndNumberSeparator: " ",
466
+ },
467
+ RON: {
468
+ strCode: "RON",
469
+ eCurrencyCode: 47,
470
+ strSymbol: "lei",
471
+ bSymbolIsPrefix: false,
472
+ bWholeUnitsOnly: false,
473
+ strDecimalSymbol: ".",
474
+ strThousandsSeparator: ",",
475
+ strSymbolAndNumberSeparator: " ",
476
+ },
477
+ RMB: {
478
+ strCode: "RMB",
479
+ eCurrencyCode: 9000,
480
+ strSymbol: "\u5200\u5e01",
481
+ bSymbolIsPrefix: false,
482
+ bWholeUnitsOnly: true,
483
+ strDecimalSymbol: ".",
484
+ strThousandsSeparator: "",
485
+ strSymbolAndNumberSeparator: " ",
486
+ },
487
+ NXP: {
488
+ strCode: "NXP",
489
+ eCurrencyCode: 9001,
490
+ strSymbol: "\uc6d0",
491
+ bSymbolIsPrefix: false,
492
+ bWholeUnitsOnly: true,
493
+ strDecimalSymbol: ".",
494
+ strThousandsSeparator: ",",
495
+ strSymbolAndNumberSeparator: "",
496
+ },
497
+ };
498
+ const g_rgWalletInfo = {
499
+ wallet_currency: 15,
500
+ wallet_country: "VN",
501
+ wallet_state: "",
502
+ wallet_fee: "1",
503
+ wallet_fee_minimum: "1",
504
+ wallet_fee_percent: "0.05",
505
+ wallet_publisher_fee_percent_default: "0.10",
506
+ wallet_fee_base: "0",
507
+ wallet_balance: "6540490",
508
+ wallet_delayed_balance: "0",
509
+ wallet_max_balance: "4500000000",
510
+ wallet_trade_max_balance: "4049999616",
511
+ success: 1,
512
+ rwgrsn: -2,
513
+ };
514
+
515
+ export const sleep = (ms) => {
516
+ return new Promise((resolve) => {
517
+ setTimeout(resolve, ms);
518
+ });
519
+ };
520
+
521
+ export const sleepRandom = async (startMs, endMs) => {
522
+ return await sleep(Math.random() * (endMs - startMs) + startMs);
523
+ };
524
+
525
+ /**
526
+ * const audioTrack = stream.getAudioTracks()[0]
527
+ * const videoStream = UserMedia.createBlankVideoTrack()
528
+ * videoStream.addTrack(audioTrack)
529
+ * stream = videoStream
530
+ * **/
531
+ export const createBlankVideoTrack = (opts = {}) => {
532
+ const { width = 1920, height = 1080 } = opts;
533
+
534
+ const canvas = Object.assign(document.createElement("canvas"), {
535
+ width,
536
+ height,
537
+ });
538
+
539
+ canvas.getContext("2d").fillRect(0, 0, width, height);
540
+
541
+ return canvas.captureStream();
542
+ };
543
+
544
+ const minDate = new Date(0),
545
+ maxDate = new Date(parseInt("ffffffff", 16) * 1000);
546
+
547
+ export function objectIdFromDate(date) {
548
+ if (date < minDate || date > maxDate) {
549
+ return `Error: date must be between ${minDate.getFullYear()} and ${maxDate.getFullYear()}`;
550
+ }
551
+ var pad = "00000000";
552
+ var hexSeconds = Math.floor(date.getTime() / 1000).toString(16);
553
+ return `${pad.substring(0, pad.length - hexSeconds.length) + hexSeconds}0000000000000000`;
554
+ }
555
+
556
+ export function dateFromObjectId(objectId) {
557
+ return new Date(parseInt(objectId.substring(0, 8), 16) * 1000);
558
+ }
559
+
560
+ export function console_log(...args) {
561
+ const params = [];
562
+ params.push(new Date().toUTCString());
563
+ const errorStack = new Error().stack;
564
+ const fnName = errorStack
565
+ .split("\n")
566
+ .map((e) => e?.trim())
567
+ .filter((e) => e.startsWith("at") && !e.startsWith("at console_log") && !e.startsWith("at processTicksAndRejections"))[0]
568
+ .substr(3);
569
+ params.push(fnName);
570
+ console.log(
571
+ params
572
+ .filter(Boolean)
573
+ .map((p) => `[${p.trim()}]`)
574
+ .join(" "),
575
+ ...args,
576
+ );
577
+ }
578
+
579
+ export function removeSpaceKeys(object) {
580
+ //mutate object
581
+ if (!object || Array.isArray(object)) {
582
+ return object;
583
+ }
584
+
585
+ Object.entries(object).forEach(([key, value]) => {
586
+ const newKey = key.replaceAll(/[^a-zA-Z0-9]/gi, "_");
587
+ if (newKey !== key) {
588
+ delete object[key];
589
+ object[newKey] = value;
590
+ }
591
+ });
592
+ return object;
593
+ }
594
+
595
+ export function getCleanObject(object) {
596
+ //like removeSpaceKeys but not mutate object
597
+ if (!object || Array.isArray(object)) {
598
+ return object;
599
+ }
600
+
601
+ const newObject = {};
602
+ Object.entries(object).forEach(([key, value]) => {
603
+ const newKey = key.replaceAll(/[^a-zA-Z0-9]/gi, "_");
604
+ newObject[newKey] = value;
605
+ });
606
+ return newObject;
607
+ }
608
+
609
+ export function JSON_parse(data) {
610
+ try {
611
+ return JSON.parse(data);
612
+ } catch (e) {
613
+ return null;
614
+ }
615
+ }
616
+
617
+ export function JSON_stringify(data) {
618
+ try {
619
+ return JSON.stringify(data);
620
+ } catch (e) {
621
+ return null;
622
+ }
623
+ }
624
+
625
+ export async function throttle(fn, delay) {
626
+ let canFire = true;
627
+ let queue = [];
628
+
629
+ async function pop() {
630
+ if (queue.length < 1) return;
631
+
632
+ const [that, args] = queue.pop();
633
+ await fn.apply(that, args);
634
+ canFire = false;
635
+ setTimeout(async () => {
636
+ canFire = true;
637
+ await pop();
638
+ }, delay);
639
+ }
640
+
641
+ async function push() {
642
+ queue.push([this, arguments]);
643
+ if (canFire) {
644
+ await pop();
645
+ }
646
+ }
647
+
648
+ push.cancel = () => {
649
+ queue = [];
650
+ };
651
+
652
+ return push;
653
+ }
654
+
655
+ export const secretAsBuffer = (sharedSecret) => {
656
+ if (Buffer.isBuffer(sharedSecret)) {
657
+ return sharedSecret;
658
+ }
659
+
660
+ if (sharedSecret.match(/^[0-9a-f]{40}$/i)) {
661
+ // Looks like it's hex
662
+ return Buffer.from(sharedSecret, "hex");
663
+ }
664
+
665
+ // It must be base64
666
+ return Buffer.from(sharedSecret, "base64");
667
+ };
668
+
669
+ export function decodeLoginQrUrl(qrUrl) {
670
+ if (!qrUrl || typeof qrUrl !== "string") {
671
+ return null;
672
+ }
673
+ const match = qrUrl.match(/^https?:\/\/s\.team\/q\/(\d+)\/(\d+)(\?|$)/);
674
+ if (!match) {
675
+ console.log("Invalid QR code URL");
676
+ return null;
677
+ }
678
+
679
+ return { clientId: match[2], version: parseInt(match[1], 10) };
680
+ }
681
+
682
+ export function decodeJwt(jwt) {
683
+ try {
684
+ const parts = jwt.split(".");
685
+ if (parts.length !== 3) {
686
+ console.err("decodeJwt Error", new Error("Invalid JWT"));
687
+ return;
688
+ }
689
+
690
+ const standardBase64 = parts[1].replace(/-/g, "+").replace(/_/g, "/");
691
+ return JSON.parse(Buffer.from(standardBase64, "base64").toString("utf8"));
692
+ } catch (e) {
693
+ console.error("decodeJwt Error", e);
694
+ }
695
+ }
696
+
697
+ export async function renewRefreshToken({ refreshToken, accessToken }) {
698
+ try {
699
+ const { aud } = decodeJwt(accessToken);
700
+ let platformType = EAuthTokenPlatformType.SteamClient;
701
+ if (aud.includes("mobile")) {
702
+ platformType = EAuthTokenPlatformType.MobileApp;
703
+ } else if (aud.includes("client")) {
704
+ platformType = EAuthTokenPlatformType.SteamClient;
705
+ } else if (aud.includes("web")) {
706
+ platformType = EAuthTokenPlatformType.WebBrowser;
707
+ }
708
+
709
+ const { LoginSession } = await import("steam-session");
710
+ const session = new LoginSession(platformType);
711
+ session.refreshToken = refreshToken;
712
+ await session.refreshAccessToken();
713
+ const cookie = (await session.getWebCookies())?.join?.(";");
714
+ return {
715
+ cookie,
716
+ accessToken: session.accessToken,
717
+ accessTokenDecoded: decodeJwt(session.accessToken),
718
+ };
719
+ } catch (e) {
720
+ console.error("renewRefreshToken Error", e);
721
+ }
722
+ }
723
+
724
+ export async function approveLogin({ steamId, url, sharedSecret, accessToken, shouldApprove }) {
725
+ try {
726
+ const { LoginApprover } = await import("steam-session");
727
+ const approver = new LoginApprover(accessToken, sharedSecret, {});
728
+ const sessionInfo = await approver.getAuthSessionInfo(url);
729
+ sessionInfo.steamId = steamId;
730
+
731
+ if (typeof shouldApprove === "function" && !shouldApprove(sessionInfo)) {
732
+ return;
733
+ }
734
+
735
+ await approver.approveAuthSession({
736
+ qrChallengeUrl: url,
737
+ approve: true,
738
+ });
739
+
740
+ return {
741
+ steamId,
742
+ sessionInfo,
743
+ };
744
+ } catch (error) {
745
+ console.error("approveLogin Error", error);
746
+ return {
747
+ steamId,
748
+ error,
749
+ };
750
+ }
751
+ }
752
+
753
+ export function getBonusXpTimeRefresh() {
754
+ let resetDay = moment.utc().startOf("isoWeek").add(2, "days").add(1, "hours");
755
+ while (moment().isAfter(resetDay)) {
756
+ resetDay = resetDay.add(7, "days");
757
+ }
758
+ if (moment().isBefore(resetDay)) {
759
+ resetDay = resetDay.subtract(7, "days");
760
+ }
761
+ return resetDay;
762
+ }
763
+
764
+ export function estimateNextXp(currentXp, xpEarned) {
765
+ //estimate next xp
766
+ let bonusTime = 1;
767
+ if (xpEarned < 4500) {
768
+ bonusTime = 4;
769
+ } else if (xpEarned < 7500) {
770
+ bonusTime = 2;
771
+ } else if (xpEarned < 11200) {
772
+ bonusTime = 1;
773
+ } else {
774
+ bonusTime = 0.175;
775
+ }
776
+
777
+ const nextXp = 30 * 13 * bonusTime;
778
+ return nextXp + currentXp;
779
+ }
780
+
781
+ export function formatMarketCurrency(valueInCents, currencyCode = getMarketCurrencyCode(g_rgWalletInfo.wallet_currency), countryCode) {
782
+ if (!valueInCents && valueInCents !== 0) {
783
+ return "";
784
+ }
785
+
786
+ let currencyFormat = (valueInCents / 100).toFixed(2);
787
+
788
+ if (g_rgCurrencyData[currencyCode]) {
789
+ const currencyData = g_rgCurrencyData[currencyCode];
790
+ if (isCurrencyWholeUnits(currencyCode)) {
791
+ currencyFormat = currencyFormat.replace(".00", "");
792
+ }
793
+
794
+ if (currencyData.strDecimalSymbol !== ".") {
795
+ currencyFormat = currencyFormat.replace(".", currencyData.strDecimalSymbol);
796
+ }
797
+
798
+ const currencySymbol = getMarketCurrencySymbol(currencyCode);
799
+ const currencyReturn = isCurrencySymbolBeforeValue(currencyCode) ? currencySymbol + currencyData.strSymbolAndNumberSeparator + currencyFormat : currencyFormat + currencyData.strSymbolAndNumberSeparator + currencySymbol;
800
+
801
+ if (currencyCode === "USD" && typeof countryCode != "undefined" && countryCode != "US") {
802
+ return `${currencyReturn} USD`;
803
+ } else if (currencyCode === "EUR") {
804
+ return currencyReturn.replace(",00", ",--");
805
+ } else {
806
+ return currencyReturn;
807
+ }
808
+ } else {
809
+ return `${currencyFormat} ${currencyCode}`;
810
+ }
811
+ }
812
+
813
+ export function getMarketPriceValueAsInt(strAmount) {
814
+ let nAmount;
815
+ if (!strAmount) {
816
+ return 0;
817
+ }
818
+
819
+ // Users may enter either comma or period for the decimal mark and digit group separators.
820
+ strAmount = strAmount.replace(/,/g, ".");
821
+
822
+ // strip the currency symbol, set .-- to .00
823
+ strAmount = strAmount.replace(getMarketCurrencySymbol(getMarketCurrencyCode(g_rgWalletInfo.wallet_currency)), "").replace(".--", ".00");
824
+
825
+ // strip spaces
826
+ strAmount = strAmount.replace(/ /g, "");
827
+
828
+ // Remove all but the last period so that entries like "1,147.6" work
829
+ if (strAmount.includes(".")) {
830
+ var splitAmount = strAmount.split(".");
831
+ var strLastSegment = splitAmount[splitAmount.length - 1];
832
+
833
+ if (!isNaN(strLastSegment) && strLastSegment.length == 3 && splitAmount[splitAmount.length - 2] != "0") {
834
+ // Looks like the user only entered thousands separators. Remove all commas and periods.
835
+ // Ensures an entry like "1,147" is not treated as "1.147"
836
+ //
837
+ // Users may be surprised to find that "1.147" is treated as "1,147". "1.147" is either an error or the user
838
+ // really did mean one thousand one hundred and forty seven since no currencies can be split into more than
839
+ // hundredths. If it was an error, the user should notice in the next step of the dialog and can go back and
840
+ // correct it. If they happen to not notice, it is better that we list the item at a higher price than
841
+ // intended instead of lower than intended (which we would have done if we accepted the 1.147 value as is).
842
+ strAmount = splitAmount.join("");
843
+ } else {
844
+ strAmount = `${splitAmount.slice(0, -1).join("")}.${strLastSegment}`;
845
+ }
846
+ }
847
+
848
+ let flAmount = parseFloat(strAmount) * 100;
849
+ nAmount = Math.floor(isNaN(flAmount) ? 0 : flAmount + 0.000001); // round down
850
+
851
+ nAmount = Math.max(nAmount, 0);
852
+ return nAmount;
853
+ }
854
+
855
+ export function isCurrencyWholeUnits(currencyCode) {
856
+ return g_rgCurrencyData[currencyCode] && g_rgCurrencyData[currencyCode].bWholeUnitsOnly && currencyCode !== "RUB";
857
+ }
858
+
859
+ export function isCurrencySymbolBeforeValue(currencyCode) {
860
+ return g_rgCurrencyData[currencyCode] && g_rgCurrencyData[currencyCode].bSymbolIsPrefix;
861
+ }
862
+
863
+ // Return the symbol to use for a currency
864
+ export function getMarketCurrencySymbol(currencyCode) {
865
+ return g_rgCurrencyData[currencyCode]?.strSymbol ?? currencyCode;
866
+ }
867
+
868
+ export function getMarketCurrencyCode(currencyId) {
869
+ currencyId = parseInt(currencyId);
870
+ for (const code in g_rgCurrencyData) {
871
+ if (g_rgCurrencyData[code].eCurrencyCode === currencyId) {
872
+ return code;
873
+ }
874
+ }
875
+ return "Unknown";
876
+ }
877
+
878
+ export async function loginWithCredentials({ username, password, timeoutMs = 120000, sharedSecret, getMailSteamGuardCodes }) {
879
+ if (!username) {
880
+ return {
881
+ error: "No username",
882
+ };
883
+ }
884
+
885
+ if (!password) {
886
+ return {
887
+ error: "No password",
888
+ };
889
+ }
890
+
891
+ const { LoginSession } = await import("steam-session");
892
+ let authenticated = false;
893
+ return new Promise((resolve) => {
894
+ const timeout = setTimeout(function () {
895
+ resolve({
896
+ error: "Timed out",
897
+ });
898
+ }, timeoutMs);
899
+
900
+ const session = new LoginSession(EAuthTokenPlatformType.MobileApp);
901
+ session.on("authenticated", async () => {
902
+ authenticated = true;
903
+ const cookie = (await session.getWebCookies())?.join?.(";");
904
+ return onResolve({
905
+ cookie,
906
+ accessToken: session.accessToken,
907
+ refreshToken: session.refreshToken,
908
+ accessTokenDecoded: decodeJwt(session.accessToken),
909
+ });
910
+ });
911
+
912
+ session
913
+ .startWithCredentials({
914
+ accountName: username,
915
+ password: password,
916
+ steamGuardMachineToken: "",
917
+ })
918
+ .then(async function (startResult) {
919
+ if (!startResult.actionRequired) {
920
+ return;
921
+ }
922
+
923
+ if (sharedSecret) {
924
+ let error = null;
925
+ const maxRetry = 3;
926
+ for (let i = 0; i < maxRetry; i++) {
927
+ try {
928
+ await session.submitSteamGuardCode(SteamTotp.generateAuthCode(sharedSecret));
929
+ error = null;
930
+ } catch (e) {
931
+ error = e;
932
+ }
933
+ await sleep(1000);
934
+ }
935
+ if (error) {
936
+ console.error(error);
937
+ onResolve({ error });
938
+ }
939
+ } else {
940
+ if (startResult.validActions.every((validAction) => validAction.type !== 2)) {
941
+ console.error(startResult.validActions);
942
+ return onResolve({
943
+ error: "validActions",
944
+ });
945
+ }
946
+
947
+ if (typeof getMailSteamGuardCodes === "function") {
948
+ const codes = await getMailSteamGuardCodes();
949
+ if (!Array.isArray(codes) || !codes.length) {
950
+ return onResolve({
951
+ error: "Can't find steam guard code",
952
+ });
953
+ }
954
+
955
+ let error = null;
956
+ for (const code of codes) {
957
+ if (!authenticated) {
958
+ try {
959
+ await session.submitSteamGuardCode(code);
960
+ error = null;
961
+ } catch (e) {
962
+ error = e;
963
+ }
964
+ await sleep(1000);
965
+ }
966
+ }
967
+ if (!authenticated && error) {
968
+ onResolve(error);
969
+ }
970
+ } else {
971
+ return onResolve({
972
+ error: "MailCodeError",
973
+ });
974
+ }
975
+ }
976
+ })
977
+ .catch(function (e) {
978
+ return onResolve(e);
979
+ });
980
+
981
+ function onResolve(data) {
982
+ clearTimeout(timeout);
983
+ return resolve(data);
984
+ }
985
+ });
986
+ }