@ecency/sdk 1.4.0 → 1.5.0

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.
@@ -9,6 +9,107 @@ var __export = (target, all) => {
9
9
  __defProp(target, name, { get: all[name], enumerable: true });
10
10
  };
11
11
 
12
+ // src/modules/keychain/keychain.ts
13
+ var keychain_exports = {};
14
+ __export(keychain_exports, {
15
+ broadcast: () => broadcast,
16
+ customJson: () => customJson,
17
+ handshake: () => handshake
18
+ });
19
+ function handshake() {
20
+ return new Promise((resolve) => {
21
+ window.hive_keychain?.requestHandshake(() => {
22
+ resolve();
23
+ });
24
+ });
25
+ }
26
+ var broadcast = (account, operations, key, rpc = null) => new Promise((resolve, reject) => {
27
+ window.hive_keychain?.requestBroadcast(
28
+ account,
29
+ operations,
30
+ key,
31
+ (resp) => {
32
+ if (!resp.success) {
33
+ reject({ message: "Operation cancelled" });
34
+ }
35
+ resolve(resp);
36
+ },
37
+ rpc
38
+ );
39
+ });
40
+ var customJson = (account, id, key, json, display_msg, rpc = null) => new Promise((resolve, reject) => {
41
+ window.hive_keychain?.requestCustomJson(
42
+ account,
43
+ id,
44
+ key,
45
+ json,
46
+ display_msg,
47
+ (resp) => {
48
+ if (!resp.success) {
49
+ reject({ message: "Operation cancelled" });
50
+ }
51
+ resolve(resp);
52
+ },
53
+ rpc
54
+ );
55
+ });
56
+
57
+ // src/modules/core/mutations/use-broadcast-mutation.ts
58
+ function useBroadcastMutation(mutationKey = [], username, accessToken, operations, onSuccess = () => {
59
+ }, auth) {
60
+ return useMutation({
61
+ onSuccess,
62
+ mutationKey: [...mutationKey, username],
63
+ mutationFn: async (payload) => {
64
+ if (!username) {
65
+ throw new Error(
66
+ "[Core][Broadcast] Attempted to call broadcast API with anon user"
67
+ );
68
+ }
69
+ const postingKey = auth?.postingKey;
70
+ if (postingKey) {
71
+ const privateKey = PrivateKey.fromString(postingKey);
72
+ return CONFIG.hiveClient.broadcast.sendOperations(
73
+ operations(payload),
74
+ privateKey
75
+ );
76
+ }
77
+ const loginType = auth?.loginType;
78
+ if (loginType && loginType == "keychain") {
79
+ return keychain_exports.broadcast(
80
+ username,
81
+ operations(payload),
82
+ "Posting"
83
+ ).then((r) => r.result);
84
+ }
85
+ if (accessToken) {
86
+ const f = getBoundFetch();
87
+ const res = await f("https://hivesigner.com/api/broadcast", {
88
+ method: "POST",
89
+ headers: {
90
+ Authorization: accessToken,
91
+ "Content-Type": "application/json",
92
+ Accept: "application/json"
93
+ },
94
+ body: JSON.stringify({ operations: operations(payload) })
95
+ });
96
+ if (!res.ok) {
97
+ const txt = await res.text().catch(() => "");
98
+ throw new Error(`[Hivesigner] ${res.status} ${res.statusText} ${txt}`);
99
+ }
100
+ const json = await res.json();
101
+ if (json?.errors) {
102
+ throw new Error(`[Hivesigner] ${JSON.stringify(json.errors)}`);
103
+ }
104
+ return json.result;
105
+ }
106
+ throw new Error(
107
+ "[SDK][Broadcast] \u2013 cannot broadcast w/o posting key or token"
108
+ );
109
+ }
110
+ });
111
+ }
112
+
12
113
  // src/modules/core/mock-storage.ts
13
114
  var MockStorage = class {
14
115
  length = 0;
@@ -30,6 +131,7 @@ var MockStorage = class {
30
131
  };
31
132
  var CONFIG = {
32
133
  privateApiHost: "https://ecency.com",
134
+ imageHost: "https://images.ecency.com",
33
135
  storage: typeof window === "undefined" ? new MockStorage() : window.localStorage,
34
136
  storagePrefix: "ecency",
35
137
  hiveClient: new Client(
@@ -76,6 +178,10 @@ var ConfigManager;
76
178
  CONFIG.privateApiHost = host;
77
179
  }
78
180
  ConfigManager2.setPrivateApiHost = setPrivateApiHost;
181
+ function setImageHost(host) {
182
+ CONFIG.imageHost = host;
183
+ }
184
+ ConfigManager2.setImageHost = setImageHost;
79
185
  function analyzeRedosRisk(pattern) {
80
186
  if (/(\([^)]*[*+{][^)]*\))[*+{]/.test(pattern)) {
81
187
  return { safe: false, reason: "nested quantifiers detected" };
@@ -182,6 +288,40 @@ var ConfigManager;
182
288
  }
183
289
  ConfigManager2.setDmcaLists = setDmcaLists;
184
290
  })(ConfigManager || (ConfigManager = {}));
291
+ async function broadcastJson(username, id, payload, accessToken, auth) {
292
+ if (!username) {
293
+ throw new Error(
294
+ "[Core][Broadcast] Attempted to call broadcast API with anon user"
295
+ );
296
+ }
297
+ const jjson = {
298
+ id,
299
+ required_auths: [],
300
+ required_posting_auths: [username],
301
+ json: JSON.stringify(payload)
302
+ };
303
+ const postingKey = auth?.postingKey;
304
+ if (postingKey) {
305
+ const privateKey = PrivateKey.fromString(postingKey);
306
+ return CONFIG.hiveClient.broadcast.json(
307
+ jjson,
308
+ privateKey
309
+ );
310
+ }
311
+ const loginType = auth?.loginType;
312
+ if (loginType && loginType == "keychain") {
313
+ return keychain_exports.broadcast(username, [["custom_json", jjson]], "Posting").then((r) => r.result);
314
+ }
315
+ if (accessToken) {
316
+ const response = await new hs.Client({
317
+ accessToken
318
+ }).customJson([], [username], id, JSON.stringify(payload));
319
+ return response.result;
320
+ }
321
+ throw new Error(
322
+ "[SDK][Broadcast] \u2013 cannot broadcast w/o posting key or token"
323
+ );
324
+ }
185
325
 
186
326
  // src/modules/core/utils/decoder-encoder.ts
187
327
  function encodeObj(o) {
@@ -238,6 +378,11 @@ function getBoundFetch() {
238
378
  return cachedFetch;
239
379
  }
240
380
 
381
+ // src/modules/core/utils/is-community.ts
382
+ function isCommunity(value) {
383
+ return typeof value === "string" ? /^hive-\d+$/.test(value) : false;
384
+ }
385
+
241
386
  // src/modules/core/storage.ts
242
387
  var getUser = (username) => {
243
388
  try {
@@ -254,143 +399,6 @@ var getAccessToken = (username) => getUser(username) && getUser(username).access
254
399
  var getPostingKey = (username) => getUser(username) && getUser(username).postingKey;
255
400
  var getLoginType = (username) => getUser(username) && getUser(username).loginType;
256
401
  var getRefreshToken = (username) => getUser(username) && getUser(username).refreshToken;
257
-
258
- // src/modules/keychain/keychain.ts
259
- var keychain_exports = {};
260
- __export(keychain_exports, {
261
- broadcast: () => broadcast,
262
- customJson: () => customJson,
263
- handshake: () => handshake
264
- });
265
- function handshake() {
266
- return new Promise((resolve) => {
267
- window.hive_keychain?.requestHandshake(() => {
268
- resolve();
269
- });
270
- });
271
- }
272
- var broadcast = (account, operations, key, rpc = null) => new Promise((resolve, reject) => {
273
- window.hive_keychain?.requestBroadcast(
274
- account,
275
- operations,
276
- key,
277
- (resp) => {
278
- if (!resp.success) {
279
- reject({ message: "Operation cancelled" });
280
- }
281
- resolve(resp);
282
- },
283
- rpc
284
- );
285
- });
286
- var customJson = (account, id, key, json, display_msg, rpc = null) => new Promise((resolve, reject) => {
287
- window.hive_keychain?.requestCustomJson(
288
- account,
289
- id,
290
- key,
291
- json,
292
- display_msg,
293
- (resp) => {
294
- if (!resp.success) {
295
- reject({ message: "Operation cancelled" });
296
- }
297
- resolve(resp);
298
- },
299
- rpc
300
- );
301
- });
302
-
303
- // src/modules/core/mutations/use-broadcast-mutation.ts
304
- function useBroadcastMutation(mutationKey = [], username, operations, onSuccess = () => {
305
- }) {
306
- return useMutation({
307
- onSuccess,
308
- mutationKey: [...mutationKey, username],
309
- mutationFn: async (payload) => {
310
- if (!username) {
311
- throw new Error(
312
- "[Core][Broadcast] Attempted to call broadcast API with anon user"
313
- );
314
- }
315
- const postingKey = getPostingKey(username);
316
- if (postingKey) {
317
- const privateKey = PrivateKey.fromString(postingKey);
318
- return CONFIG.hiveClient.broadcast.sendOperations(
319
- operations(payload),
320
- privateKey
321
- );
322
- }
323
- const loginType = getLoginType(username);
324
- if (loginType && loginType == "keychain") {
325
- return keychain_exports.broadcast(
326
- username,
327
- operations(payload),
328
- "Posting"
329
- ).then((r) => r.result);
330
- }
331
- let token = getAccessToken(username);
332
- if (token) {
333
- const f = getBoundFetch();
334
- const res = await f("https://hivesigner.com/api/broadcast", {
335
- method: "POST",
336
- headers: {
337
- Authorization: token,
338
- "Content-Type": "application/json",
339
- Accept: "application/json"
340
- },
341
- body: JSON.stringify({ operations: operations(payload) })
342
- });
343
- if (!res.ok) {
344
- const txt = await res.text().catch(() => "");
345
- throw new Error(`[Hivesigner] ${res.status} ${res.statusText} ${txt}`);
346
- }
347
- const json = await res.json();
348
- if (json?.errors) {
349
- throw new Error(`[Hivesigner] ${JSON.stringify(json.errors)}`);
350
- }
351
- return json.result;
352
- }
353
- throw new Error(
354
- "[SDK][Broadcast] \u2013 cannot broadcast w/o posting key or token"
355
- );
356
- }
357
- });
358
- }
359
- async function broadcastJson(username, id, payload) {
360
- if (!username) {
361
- throw new Error(
362
- "[Core][Broadcast] Attempted to call broadcast API with anon user"
363
- );
364
- }
365
- const jjson = {
366
- id,
367
- required_auths: [],
368
- required_posting_auths: [username],
369
- json: JSON.stringify(payload)
370
- };
371
- const postingKey = getPostingKey(username);
372
- if (postingKey) {
373
- const privateKey = PrivateKey.fromString(postingKey);
374
- return CONFIG.hiveClient.broadcast.json(
375
- jjson,
376
- privateKey
377
- );
378
- }
379
- const loginType = getLoginType(username);
380
- if (loginType && loginType == "keychain") {
381
- return keychain_exports.broadcast(username, [["custom_json", jjson]], "Posting").then((r) => r.result);
382
- }
383
- let token = getAccessToken(username);
384
- if (token) {
385
- const response = await new hs.Client({
386
- accessToken: token
387
- }).customJson([], [username], id, JSON.stringify(payload));
388
- return response.result;
389
- }
390
- throw new Error(
391
- "[SDK][Broadcast] \u2013 cannot broadcast w/o posting key or token"
392
- );
393
- }
394
402
  function makeQueryClient() {
395
403
  return new QueryClient({
396
404
  defaultOptions: {
@@ -898,13 +906,13 @@ function getAccountSubscriptionsQueryOptions(username) {
898
906
  }
899
907
  });
900
908
  }
901
- function getActiveAccountBookmarksQueryOptions(activeUsername) {
909
+ function getActiveAccountBookmarksQueryOptions(activeUsername, code) {
902
910
  return queryOptions({
903
911
  queryKey: ["accounts", "bookmarks", activeUsername],
904
- enabled: !!activeUsername,
912
+ enabled: !!activeUsername && !!code,
905
913
  queryFn: async () => {
906
- if (!activeUsername) {
907
- throw new Error("[SDK][Accounts][Bookmarks] \u2013 no active user");
914
+ if (!activeUsername || !code) {
915
+ throw new Error("[SDK][Accounts][Bookmarks] \u2013 missing auth");
908
916
  }
909
917
  const fetchApi = getBoundFetch();
910
918
  const response = await fetchApi(
@@ -914,20 +922,20 @@ function getActiveAccountBookmarksQueryOptions(activeUsername) {
914
922
  headers: {
915
923
  "Content-Type": "application/json"
916
924
  },
917
- body: JSON.stringify({ code: getAccessToken(activeUsername) })
925
+ body: JSON.stringify({ code })
918
926
  }
919
927
  );
920
928
  return await response.json();
921
929
  }
922
930
  });
923
931
  }
924
- function getActiveAccountFavouritesQueryOptions(activeUsername) {
932
+ function getActiveAccountFavouritesQueryOptions(activeUsername, code) {
925
933
  return queryOptions({
926
934
  queryKey: ["accounts", "favourites", activeUsername],
927
- enabled: !!activeUsername,
935
+ enabled: !!activeUsername && !!code,
928
936
  queryFn: async () => {
929
- if (!activeUsername) {
930
- throw new Error("[SDK][Accounts][Favourites] \u2013 no active user");
937
+ if (!activeUsername || !code) {
938
+ throw new Error("[SDK][Accounts][Favourites] \u2013 missing auth");
931
939
  }
932
940
  const fetchApi = getBoundFetch();
933
941
  const response = await fetchApi(
@@ -937,18 +945,21 @@ function getActiveAccountFavouritesQueryOptions(activeUsername) {
937
945
  headers: {
938
946
  "Content-Type": "application/json"
939
947
  },
940
- body: JSON.stringify({ code: getAccessToken(activeUsername) })
948
+ body: JSON.stringify({ code })
941
949
  }
942
950
  );
943
951
  return await response.json();
944
952
  }
945
953
  });
946
954
  }
947
- function getAccountRecoveriesQueryOptions(username) {
955
+ function getAccountRecoveriesQueryOptions(username, code) {
948
956
  return queryOptions({
949
- enabled: !!username,
957
+ enabled: !!username && !!code,
950
958
  queryKey: ["accounts", "recoveries", username],
951
959
  queryFn: async () => {
960
+ if (!username || !code) {
961
+ throw new Error("[SDK][Accounts] Missing username or access token");
962
+ }
952
963
  const fetchApi = getBoundFetch();
953
964
  const response = await fetchApi(
954
965
  CONFIG.privateApiHost + "/private-api/recoveries",
@@ -957,7 +968,7 @@ function getAccountRecoveriesQueryOptions(username) {
957
968
  headers: {
958
969
  "Content-Type": "application/json"
959
970
  },
960
- body: JSON.stringify({ code: getAccessToken(username) })
971
+ body: JSON.stringify({ code })
961
972
  }
962
973
  );
963
974
  return response.json();
@@ -1220,17 +1231,32 @@ function getTrendingTagsQueryOptions(limit = 20) {
1220
1231
  refetchOnMount: true
1221
1232
  });
1222
1233
  }
1223
- function getFragmentsQueryOptions(username) {
1234
+ function getTrendingTagsWithStatsQueryOptions(limit = 250) {
1235
+ return infiniteQueryOptions({
1236
+ queryKey: ["posts", "trending-tags", "stats", limit],
1237
+ queryFn: async ({ pageParam: { afterTag } }) => CONFIG.hiveClient.database.call("get_trending_tags", [afterTag, limit]).then(
1238
+ (tags) => tags.filter((tag) => tag.name !== "").filter((tag) => !isCommunity(tag.name))
1239
+ ),
1240
+ initialPageParam: { afterTag: "" },
1241
+ getNextPageParam: (lastPage) => lastPage?.length ? { afterTag: lastPage[lastPage.length - 1].name } : void 0,
1242
+ staleTime: Infinity,
1243
+ refetchOnMount: true
1244
+ });
1245
+ }
1246
+ function getFragmentsQueryOptions(username, code) {
1224
1247
  return queryOptions({
1225
1248
  queryKey: ["posts", "fragments", username],
1226
1249
  queryFn: async () => {
1250
+ if (!code) {
1251
+ return [];
1252
+ }
1227
1253
  const fetchApi = getBoundFetch();
1228
1254
  const response = await fetchApi(
1229
1255
  CONFIG.privateApiHost + "/private-api/fragments",
1230
1256
  {
1231
1257
  method: "POST",
1232
1258
  body: JSON.stringify({
1233
- code: getAccessToken(username)
1259
+ code
1234
1260
  }),
1235
1261
  headers: {
1236
1262
  "Content-Type": "application/json"
@@ -1239,7 +1265,7 @@ function getFragmentsQueryOptions(username) {
1239
1265
  );
1240
1266
  return response.json();
1241
1267
  },
1242
- enabled: !!username
1268
+ enabled: !!username && !!code
1243
1269
  });
1244
1270
  }
1245
1271
  function getPromotedPostsQuery(type = "feed") {
@@ -1546,20 +1572,21 @@ function getReblogsQueryOptions(username, activeUsername, limit = 200) {
1546
1572
  enabled: !!username
1547
1573
  });
1548
1574
  }
1549
- function getSchedulesQueryOptions(activeUsername) {
1575
+ function getSchedulesQueryOptions(activeUsername, code) {
1550
1576
  return queryOptions({
1551
1577
  queryKey: ["posts", "schedules", activeUsername],
1552
1578
  queryFn: async () => {
1553
- if (!activeUsername) {
1579
+ if (!activeUsername || !code) {
1554
1580
  return [];
1555
1581
  }
1556
- const response = await fetch(CONFIG.privateApiHost + "/private-api/schedules", {
1582
+ const fetchApi = getBoundFetch();
1583
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/schedules", {
1557
1584
  method: "POST",
1558
1585
  headers: {
1559
1586
  "Content-Type": "application/json"
1560
1587
  },
1561
1588
  body: JSON.stringify({
1562
- code: getAccessToken(activeUsername)
1589
+ code
1563
1590
  })
1564
1591
  });
1565
1592
  if (!response.ok) {
@@ -1567,23 +1594,24 @@ function getSchedulesQueryOptions(activeUsername) {
1567
1594
  }
1568
1595
  return response.json();
1569
1596
  },
1570
- enabled: !!activeUsername
1597
+ enabled: !!activeUsername && !!code
1571
1598
  });
1572
1599
  }
1573
- function getDraftsQueryOptions(activeUsername) {
1600
+ function getDraftsQueryOptions(activeUsername, code) {
1574
1601
  return queryOptions({
1575
1602
  queryKey: ["posts", "drafts", activeUsername],
1576
1603
  queryFn: async () => {
1577
- if (!activeUsername) {
1604
+ if (!activeUsername || !code) {
1578
1605
  return [];
1579
1606
  }
1580
- const response = await fetch(CONFIG.privateApiHost + "/private-api/drafts", {
1607
+ const fetchApi = getBoundFetch();
1608
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/drafts", {
1581
1609
  method: "POST",
1582
1610
  headers: {
1583
1611
  "Content-Type": "application/json"
1584
1612
  },
1585
1613
  body: JSON.stringify({
1586
- code: getAccessToken(activeUsername)
1614
+ code
1587
1615
  })
1588
1616
  });
1589
1617
  if (!response.ok) {
@@ -1591,17 +1619,18 @@ function getDraftsQueryOptions(activeUsername) {
1591
1619
  }
1592
1620
  return response.json();
1593
1621
  },
1594
- enabled: !!activeUsername
1622
+ enabled: !!activeUsername && !!code
1595
1623
  });
1596
1624
  }
1597
- async function fetchUserImages(username) {
1598
- const response = await fetch(CONFIG.privateApiHost + "/private-api/images", {
1625
+ async function fetchUserImages(code) {
1626
+ const fetchApi = getBoundFetch();
1627
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/images", {
1599
1628
  method: "POST",
1600
1629
  headers: {
1601
1630
  "Content-Type": "application/json"
1602
1631
  },
1603
1632
  body: JSON.stringify({
1604
- code: getAccessToken(username)
1633
+ code
1605
1634
  })
1606
1635
  });
1607
1636
  if (!response.ok) {
@@ -1609,28 +1638,28 @@ async function fetchUserImages(username) {
1609
1638
  }
1610
1639
  return response.json();
1611
1640
  }
1612
- function getImagesQueryOptions(username) {
1641
+ function getImagesQueryOptions(username, code) {
1613
1642
  return queryOptions({
1614
1643
  queryKey: ["posts", "images", username],
1615
1644
  queryFn: async () => {
1616
- if (!username) {
1645
+ if (!username || !code) {
1617
1646
  return [];
1618
1647
  }
1619
- return fetchUserImages(username);
1648
+ return fetchUserImages(code);
1620
1649
  },
1621
- enabled: !!username
1650
+ enabled: !!username && !!code
1622
1651
  });
1623
1652
  }
1624
- function getGalleryImagesQueryOptions(activeUsername) {
1653
+ function getGalleryImagesQueryOptions(activeUsername, code) {
1625
1654
  return queryOptions({
1626
1655
  queryKey: ["posts", "gallery-images", activeUsername],
1627
1656
  queryFn: async () => {
1628
- if (!activeUsername) {
1657
+ if (!activeUsername || !code) {
1629
1658
  return [];
1630
1659
  }
1631
- return fetchUserImages(activeUsername);
1660
+ return fetchUserImages(code);
1632
1661
  },
1633
- enabled: !!activeUsername
1662
+ enabled: !!activeUsername && !!code
1634
1663
  });
1635
1664
  }
1636
1665
  function getCommentHistoryQueryOptions(author, permlink, onlyMeta = false) {
@@ -2026,12 +2055,13 @@ function getAccountVoteHistoryInfiniteQueryOptions(username, options) {
2026
2055
  }
2027
2056
 
2028
2057
  // src/modules/accounts/mutations/use-account-update.ts
2029
- function useAccountUpdate(username) {
2058
+ function useAccountUpdate(username, accessToken, auth) {
2030
2059
  const queryClient = useQueryClient();
2031
2060
  const { data } = useQuery(getAccountFullQueryOptions(username));
2032
2061
  return useBroadcastMutation(
2033
2062
  ["accounts", "update"],
2034
2063
  username,
2064
+ accessToken,
2035
2065
  (payload) => {
2036
2066
  if (!data) {
2037
2067
  throw new Error("[SDK][Accounts] \u2013 cannot update not existing account");
@@ -2055,7 +2085,7 @@ function useAccountUpdate(username) {
2055
2085
  ]
2056
2086
  ];
2057
2087
  },
2058
- (_, variables) => queryClient.setQueryData(
2088
+ (_data, variables) => queryClient.setQueryData(
2059
2089
  getAccountFullQueryOptions(username).queryKey,
2060
2090
  (data2) => {
2061
2091
  if (!data2) {
@@ -2069,7 +2099,8 @@ function useAccountUpdate(username) {
2069
2099
  });
2070
2100
  return obj;
2071
2101
  }
2072
- )
2102
+ ),
2103
+ auth
2073
2104
  );
2074
2105
  }
2075
2106
  function useAccountRelationsUpdate(reference, target, onSuccess, onError) {
@@ -2111,12 +2142,12 @@ function useAccountRelationsUpdate(reference, target, onSuccess, onError) {
2111
2142
  }
2112
2143
  });
2113
2144
  }
2114
- function useBookmarkAdd(username, onSuccess, onError) {
2145
+ function useBookmarkAdd(username, code, onSuccess, onError) {
2115
2146
  return useMutation({
2116
2147
  mutationKey: ["accounts", "bookmarks", "add", username],
2117
2148
  mutationFn: async ({ author, permlink }) => {
2118
- if (!username) {
2119
- throw new Error("[SDK][Account][Bookmarks] \u2013 no active user");
2149
+ if (!username || !code) {
2150
+ throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
2120
2151
  }
2121
2152
  const fetchApi = getBoundFetch();
2122
2153
  const response = await fetchApi(
@@ -2129,7 +2160,7 @@ function useBookmarkAdd(username, onSuccess, onError) {
2129
2160
  body: JSON.stringify({
2130
2161
  author,
2131
2162
  permlink,
2132
- code: getAccessToken(username)
2163
+ code
2133
2164
  })
2134
2165
  }
2135
2166
  );
@@ -2144,12 +2175,12 @@ function useBookmarkAdd(username, onSuccess, onError) {
2144
2175
  onError
2145
2176
  });
2146
2177
  }
2147
- function useBookmarkDelete(username, onSuccess, onError) {
2178
+ function useBookmarkDelete(username, code, onSuccess, onError) {
2148
2179
  return useMutation({
2149
2180
  mutationKey: ["accounts", "bookmarks", "delete", username],
2150
2181
  mutationFn: async (bookmarkId) => {
2151
- if (!username) {
2152
- throw new Error("[SDK][Account][Bookmarks] \u2013 no active user");
2182
+ if (!username || !code) {
2183
+ throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
2153
2184
  }
2154
2185
  const fetchApi = getBoundFetch();
2155
2186
  const response = await fetchApi(
@@ -2161,7 +2192,7 @@ function useBookmarkDelete(username, onSuccess, onError) {
2161
2192
  },
2162
2193
  body: JSON.stringify({
2163
2194
  id: bookmarkId,
2164
- code: getAccessToken(username)
2195
+ code
2165
2196
  })
2166
2197
  }
2167
2198
  );
@@ -2176,12 +2207,12 @@ function useBookmarkDelete(username, onSuccess, onError) {
2176
2207
  onError
2177
2208
  });
2178
2209
  }
2179
- function useAccountFavouriteAdd(username, onSuccess, onError) {
2210
+ function useAccountFavouriteAdd(username, code, onSuccess, onError) {
2180
2211
  return useMutation({
2181
2212
  mutationKey: ["accounts", "favourites", "add", username],
2182
2213
  mutationFn: async (account) => {
2183
- if (!username) {
2184
- throw new Error("[SDK][Account][Bookmarks] \u2013 no active user");
2214
+ if (!username || !code) {
2215
+ throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
2185
2216
  }
2186
2217
  const fetchApi = getBoundFetch();
2187
2218
  const response = await fetchApi(
@@ -2193,7 +2224,7 @@ function useAccountFavouriteAdd(username, onSuccess, onError) {
2193
2224
  },
2194
2225
  body: JSON.stringify({
2195
2226
  account,
2196
- code: getAccessToken(username)
2227
+ code
2197
2228
  })
2198
2229
  }
2199
2230
  );
@@ -2208,12 +2239,12 @@ function useAccountFavouriteAdd(username, onSuccess, onError) {
2208
2239
  onError
2209
2240
  });
2210
2241
  }
2211
- function useAccountFavouriteDelete(username, onSuccess, onError) {
2242
+ function useAccountFavouriteDelete(username, code, onSuccess, onError) {
2212
2243
  return useMutation({
2213
2244
  mutationKey: ["accounts", "favourites", "add", username],
2214
2245
  mutationFn: async (account) => {
2215
- if (!username) {
2216
- throw new Error("[SDK][Account][Bookmarks] \u2013 no active user");
2246
+ if (!username || !code) {
2247
+ throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
2217
2248
  }
2218
2249
  const fetchApi = getBoundFetch();
2219
2250
  const response = await fetchApi(
@@ -2225,7 +2256,7 @@ function useAccountFavouriteDelete(username, onSuccess, onError) {
2225
2256
  },
2226
2257
  body: JSON.stringify({
2227
2258
  account,
2228
- code: getAccessToken(username)
2259
+ code
2229
2260
  })
2230
2261
  }
2231
2262
  );
@@ -2383,7 +2414,7 @@ function useAccountRevokePosting(username, options) {
2383
2414
  }
2384
2415
  });
2385
2416
  }
2386
- function useAccountUpdateRecovery(username, options) {
2417
+ function useAccountUpdateRecovery(username, code, options) {
2387
2418
  const { data } = useQuery(getAccountFullQueryOptions(username));
2388
2419
  return useMutation({
2389
2420
  mutationKey: ["accounts", "recovery", data?.name],
@@ -2399,11 +2430,14 @@ function useAccountUpdateRecovery(username, options) {
2399
2430
  extensions: []
2400
2431
  };
2401
2432
  if (type === "ecency") {
2433
+ if (!code) {
2434
+ throw new Error("[SDK][Accounts] \u2013 missing access token");
2435
+ }
2402
2436
  const fetchApi = getBoundFetch();
2403
2437
  return fetchApi(CONFIG.privateApiHost + "/private-api/recoveries-add", {
2404
2438
  method: "POST",
2405
2439
  body: JSON.stringify({
2406
- code: getAccessToken(data.name),
2440
+ code,
2407
2441
  email,
2408
2442
  publicKeys: [
2409
2443
  ...data.owner.key_auths,
@@ -2527,17 +2561,20 @@ function getChainPropertiesQueryOptions() {
2527
2561
  }
2528
2562
  });
2529
2563
  }
2530
- function useAddFragment(username) {
2564
+ function useAddFragment(username, code) {
2531
2565
  return useMutation({
2532
2566
  mutationKey: ["posts", "add-fragment", username],
2533
2567
  mutationFn: async ({ title, body }) => {
2568
+ if (!code) {
2569
+ throw new Error("[SDK][Posts] Missing access token");
2570
+ }
2534
2571
  const fetchApi = getBoundFetch();
2535
2572
  const response = await fetchApi(
2536
2573
  CONFIG.privateApiHost + "/private-api/fragments-add",
2537
2574
  {
2538
2575
  method: "POST",
2539
2576
  body: JSON.stringify({
2540
- code: getAccessToken(username),
2577
+ code,
2541
2578
  title,
2542
2579
  body
2543
2580
  }),
@@ -2550,23 +2587,26 @@ function useAddFragment(username) {
2550
2587
  },
2551
2588
  onSuccess(response) {
2552
2589
  getQueryClient().setQueryData(
2553
- getFragmentsQueryOptions(username).queryKey,
2590
+ getFragmentsQueryOptions(username, code).queryKey,
2554
2591
  (data) => [response, ...data ?? []]
2555
2592
  );
2556
2593
  }
2557
2594
  });
2558
2595
  }
2559
- function useEditFragment(username, fragmentId) {
2596
+ function useEditFragment(username, fragmentId, code) {
2560
2597
  return useMutation({
2561
2598
  mutationKey: ["posts", "edit-fragment", username, fragmentId],
2562
2599
  mutationFn: async ({ title, body }) => {
2600
+ if (!code) {
2601
+ throw new Error("[SDK][Posts] Missing access token");
2602
+ }
2563
2603
  const fetchApi = getBoundFetch();
2564
2604
  const response = await fetchApi(
2565
2605
  CONFIG.privateApiHost + "/private-api/fragments-update",
2566
2606
  {
2567
2607
  method: "POST",
2568
2608
  body: JSON.stringify({
2569
- code: getAccessToken(username),
2609
+ code,
2570
2610
  id: fragmentId,
2571
2611
  title,
2572
2612
  body
@@ -2580,7 +2620,7 @@ function useEditFragment(username, fragmentId) {
2580
2620
  },
2581
2621
  onSuccess(response) {
2582
2622
  getQueryClient().setQueryData(
2583
- getFragmentsQueryOptions(username).queryKey,
2623
+ getFragmentsQueryOptions(username, code).queryKey,
2584
2624
  (data) => {
2585
2625
  if (!data) {
2586
2626
  return [];
@@ -2595,15 +2635,18 @@ function useEditFragment(username, fragmentId) {
2595
2635
  }
2596
2636
  });
2597
2637
  }
2598
- function useRemoveFragment(username, fragmentId) {
2638
+ function useRemoveFragment(username, fragmentId, code) {
2599
2639
  return useMutation({
2600
2640
  mutationKey: ["posts", "remove-fragment", username],
2601
2641
  mutationFn: async () => {
2642
+ if (!code) {
2643
+ throw new Error("[SDK][Posts] Missing access token");
2644
+ }
2602
2645
  const fetchApi = getBoundFetch();
2603
2646
  return fetchApi(CONFIG.privateApiHost + "/private-api/fragments-delete", {
2604
2647
  method: "POST",
2605
2648
  body: JSON.stringify({
2606
- code: getAccessToken(username),
2649
+ code,
2607
2650
  id: fragmentId
2608
2651
  }),
2609
2652
  headers: {
@@ -2613,7 +2656,7 @@ function useRemoveFragment(username, fragmentId) {
2613
2656
  },
2614
2657
  onSuccess() {
2615
2658
  getQueryClient().setQueryData(
2616
- getFragmentsQueryOptions(username).queryKey,
2659
+ getFragmentsQueryOptions(username, code).queryKey,
2617
2660
  (data) => [...data ?? []].filter(({ id }) => id !== fragmentId)
2618
2661
  );
2619
2662
  }
@@ -2732,11 +2775,10 @@ var queries_exports = {};
2732
2775
  __export(queries_exports, {
2733
2776
  getDecodeMemoQueryOptions: () => getDecodeMemoQueryOptions
2734
2777
  });
2735
- function getDecodeMemoQueryOptions(username, memo) {
2778
+ function getDecodeMemoQueryOptions(username, memo, accessToken) {
2736
2779
  return queryOptions({
2737
2780
  queryKey: ["integrations", "hivesigner", "decode-memo", username],
2738
2781
  queryFn: async () => {
2739
- const accessToken = getAccessToken(username);
2740
2782
  if (accessToken) {
2741
2783
  const hsClient = new hs.Client({
2742
2784
  accessToken
@@ -2753,12 +2795,12 @@ var HiveSignerIntegration = {
2753
2795
  };
2754
2796
 
2755
2797
  // src/modules/integrations/3speak/queries/get-account-token-query-options.ts
2756
- function getAccountTokenQueryOptions(username) {
2798
+ function getAccountTokenQueryOptions(username, accessToken) {
2757
2799
  return queryOptions({
2758
2800
  queryKey: ["integrations", "3speak", "authenticate", username],
2759
- enabled: !!username,
2801
+ enabled: !!username && !!accessToken,
2760
2802
  queryFn: async () => {
2761
- if (!username) {
2803
+ if (!username || !accessToken) {
2762
2804
  throw new Error("[SDK][Integrations][3Speak] \u2013\xA0anon user");
2763
2805
  }
2764
2806
  const fetchApi = getBoundFetch();
@@ -2772,7 +2814,8 @@ function getAccountTokenQueryOptions(username) {
2772
2814
  );
2773
2815
  const memoQueryOptions = HiveSignerIntegration.queries.getDecodeMemoQueryOptions(
2774
2816
  username,
2775
- (await response.json()).memo
2817
+ (await response.json()).memo,
2818
+ accessToken
2776
2819
  );
2777
2820
  await getQueryClient().prefetchQuery(memoQueryOptions);
2778
2821
  const { memoDecoded } = getQueryClient().getQueryData(
@@ -2782,17 +2825,23 @@ function getAccountTokenQueryOptions(username) {
2782
2825
  }
2783
2826
  });
2784
2827
  }
2785
- function getAccountVideosQueryOptions(username) {
2828
+ function getAccountVideosQueryOptions(username, accessToken) {
2786
2829
  return queryOptions({
2787
2830
  queryKey: ["integrations", "3speak", "videos", username],
2788
- enabled: !!username,
2831
+ enabled: !!username && !!accessToken,
2789
2832
  queryFn: async () => {
2790
- await getQueryClient().prefetchQuery(
2791
- getAccountTokenQueryOptions(username)
2792
- );
2793
- const token = getQueryClient().getQueryData(
2794
- getAccountTokenQueryOptions(username).queryKey
2833
+ if (!username || !accessToken) {
2834
+ throw new Error("[SDK][Integrations][3Speak] \u2013\xA0anon user");
2835
+ }
2836
+ const tokenQueryOptions = getAccountTokenQueryOptions(
2837
+ username,
2838
+ accessToken
2795
2839
  );
2840
+ await getQueryClient().prefetchQuery(tokenQueryOptions);
2841
+ const token = getQueryClient().getQueryData(tokenQueryOptions.queryKey);
2842
+ if (!token) {
2843
+ throw new Error("[SDK][Integrations][3Speak] \u2013 missing account token");
2844
+ }
2796
2845
  const fetchApi = getBoundFetch();
2797
2846
  const response = await fetchApi(
2798
2847
  `https://studio.3speak.tv/mobile/api/my-videos`,
@@ -2903,13 +2952,13 @@ function getAccountRcQueryOptions(username) {
2903
2952
  enabled: !!username
2904
2953
  });
2905
2954
  }
2906
- function getGameStatusCheckQueryOptions(username, gameType) {
2955
+ function getGameStatusCheckQueryOptions(username, code, gameType) {
2907
2956
  return queryOptions({
2908
2957
  queryKey: ["games", "status-check", gameType, username],
2909
- enabled: !!username,
2958
+ enabled: !!username && !!code,
2910
2959
  queryFn: async () => {
2911
- if (!username) {
2912
- throw new Error("[SDK][Games] \u2013 anon user in status check");
2960
+ if (!username || !code) {
2961
+ throw new Error("[SDK][Games] \u2013 missing auth");
2913
2962
  }
2914
2963
  const fetchApi = getBoundFetch();
2915
2964
  const response = await fetchApi(
@@ -2918,7 +2967,7 @@ function getGameStatusCheckQueryOptions(username, gameType) {
2918
2967
  method: "POST",
2919
2968
  body: JSON.stringify({
2920
2969
  game_type: gameType,
2921
- code: getAccessToken(username)
2970
+ code
2922
2971
  }),
2923
2972
  headers: {
2924
2973
  "Content-Type": "application/json"
@@ -2929,7 +2978,7 @@ function getGameStatusCheckQueryOptions(username, gameType) {
2929
2978
  }
2930
2979
  });
2931
2980
  }
2932
- function useGameClaim(username, gameType, key) {
2981
+ function useGameClaim(username, code, gameType, key) {
2933
2982
  const { mutateAsync: recordActivity } = useRecordActivity(
2934
2983
  username,
2935
2984
  "spin-rolled"
@@ -2937,8 +2986,8 @@ function useGameClaim(username, gameType, key) {
2937
2986
  return useMutation({
2938
2987
  mutationKey: ["games", "post", gameType, username],
2939
2988
  mutationFn: async () => {
2940
- if (!username) {
2941
- throw new Error("[SDK][Games] \u2013 anon user in game post");
2989
+ if (!username || !code) {
2990
+ throw new Error("[SDK][Games] \u2013 missing auth");
2942
2991
  }
2943
2992
  const fetchApi = getBoundFetch();
2944
2993
  const response = await fetchApi(
@@ -2947,7 +2996,7 @@ function useGameClaim(username, gameType, key) {
2947
2996
  method: "POST",
2948
2997
  body: JSON.stringify({
2949
2998
  game_type: gameType,
2950
- code: getAccessToken(username),
2999
+ code,
2951
3000
  key
2952
3001
  }),
2953
3002
  headers: {
@@ -3112,15 +3161,18 @@ function getCommunityPermissions({
3112
3161
  isModerator
3113
3162
  };
3114
3163
  }
3115
- function getNotificationsUnreadCountQueryOptions(activeUsername) {
3164
+ function getNotificationsUnreadCountQueryOptions(activeUsername, code) {
3116
3165
  return queryOptions({
3117
3166
  queryKey: ["notifications", "unread", activeUsername],
3118
3167
  queryFn: async () => {
3168
+ if (!code) {
3169
+ return 0;
3170
+ }
3119
3171
  const response = await fetch(
3120
3172
  `${CONFIG.privateApiHost}/private-api/notifications/unread`,
3121
3173
  {
3122
3174
  method: "POST",
3123
- body: JSON.stringify({ code: getAccessToken(activeUsername) }),
3175
+ body: JSON.stringify({ code }),
3124
3176
  headers: {
3125
3177
  "Content-Type": "application/json"
3126
3178
  }
@@ -3129,17 +3181,20 @@ function getNotificationsUnreadCountQueryOptions(activeUsername) {
3129
3181
  const data = await response.json();
3130
3182
  return data.count;
3131
3183
  },
3132
- enabled: !!activeUsername,
3184
+ enabled: !!activeUsername && !!code,
3133
3185
  initialData: 0,
3134
3186
  refetchInterval: 6e4
3135
3187
  });
3136
3188
  }
3137
- function getNotificationsInfiniteQueryOptions(activeUsername, filter = void 0) {
3189
+ function getNotificationsInfiniteQueryOptions(activeUsername, code, filter = void 0) {
3138
3190
  return infiniteQueryOptions({
3139
3191
  queryKey: ["notifications", activeUsername, filter],
3140
3192
  queryFn: async ({ pageParam }) => {
3193
+ if (!code) {
3194
+ return [];
3195
+ }
3141
3196
  const data = {
3142
- code: getAccessToken(activeUsername),
3197
+ code,
3143
3198
  filter,
3144
3199
  since: pageParam,
3145
3200
  user: void 0
@@ -3156,7 +3211,7 @@ function getNotificationsInfiniteQueryOptions(activeUsername, filter = void 0) {
3156
3211
  );
3157
3212
  return response.json();
3158
3213
  },
3159
- enabled: !!activeUsername,
3214
+ enabled: !!activeUsername && !!code,
3160
3215
  initialData: { pages: [], pageParams: [] },
3161
3216
  initialPageParam: "",
3162
3217
  getNextPageParam: (lastPage) => lastPage?.[lastPage.length - 1]?.id ?? "",
@@ -3209,16 +3264,19 @@ var NotificationViewType = /* @__PURE__ */ ((NotificationViewType2) => {
3209
3264
  })(NotificationViewType || {});
3210
3265
 
3211
3266
  // src/modules/notifications/queries/get-notifications-settings-query-options.ts
3212
- function getNotificationsSettingsQueryOptions(activeUsername) {
3267
+ function getNotificationsSettingsQueryOptions(activeUsername, code) {
3213
3268
  return queryOptions({
3214
3269
  queryKey: ["notifications", "settings", activeUsername],
3215
3270
  queryFn: async () => {
3216
3271
  let token = activeUsername + "-web";
3272
+ if (!code) {
3273
+ throw new Error("Missing access token");
3274
+ }
3217
3275
  const response = await fetch(
3218
3276
  CONFIG.privateApiHost + "/private-api/detail-device",
3219
3277
  {
3220
3278
  body: JSON.stringify({
3221
- code: getAccessToken(activeUsername),
3279
+ code,
3222
3280
  username: activeUsername,
3223
3281
  token
3224
3282
  }),
@@ -3233,7 +3291,7 @@ function getNotificationsSettingsQueryOptions(activeUsername) {
3233
3291
  }
3234
3292
  return response.json();
3235
3293
  },
3236
- enabled: !!activeUsername,
3294
+ enabled: !!activeUsername && !!code,
3237
3295
  refetchOnMount: false,
3238
3296
  initialData: () => {
3239
3297
  const wasMutedPreviously = typeof window !== "undefined" ? localStorage.getItem("notifications") !== "true" : false;
@@ -3527,8 +3585,9 @@ function getMarketDataQueryOptions(coin, vsCurrency, fromTs, toTs) {
3527
3585
  return queryOptions({
3528
3586
  queryKey: ["market", "data", coin, vsCurrency, fromTs, toTs],
3529
3587
  queryFn: async ({ signal }) => {
3588
+ const fetchApi = getBoundFetch();
3530
3589
  const url = `https://api.coingecko.com/api/v3/coins/${coin}/market_chart/range?vs_currency=${vsCurrency}&from=${fromTs}&to=${toTs}`;
3531
- const response = await fetch(url, { signal });
3590
+ const response = await fetchApi(url, { signal });
3532
3591
  if (!response.ok) {
3533
3592
  throw new Error(`Failed to fetch market data: ${response.status}`);
3534
3593
  }
@@ -3536,6 +3595,46 @@ function getMarketDataQueryOptions(coin, vsCurrency, fromTs, toTs) {
3536
3595
  }
3537
3596
  });
3538
3597
  }
3598
+
3599
+ // src/modules/market/requests.ts
3600
+ async function parseJsonResponse(response) {
3601
+ const data = await response.json();
3602
+ if (!response.ok) {
3603
+ const error = new Error(`Request failed with status ${response.status}`);
3604
+ error.status = response.status;
3605
+ error.data = data;
3606
+ throw error;
3607
+ }
3608
+ return data;
3609
+ }
3610
+ async function getMarketData(coin, vsCurrency, fromTs, toTs) {
3611
+ const fetchApi = getBoundFetch();
3612
+ const url = `https://api.coingecko.com/api/v3/coins/${coin}/market_chart/range?vs_currency=${vsCurrency}&from=${fromTs}&to=${toTs}`;
3613
+ const response = await fetchApi(url);
3614
+ return parseJsonResponse(response);
3615
+ }
3616
+ async function getCurrencyRate(cur) {
3617
+ if (cur === "hbd") {
3618
+ return 1;
3619
+ }
3620
+ const fetchApi = getBoundFetch();
3621
+ const url = `https://api.coingecko.com/api/v3/simple/price?ids=hive_dollar&vs_currencies=${cur}`;
3622
+ const response = await fetchApi(url);
3623
+ const data = await parseJsonResponse(response);
3624
+ return data.hive_dollar[cur];
3625
+ }
3626
+ async function getCurrencyTokenRate(currency, token) {
3627
+ const fetchApi = getBoundFetch();
3628
+ const response = await fetchApi(
3629
+ CONFIG.privateApiHost + `/private-api/market-data/${currency === "hbd" ? "usd" : currency}/${token}`
3630
+ );
3631
+ return parseJsonResponse(response);
3632
+ }
3633
+ async function getCurrencyRates() {
3634
+ const fetchApi = getBoundFetch();
3635
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/market-data/latest");
3636
+ return parseJsonResponse(response);
3637
+ }
3539
3638
  function getPointsQueryOptions(username, filter = 0) {
3540
3639
  return queryOptions({
3541
3640
  queryKey: ["points", username, filter],
@@ -3876,6 +3975,311 @@ function getBoostPlusAccountPricesQueryOptions(account, accessToken) {
3876
3975
  });
3877
3976
  }
3878
3977
 
3879
- export { ACCOUNT_OPERATION_GROUPS, ALL_ACCOUNT_OPERATIONS, ALL_NOTIFY_TYPES, CONFIG, ConfigManager, mutations_exports as EcencyAnalytics, EcencyQueriesManager, HiveSignerIntegration, keychain_exports as Keychain, NaiMap, NotificationFilter, NotificationViewType, NotifyTypes, ROLES, SortOrder, Symbol2 as Symbol, ThreeSpeakIntegration, broadcastJson, buildProfileMetadata, checkUsernameWalletsPendingQueryOptions, decodeObj, dedupeAndSortKeyAuths, encodeObj, extractAccountProfile, getAccessToken, getAccountFullQueryOptions, getAccountNotificationsInfiniteQueryOptions, getAccountPendingRecoveryQueryOptions, getAccountPostsInfiniteQueryOptions, getAccountRcQueryOptions, getAccountRecoveriesQueryOptions, getAccountSubscriptionsQueryOptions, getAccountVoteHistoryInfiniteQueryOptions, getAccountsQueryOptions, getActiveAccountBookmarksQueryOptions, getActiveAccountFavouritesQueryOptions, getAnnouncementsQueryOptions, getBoostPlusAccountPricesQueryOptions, getBoostPlusPricesQueryOptions, getBotsQueryOptions, getBoundFetch, getChainPropertiesQueryOptions, getCollateralizedConversionRequestsQueryOptions, getCommentHistoryQueryOptions, getCommunitiesQueryOptions, getCommunityContextQueryOptions, getCommunityPermissions, getCommunitySubscribersQueryOptions, getCommunityType, getControversialRisingInfiniteQueryOptions, getConversionRequestsQueryOptions, getDeletedEntryQueryOptions, getDiscoverCurationQueryOptions, getDiscoverLeaderboardQueryOptions, getDiscussionsQueryOptions, getDraftsQueryOptions, getDynamicPropsQueryOptions, getEntryActiveVotesQueryOptions, getFollowCountQueryOptions, getFollowingQueryOptions, getFragmentsQueryOptions, getFriendsInfiniteQueryOptions, getGalleryImagesQueryOptions, getGameStatusCheckQueryOptions, getHiveHbdStatsQueryOptions, getHivePoshLinksQueryOptions, getImagesQueryOptions, getLoginType, getMarketDataQueryOptions, getMarketHistoryQueryOptions, getMarketStatisticsQueryOptions, getMutedUsersQueryOptions, getNotificationsInfiniteQueryOptions, getNotificationsSettingsQueryOptions, getNotificationsUnreadCountQueryOptions, getOpenOrdersQueryOptions, getOrderBookQueryOptions, getOutgoingRcDelegationsInfiniteQueryOptions, getPageStatsQueryOptions, getPointsQueryOptions, getPostHeaderQueryOptions, getPostQueryOptions, getPostTipsQueryOptions, getPostingKey, getPostsRankedInfiniteQueryOptions, getPromotePriceQueryOptions, getPromotedPostsQuery, getProposalQueryOptions, getProposalVotesInfiniteQueryOptions, getProposalsQueryOptions, getQueryClient, getRcStatsQueryOptions, getReblogsQueryOptions, getReceivedVestingSharesQueryOptions, getReferralsInfiniteQueryOptions, getReferralsStatsQueryOptions, getRefreshToken, getRelationshipBetweenAccountsQueryOptions, getRewardedCommunitiesQueryOptions, getSavingsWithdrawFromQueryOptions, getSchedulesQueryOptions, getSearchAccountQueryOptions, getSearchAccountsByUsernameQueryOptions, getSearchApiInfiniteQueryOptions, getSearchFriendsQueryOptions, getSearchPathQueryOptions, getSearchTopicsQueryOptions, getSimilarEntriesQueryOptions, getStatsQueryOptions, getTransactionsInfiniteQueryOptions, getTrendingTagsQueryOptions, getUser, getUserProposalVotesQueryOptions, getVestingDelegationsQueryOptions, getVisibleFirstLevelThreadItems, getWavesByHostQueryOptions, getWavesByTagQueryOptions, getWavesFollowingQueryOptions, getWavesTrendingTagsQueryOptions, getWithdrawRoutesQueryOptions, getWitnessesInfiniteQueryOptions, lookupAccountsQueryOptions, makeQueryClient, mapThreadItemsToWaveEntries, normalizeWaveEntryFromApi, parseAccounts, parseAsset, parseProfileMetadata, roleMap, searchQueryOptions, sortDiscussions, toEntryArray, useAccountFavouriteAdd, useAccountFavouriteDelete, useAccountRelationsUpdate, useAccountRevokeKey, useAccountRevokePosting, useAccountUpdate, useAccountUpdateKeyAuths, useAccountUpdatePassword, useAccountUpdateRecovery, useAddFragment, useBookmarkAdd, useBookmarkDelete, useBroadcastMutation, useEditFragment, useGameClaim, useRecordActivity, useRemoveFragment, useSignOperationByHivesigner, useSignOperationByKey, useSignOperationByKeychain };
3978
+ // src/modules/private-api/requests.ts
3979
+ async function parseJsonResponse2(response) {
3980
+ if (!response.ok) {
3981
+ let errorData = void 0;
3982
+ try {
3983
+ errorData = await response.json();
3984
+ } catch {
3985
+ errorData = void 0;
3986
+ }
3987
+ const error = new Error(`Request failed with status ${response.status}`);
3988
+ error.status = response.status;
3989
+ error.data = errorData;
3990
+ throw error;
3991
+ }
3992
+ return await response.json();
3993
+ }
3994
+ async function signUp(username, email, referral) {
3995
+ const fetchApi = getBoundFetch();
3996
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/account-create", {
3997
+ method: "POST",
3998
+ headers: {
3999
+ "Content-Type": "application/json"
4000
+ },
4001
+ body: JSON.stringify({ username, email, referral })
4002
+ });
4003
+ const data = await parseJsonResponse2(response);
4004
+ return { status: response.status, data };
4005
+ }
4006
+ async function subscribeEmail(email) {
4007
+ const fetchApi = getBoundFetch();
4008
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/subscribe", {
4009
+ method: "POST",
4010
+ headers: {
4011
+ "Content-Type": "application/json"
4012
+ },
4013
+ body: JSON.stringify({ email })
4014
+ });
4015
+ const data = await parseJsonResponse2(response);
4016
+ return { status: response.status, data };
4017
+ }
4018
+ async function usrActivity(code, ty, bl = "", tx = "") {
4019
+ const params = { code, ty };
4020
+ if (bl) {
4021
+ params.bl = bl;
4022
+ }
4023
+ if (tx) {
4024
+ params.tx = tx;
4025
+ }
4026
+ const fetchApi = getBoundFetch();
4027
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/usr-activity", {
4028
+ method: "POST",
4029
+ headers: {
4030
+ "Content-Type": "application/json"
4031
+ },
4032
+ body: JSON.stringify(params)
4033
+ });
4034
+ await parseJsonResponse2(response);
4035
+ }
4036
+ async function getNotifications(code, filter, since = null, user = null) {
4037
+ const data = {
4038
+ code
4039
+ };
4040
+ if (filter) {
4041
+ data.filter = filter;
4042
+ }
4043
+ if (since) {
4044
+ data.since = since;
4045
+ }
4046
+ if (user) {
4047
+ data.user = user;
4048
+ }
4049
+ const fetchApi = getBoundFetch();
4050
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/notifications", {
4051
+ method: "POST",
4052
+ headers: {
4053
+ "Content-Type": "application/json"
4054
+ },
4055
+ body: JSON.stringify(data)
4056
+ });
4057
+ return parseJsonResponse2(response);
4058
+ }
4059
+ async function saveNotificationSetting(code, username, system, allows_notify, notify_types, token) {
4060
+ const data = {
4061
+ code,
4062
+ username,
4063
+ token,
4064
+ system,
4065
+ allows_notify,
4066
+ notify_types
4067
+ };
4068
+ const fetchApi = getBoundFetch();
4069
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/register-device", {
4070
+ method: "POST",
4071
+ headers: {
4072
+ "Content-Type": "application/json"
4073
+ },
4074
+ body: JSON.stringify(data)
4075
+ });
4076
+ return parseJsonResponse2(response);
4077
+ }
4078
+ async function getNotificationSetting(code, username, token) {
4079
+ const data = { code, username, token };
4080
+ const fetchApi = getBoundFetch();
4081
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/detail-device", {
4082
+ method: "POST",
4083
+ headers: {
4084
+ "Content-Type": "application/json"
4085
+ },
4086
+ body: JSON.stringify(data)
4087
+ });
4088
+ return parseJsonResponse2(response);
4089
+ }
4090
+ async function markNotifications(code, id) {
4091
+ const data = {
4092
+ code
4093
+ };
4094
+ if (id) {
4095
+ data.id = id;
4096
+ }
4097
+ const fetchApi = getBoundFetch();
4098
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/notifications/mark", {
4099
+ method: "POST",
4100
+ headers: {
4101
+ "Content-Type": "application/json"
4102
+ },
4103
+ body: JSON.stringify(data)
4104
+ });
4105
+ return parseJsonResponse2(response);
4106
+ }
4107
+ async function addImage(code, url) {
4108
+ const data = { code, url };
4109
+ const fetchApi = getBoundFetch();
4110
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/images-add", {
4111
+ method: "POST",
4112
+ headers: {
4113
+ "Content-Type": "application/json"
4114
+ },
4115
+ body: JSON.stringify(data)
4116
+ });
4117
+ return parseJsonResponse2(response);
4118
+ }
4119
+ async function uploadImage(file, token, signal) {
4120
+ const fetchApi = getBoundFetch();
4121
+ const formData = new FormData();
4122
+ formData.append("file", file);
4123
+ const response = await fetchApi(`${CONFIG.imageHost}/hs/${token}`, {
4124
+ method: "POST",
4125
+ body: formData,
4126
+ signal
4127
+ });
4128
+ return parseJsonResponse2(response);
4129
+ }
4130
+ async function deleteImage(code, imageId) {
4131
+ const data = { code, id: imageId };
4132
+ const fetchApi = getBoundFetch();
4133
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/images-delete", {
4134
+ method: "POST",
4135
+ headers: {
4136
+ "Content-Type": "application/json"
4137
+ },
4138
+ body: JSON.stringify(data)
4139
+ });
4140
+ return parseJsonResponse2(response);
4141
+ }
4142
+ async function addDraft(code, title, body, tags, meta) {
4143
+ const data = { code, title, body, tags, meta };
4144
+ const fetchApi = getBoundFetch();
4145
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/drafts-add", {
4146
+ method: "POST",
4147
+ headers: {
4148
+ "Content-Type": "application/json"
4149
+ },
4150
+ body: JSON.stringify(data)
4151
+ });
4152
+ return parseJsonResponse2(response);
4153
+ }
4154
+ async function updateDraft(code, draftId, title, body, tags, meta) {
4155
+ const data = { code, id: draftId, title, body, tags, meta };
4156
+ const fetchApi = getBoundFetch();
4157
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/drafts-update", {
4158
+ method: "POST",
4159
+ headers: {
4160
+ "Content-Type": "application/json"
4161
+ },
4162
+ body: JSON.stringify(data)
4163
+ });
4164
+ return parseJsonResponse2(response);
4165
+ }
4166
+ async function deleteDraft(code, draftId) {
4167
+ const data = { code, id: draftId };
4168
+ const fetchApi = getBoundFetch();
4169
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/drafts-delete", {
4170
+ method: "POST",
4171
+ headers: {
4172
+ "Content-Type": "application/json"
4173
+ },
4174
+ body: JSON.stringify(data)
4175
+ });
4176
+ return parseJsonResponse2(response);
4177
+ }
4178
+ async function addSchedule(code, permlink, title, body, meta, options, schedule, reblog) {
4179
+ const data = {
4180
+ code,
4181
+ permlink,
4182
+ title,
4183
+ body,
4184
+ meta,
4185
+ schedule,
4186
+ reblog
4187
+ };
4188
+ if (options) {
4189
+ data.options = options;
4190
+ }
4191
+ const fetchApi = getBoundFetch();
4192
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/schedules-add", {
4193
+ method: "POST",
4194
+ headers: {
4195
+ "Content-Type": "application/json"
4196
+ },
4197
+ body: JSON.stringify(data)
4198
+ });
4199
+ return parseJsonResponse2(response);
4200
+ }
4201
+ async function deleteSchedule(code, id) {
4202
+ const data = { code, id };
4203
+ const fetchApi = getBoundFetch();
4204
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/schedules-delete", {
4205
+ method: "POST",
4206
+ headers: {
4207
+ "Content-Type": "application/json"
4208
+ },
4209
+ body: JSON.stringify(data)
4210
+ });
4211
+ return parseJsonResponse2(response);
4212
+ }
4213
+ async function moveSchedule(code, id) {
4214
+ const data = { code, id };
4215
+ const fetchApi = getBoundFetch();
4216
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/schedules-move", {
4217
+ method: "POST",
4218
+ headers: {
4219
+ "Content-Type": "application/json"
4220
+ },
4221
+ body: JSON.stringify(data)
4222
+ });
4223
+ return parseJsonResponse2(response);
4224
+ }
4225
+ async function getPromotedPost(code, author, permlink) {
4226
+ const data = { code, author, permlink };
4227
+ const fetchApi = getBoundFetch();
4228
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/promoted-post", {
4229
+ method: "POST",
4230
+ headers: {
4231
+ "Content-Type": "application/json"
4232
+ },
4233
+ body: JSON.stringify(data)
4234
+ });
4235
+ return parseJsonResponse2(response);
4236
+ }
4237
+ async function onboardEmail(username, email, friend) {
4238
+ const dataBody = {
4239
+ username,
4240
+ email,
4241
+ friend
4242
+ };
4243
+ const fetchApi = getBoundFetch();
4244
+ const response = await fetchApi(
4245
+ CONFIG.privateApiHost + "/private-api/account-create-friend",
4246
+ {
4247
+ method: "POST",
4248
+ headers: {
4249
+ "Content-Type": "application/json"
4250
+ },
4251
+ body: JSON.stringify(dataBody)
4252
+ }
4253
+ );
4254
+ return parseJsonResponse2(response);
4255
+ }
4256
+
4257
+ // src/modules/auth/requests.ts
4258
+ async function hsTokenRenew(code) {
4259
+ const fetchApi = getBoundFetch();
4260
+ const response = await fetchApi(CONFIG.privateApiHost + "/auth-api/hs-token-refresh", {
4261
+ method: "POST",
4262
+ headers: {
4263
+ "Content-Type": "application/json"
4264
+ },
4265
+ body: JSON.stringify({ code })
4266
+ });
4267
+ if (!response.ok) {
4268
+ let data2 = void 0;
4269
+ try {
4270
+ data2 = await response.json();
4271
+ } catch {
4272
+ data2 = void 0;
4273
+ }
4274
+ const error = new Error(`Failed to refresh token: ${response.status}`);
4275
+ error.status = response.status;
4276
+ error.data = data2;
4277
+ throw error;
4278
+ }
4279
+ const data = await response.json();
4280
+ return data;
4281
+ }
4282
+
4283
+ export { ACCOUNT_OPERATION_GROUPS, ALL_ACCOUNT_OPERATIONS, ALL_NOTIFY_TYPES, CONFIG, ConfigManager, mutations_exports as EcencyAnalytics, EcencyQueriesManager, HiveSignerIntegration, keychain_exports as Keychain, NaiMap, NotificationFilter, NotificationViewType, NotifyTypes, ROLES, SortOrder, Symbol2 as Symbol, ThreeSpeakIntegration, addDraft, addImage, addSchedule, broadcastJson, buildProfileMetadata, checkUsernameWalletsPendingQueryOptions, decodeObj, dedupeAndSortKeyAuths, deleteDraft, deleteImage, deleteSchedule, encodeObj, extractAccountProfile, getAccessToken, getAccountFullQueryOptions, getAccountNotificationsInfiniteQueryOptions, getAccountPendingRecoveryQueryOptions, getAccountPostsInfiniteQueryOptions, getAccountRcQueryOptions, getAccountRecoveriesQueryOptions, getAccountSubscriptionsQueryOptions, getAccountVoteHistoryInfiniteQueryOptions, getAccountsQueryOptions, getActiveAccountBookmarksQueryOptions, getActiveAccountFavouritesQueryOptions, getAnnouncementsQueryOptions, getBoostPlusAccountPricesQueryOptions, getBoostPlusPricesQueryOptions, getBotsQueryOptions, getBoundFetch, getChainPropertiesQueryOptions, getCollateralizedConversionRequestsQueryOptions, getCommentHistoryQueryOptions, getCommunitiesQueryOptions, getCommunityContextQueryOptions, getCommunityPermissions, getCommunitySubscribersQueryOptions, getCommunityType, getControversialRisingInfiniteQueryOptions, getConversionRequestsQueryOptions, getCurrencyRate, getCurrencyRates, getCurrencyTokenRate, getDeletedEntryQueryOptions, getDiscoverCurationQueryOptions, getDiscoverLeaderboardQueryOptions, getDiscussionsQueryOptions, getDraftsQueryOptions, getDynamicPropsQueryOptions, getEntryActiveVotesQueryOptions, getFollowCountQueryOptions, getFollowingQueryOptions, getFragmentsQueryOptions, getFriendsInfiniteQueryOptions, getGalleryImagesQueryOptions, getGameStatusCheckQueryOptions, getHiveHbdStatsQueryOptions, getHivePoshLinksQueryOptions, getImagesQueryOptions, getLoginType, getMarketData, getMarketDataQueryOptions, getMarketHistoryQueryOptions, getMarketStatisticsQueryOptions, getMutedUsersQueryOptions, getNotificationSetting, getNotifications, getNotificationsInfiniteQueryOptions, getNotificationsSettingsQueryOptions, getNotificationsUnreadCountQueryOptions, getOpenOrdersQueryOptions, getOrderBookQueryOptions, getOutgoingRcDelegationsInfiniteQueryOptions, getPageStatsQueryOptions, getPointsQueryOptions, getPostHeaderQueryOptions, getPostQueryOptions, getPostTipsQueryOptions, getPostingKey, getPostsRankedInfiniteQueryOptions, getPromotePriceQueryOptions, getPromotedPost, getPromotedPostsQuery, getProposalQueryOptions, getProposalVotesInfiniteQueryOptions, getProposalsQueryOptions, getQueryClient, getRcStatsQueryOptions, getReblogsQueryOptions, getReceivedVestingSharesQueryOptions, getReferralsInfiniteQueryOptions, getReferralsStatsQueryOptions, getRefreshToken, getRelationshipBetweenAccountsQueryOptions, getRewardedCommunitiesQueryOptions, getSavingsWithdrawFromQueryOptions, getSchedulesQueryOptions, getSearchAccountQueryOptions, getSearchAccountsByUsernameQueryOptions, getSearchApiInfiniteQueryOptions, getSearchFriendsQueryOptions, getSearchPathQueryOptions, getSearchTopicsQueryOptions, getSimilarEntriesQueryOptions, getStatsQueryOptions, getTransactionsInfiniteQueryOptions, getTrendingTagsQueryOptions, getTrendingTagsWithStatsQueryOptions, getUser, getUserProposalVotesQueryOptions, getVestingDelegationsQueryOptions, getVisibleFirstLevelThreadItems, getWavesByHostQueryOptions, getWavesByTagQueryOptions, getWavesFollowingQueryOptions, getWavesTrendingTagsQueryOptions, getWithdrawRoutesQueryOptions, getWitnessesInfiniteQueryOptions, hsTokenRenew, isCommunity, lookupAccountsQueryOptions, makeQueryClient, mapThreadItemsToWaveEntries, markNotifications, moveSchedule, normalizeWaveEntryFromApi, onboardEmail, parseAccounts, parseAsset, parseProfileMetadata, roleMap, saveNotificationSetting, searchQueryOptions, signUp, sortDiscussions, subscribeEmail, toEntryArray, updateDraft, uploadImage, useAccountFavouriteAdd, useAccountFavouriteDelete, useAccountRelationsUpdate, useAccountRevokeKey, useAccountRevokePosting, useAccountUpdate, useAccountUpdateKeyAuths, useAccountUpdatePassword, useAccountUpdateRecovery, useAddFragment, useBookmarkAdd, useBookmarkDelete, useBroadcastMutation, useEditFragment, useGameClaim, useRecordActivity, useRemoveFragment, useSignOperationByHivesigner, useSignOperationByKey, useSignOperationByKeychain, usrActivity };
3880
4284
  //# sourceMappingURL=index.mjs.map
3881
4285
  //# sourceMappingURL=index.mjs.map