@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.
@@ -11,6 +11,107 @@ var __export = (target, all) => {
11
11
  };
12
12
  var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
13
13
 
14
+ // src/modules/keychain/keychain.ts
15
+ var keychain_exports = {};
16
+ __export(keychain_exports, {
17
+ broadcast: () => broadcast,
18
+ customJson: () => customJson,
19
+ handshake: () => handshake
20
+ });
21
+ function handshake() {
22
+ return new Promise((resolve) => {
23
+ window.hive_keychain?.requestHandshake(() => {
24
+ resolve();
25
+ });
26
+ });
27
+ }
28
+ var broadcast = (account, operations, key, rpc = null) => new Promise((resolve, reject) => {
29
+ window.hive_keychain?.requestBroadcast(
30
+ account,
31
+ operations,
32
+ key,
33
+ (resp) => {
34
+ if (!resp.success) {
35
+ reject({ message: "Operation cancelled" });
36
+ }
37
+ resolve(resp);
38
+ },
39
+ rpc
40
+ );
41
+ });
42
+ var customJson = (account, id, key, json, display_msg, rpc = null) => new Promise((resolve, reject) => {
43
+ window.hive_keychain?.requestCustomJson(
44
+ account,
45
+ id,
46
+ key,
47
+ json,
48
+ display_msg,
49
+ (resp) => {
50
+ if (!resp.success) {
51
+ reject({ message: "Operation cancelled" });
52
+ }
53
+ resolve(resp);
54
+ },
55
+ rpc
56
+ );
57
+ });
58
+
59
+ // src/modules/core/mutations/use-broadcast-mutation.ts
60
+ function useBroadcastMutation(mutationKey = [], username, accessToken, operations, onSuccess = () => {
61
+ }, auth) {
62
+ return useMutation({
63
+ onSuccess,
64
+ mutationKey: [...mutationKey, username],
65
+ mutationFn: async (payload) => {
66
+ if (!username) {
67
+ throw new Error(
68
+ "[Core][Broadcast] Attempted to call broadcast API with anon user"
69
+ );
70
+ }
71
+ const postingKey = auth?.postingKey;
72
+ if (postingKey) {
73
+ const privateKey = PrivateKey.fromString(postingKey);
74
+ return CONFIG.hiveClient.broadcast.sendOperations(
75
+ operations(payload),
76
+ privateKey
77
+ );
78
+ }
79
+ const loginType = auth?.loginType;
80
+ if (loginType && loginType == "keychain") {
81
+ return keychain_exports.broadcast(
82
+ username,
83
+ operations(payload),
84
+ "Posting"
85
+ ).then((r) => r.result);
86
+ }
87
+ if (accessToken) {
88
+ const f = getBoundFetch();
89
+ const res = await f("https://hivesigner.com/api/broadcast", {
90
+ method: "POST",
91
+ headers: {
92
+ Authorization: accessToken,
93
+ "Content-Type": "application/json",
94
+ Accept: "application/json"
95
+ },
96
+ body: JSON.stringify({ operations: operations(payload) })
97
+ });
98
+ if (!res.ok) {
99
+ const txt = await res.text().catch(() => "");
100
+ throw new Error(`[Hivesigner] ${res.status} ${res.statusText} ${txt}`);
101
+ }
102
+ const json = await res.json();
103
+ if (json?.errors) {
104
+ throw new Error(`[Hivesigner] ${JSON.stringify(json.errors)}`);
105
+ }
106
+ return json.result;
107
+ }
108
+ throw new Error(
109
+ "[SDK][Broadcast] \u2013 cannot broadcast w/o posting key or token"
110
+ );
111
+ }
112
+ });
113
+ }
114
+
14
115
  // src/modules/core/mock-storage.ts
15
116
  var MockStorage = class {
16
117
  constructor() {
@@ -34,6 +135,7 @@ var MockStorage = class {
34
135
  };
35
136
  var CONFIG = {
36
137
  privateApiHost: "https://ecency.com",
138
+ imageHost: "https://images.ecency.com",
37
139
  storage: typeof window === "undefined" ? new MockStorage() : window.localStorage,
38
140
  storagePrefix: "ecency",
39
141
  hiveClient: new Client(
@@ -80,6 +182,10 @@ var ConfigManager;
80
182
  CONFIG.privateApiHost = host;
81
183
  }
82
184
  ConfigManager2.setPrivateApiHost = setPrivateApiHost;
185
+ function setImageHost(host) {
186
+ CONFIG.imageHost = host;
187
+ }
188
+ ConfigManager2.setImageHost = setImageHost;
83
189
  function analyzeRedosRisk(pattern) {
84
190
  if (/(\([^)]*[*+{][^)]*\))[*+{]/.test(pattern)) {
85
191
  return { safe: false, reason: "nested quantifiers detected" };
@@ -186,6 +292,40 @@ var ConfigManager;
186
292
  }
187
293
  ConfigManager2.setDmcaLists = setDmcaLists;
188
294
  })(ConfigManager || (ConfigManager = {}));
295
+ async function broadcastJson(username, id, payload, accessToken, auth) {
296
+ if (!username) {
297
+ throw new Error(
298
+ "[Core][Broadcast] Attempted to call broadcast API with anon user"
299
+ );
300
+ }
301
+ const jjson = {
302
+ id,
303
+ required_auths: [],
304
+ required_posting_auths: [username],
305
+ json: JSON.stringify(payload)
306
+ };
307
+ const postingKey = auth?.postingKey;
308
+ if (postingKey) {
309
+ const privateKey = PrivateKey.fromString(postingKey);
310
+ return CONFIG.hiveClient.broadcast.json(
311
+ jjson,
312
+ privateKey
313
+ );
314
+ }
315
+ const loginType = auth?.loginType;
316
+ if (loginType && loginType == "keychain") {
317
+ return keychain_exports.broadcast(username, [["custom_json", jjson]], "Posting").then((r) => r.result);
318
+ }
319
+ if (accessToken) {
320
+ const response = await new hs.Client({
321
+ accessToken
322
+ }).customJson([], [username], id, JSON.stringify(payload));
323
+ return response.result;
324
+ }
325
+ throw new Error(
326
+ "[SDK][Broadcast] \u2013 cannot broadcast w/o posting key or token"
327
+ );
328
+ }
189
329
 
190
330
  // src/modules/core/utils/decoder-encoder.ts
191
331
  function encodeObj(o) {
@@ -242,6 +382,11 @@ function getBoundFetch() {
242
382
  return cachedFetch;
243
383
  }
244
384
 
385
+ // src/modules/core/utils/is-community.ts
386
+ function isCommunity(value) {
387
+ return typeof value === "string" ? /^hive-\d+$/.test(value) : false;
388
+ }
389
+
245
390
  // src/modules/core/storage.ts
246
391
  var getUser = (username) => {
247
392
  try {
@@ -258,143 +403,6 @@ var getAccessToken = (username) => getUser(username) && getUser(username).access
258
403
  var getPostingKey = (username) => getUser(username) && getUser(username).postingKey;
259
404
  var getLoginType = (username) => getUser(username) && getUser(username).loginType;
260
405
  var getRefreshToken = (username) => getUser(username) && getUser(username).refreshToken;
261
-
262
- // src/modules/keychain/keychain.ts
263
- var keychain_exports = {};
264
- __export(keychain_exports, {
265
- broadcast: () => broadcast,
266
- customJson: () => customJson,
267
- handshake: () => handshake
268
- });
269
- function handshake() {
270
- return new Promise((resolve) => {
271
- window.hive_keychain?.requestHandshake(() => {
272
- resolve();
273
- });
274
- });
275
- }
276
- var broadcast = (account, operations, key, rpc = null) => new Promise((resolve, reject) => {
277
- window.hive_keychain?.requestBroadcast(
278
- account,
279
- operations,
280
- key,
281
- (resp) => {
282
- if (!resp.success) {
283
- reject({ message: "Operation cancelled" });
284
- }
285
- resolve(resp);
286
- },
287
- rpc
288
- );
289
- });
290
- var customJson = (account, id, key, json, display_msg, rpc = null) => new Promise((resolve, reject) => {
291
- window.hive_keychain?.requestCustomJson(
292
- account,
293
- id,
294
- key,
295
- json,
296
- display_msg,
297
- (resp) => {
298
- if (!resp.success) {
299
- reject({ message: "Operation cancelled" });
300
- }
301
- resolve(resp);
302
- },
303
- rpc
304
- );
305
- });
306
-
307
- // src/modules/core/mutations/use-broadcast-mutation.ts
308
- function useBroadcastMutation(mutationKey = [], username, operations, onSuccess = () => {
309
- }) {
310
- return useMutation({
311
- onSuccess,
312
- mutationKey: [...mutationKey, username],
313
- mutationFn: async (payload) => {
314
- if (!username) {
315
- throw new Error(
316
- "[Core][Broadcast] Attempted to call broadcast API with anon user"
317
- );
318
- }
319
- const postingKey = getPostingKey(username);
320
- if (postingKey) {
321
- const privateKey = PrivateKey.fromString(postingKey);
322
- return CONFIG.hiveClient.broadcast.sendOperations(
323
- operations(payload),
324
- privateKey
325
- );
326
- }
327
- const loginType = getLoginType(username);
328
- if (loginType && loginType == "keychain") {
329
- return keychain_exports.broadcast(
330
- username,
331
- operations(payload),
332
- "Posting"
333
- ).then((r) => r.result);
334
- }
335
- let token = getAccessToken(username);
336
- if (token) {
337
- const f = getBoundFetch();
338
- const res = await f("https://hivesigner.com/api/broadcast", {
339
- method: "POST",
340
- headers: {
341
- Authorization: token,
342
- "Content-Type": "application/json",
343
- Accept: "application/json"
344
- },
345
- body: JSON.stringify({ operations: operations(payload) })
346
- });
347
- if (!res.ok) {
348
- const txt = await res.text().catch(() => "");
349
- throw new Error(`[Hivesigner] ${res.status} ${res.statusText} ${txt}`);
350
- }
351
- const json = await res.json();
352
- if (json?.errors) {
353
- throw new Error(`[Hivesigner] ${JSON.stringify(json.errors)}`);
354
- }
355
- return json.result;
356
- }
357
- throw new Error(
358
- "[SDK][Broadcast] \u2013 cannot broadcast w/o posting key or token"
359
- );
360
- }
361
- });
362
- }
363
- async function broadcastJson(username, id, payload) {
364
- if (!username) {
365
- throw new Error(
366
- "[Core][Broadcast] Attempted to call broadcast API with anon user"
367
- );
368
- }
369
- const jjson = {
370
- id,
371
- required_auths: [],
372
- required_posting_auths: [username],
373
- json: JSON.stringify(payload)
374
- };
375
- const postingKey = getPostingKey(username);
376
- if (postingKey) {
377
- const privateKey = PrivateKey.fromString(postingKey);
378
- return CONFIG.hiveClient.broadcast.json(
379
- jjson,
380
- privateKey
381
- );
382
- }
383
- const loginType = getLoginType(username);
384
- if (loginType && loginType == "keychain") {
385
- return keychain_exports.broadcast(username, [["custom_json", jjson]], "Posting").then((r) => r.result);
386
- }
387
- let token = getAccessToken(username);
388
- if (token) {
389
- const response = await new hs.Client({
390
- accessToken: token
391
- }).customJson([], [username], id, JSON.stringify(payload));
392
- return response.result;
393
- }
394
- throw new Error(
395
- "[SDK][Broadcast] \u2013 cannot broadcast w/o posting key or token"
396
- );
397
- }
398
406
  function makeQueryClient() {
399
407
  return new QueryClient({
400
408
  defaultOptions: {
@@ -902,13 +910,13 @@ function getAccountSubscriptionsQueryOptions(username) {
902
910
  }
903
911
  });
904
912
  }
905
- function getActiveAccountBookmarksQueryOptions(activeUsername) {
913
+ function getActiveAccountBookmarksQueryOptions(activeUsername, code) {
906
914
  return queryOptions({
907
915
  queryKey: ["accounts", "bookmarks", activeUsername],
908
- enabled: !!activeUsername,
916
+ enabled: !!activeUsername && !!code,
909
917
  queryFn: async () => {
910
- if (!activeUsername) {
911
- throw new Error("[SDK][Accounts][Bookmarks] \u2013 no active user");
918
+ if (!activeUsername || !code) {
919
+ throw new Error("[SDK][Accounts][Bookmarks] \u2013 missing auth");
912
920
  }
913
921
  const fetchApi = getBoundFetch();
914
922
  const response = await fetchApi(
@@ -918,20 +926,20 @@ function getActiveAccountBookmarksQueryOptions(activeUsername) {
918
926
  headers: {
919
927
  "Content-Type": "application/json"
920
928
  },
921
- body: JSON.stringify({ code: getAccessToken(activeUsername) })
929
+ body: JSON.stringify({ code })
922
930
  }
923
931
  );
924
932
  return await response.json();
925
933
  }
926
934
  });
927
935
  }
928
- function getActiveAccountFavouritesQueryOptions(activeUsername) {
936
+ function getActiveAccountFavouritesQueryOptions(activeUsername, code) {
929
937
  return queryOptions({
930
938
  queryKey: ["accounts", "favourites", activeUsername],
931
- enabled: !!activeUsername,
939
+ enabled: !!activeUsername && !!code,
932
940
  queryFn: async () => {
933
- if (!activeUsername) {
934
- throw new Error("[SDK][Accounts][Favourites] \u2013 no active user");
941
+ if (!activeUsername || !code) {
942
+ throw new Error("[SDK][Accounts][Favourites] \u2013 missing auth");
935
943
  }
936
944
  const fetchApi = getBoundFetch();
937
945
  const response = await fetchApi(
@@ -941,18 +949,21 @@ function getActiveAccountFavouritesQueryOptions(activeUsername) {
941
949
  headers: {
942
950
  "Content-Type": "application/json"
943
951
  },
944
- body: JSON.stringify({ code: getAccessToken(activeUsername) })
952
+ body: JSON.stringify({ code })
945
953
  }
946
954
  );
947
955
  return await response.json();
948
956
  }
949
957
  });
950
958
  }
951
- function getAccountRecoveriesQueryOptions(username) {
959
+ function getAccountRecoveriesQueryOptions(username, code) {
952
960
  return queryOptions({
953
- enabled: !!username,
961
+ enabled: !!username && !!code,
954
962
  queryKey: ["accounts", "recoveries", username],
955
963
  queryFn: async () => {
964
+ if (!username || !code) {
965
+ throw new Error("[SDK][Accounts] Missing username or access token");
966
+ }
956
967
  const fetchApi = getBoundFetch();
957
968
  const response = await fetchApi(
958
969
  CONFIG.privateApiHost + "/private-api/recoveries",
@@ -961,7 +972,7 @@ function getAccountRecoveriesQueryOptions(username) {
961
972
  headers: {
962
973
  "Content-Type": "application/json"
963
974
  },
964
- body: JSON.stringify({ code: getAccessToken(username) })
975
+ body: JSON.stringify({ code })
965
976
  }
966
977
  );
967
978
  return response.json();
@@ -1224,17 +1235,32 @@ function getTrendingTagsQueryOptions(limit = 20) {
1224
1235
  refetchOnMount: true
1225
1236
  });
1226
1237
  }
1227
- function getFragmentsQueryOptions(username) {
1238
+ function getTrendingTagsWithStatsQueryOptions(limit = 250) {
1239
+ return infiniteQueryOptions({
1240
+ queryKey: ["posts", "trending-tags", "stats", limit],
1241
+ queryFn: async ({ pageParam: { afterTag } }) => CONFIG.hiveClient.database.call("get_trending_tags", [afterTag, limit]).then(
1242
+ (tags) => tags.filter((tag) => tag.name !== "").filter((tag) => !isCommunity(tag.name))
1243
+ ),
1244
+ initialPageParam: { afterTag: "" },
1245
+ getNextPageParam: (lastPage) => lastPage?.length ? { afterTag: lastPage[lastPage.length - 1].name } : void 0,
1246
+ staleTime: Infinity,
1247
+ refetchOnMount: true
1248
+ });
1249
+ }
1250
+ function getFragmentsQueryOptions(username, code) {
1228
1251
  return queryOptions({
1229
1252
  queryKey: ["posts", "fragments", username],
1230
1253
  queryFn: async () => {
1254
+ if (!code) {
1255
+ return [];
1256
+ }
1231
1257
  const fetchApi = getBoundFetch();
1232
1258
  const response = await fetchApi(
1233
1259
  CONFIG.privateApiHost + "/private-api/fragments",
1234
1260
  {
1235
1261
  method: "POST",
1236
1262
  body: JSON.stringify({
1237
- code: getAccessToken(username)
1263
+ code
1238
1264
  }),
1239
1265
  headers: {
1240
1266
  "Content-Type": "application/json"
@@ -1243,7 +1269,7 @@ function getFragmentsQueryOptions(username) {
1243
1269
  );
1244
1270
  return response.json();
1245
1271
  },
1246
- enabled: !!username
1272
+ enabled: !!username && !!code
1247
1273
  });
1248
1274
  }
1249
1275
  function getPromotedPostsQuery(type = "feed") {
@@ -1550,20 +1576,21 @@ function getReblogsQueryOptions(username, activeUsername, limit = 200) {
1550
1576
  enabled: !!username
1551
1577
  });
1552
1578
  }
1553
- function getSchedulesQueryOptions(activeUsername) {
1579
+ function getSchedulesQueryOptions(activeUsername, code) {
1554
1580
  return queryOptions({
1555
1581
  queryKey: ["posts", "schedules", activeUsername],
1556
1582
  queryFn: async () => {
1557
- if (!activeUsername) {
1583
+ if (!activeUsername || !code) {
1558
1584
  return [];
1559
1585
  }
1560
- const response = await fetch(CONFIG.privateApiHost + "/private-api/schedules", {
1586
+ const fetchApi = getBoundFetch();
1587
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/schedules", {
1561
1588
  method: "POST",
1562
1589
  headers: {
1563
1590
  "Content-Type": "application/json"
1564
1591
  },
1565
1592
  body: JSON.stringify({
1566
- code: getAccessToken(activeUsername)
1593
+ code
1567
1594
  })
1568
1595
  });
1569
1596
  if (!response.ok) {
@@ -1571,23 +1598,24 @@ function getSchedulesQueryOptions(activeUsername) {
1571
1598
  }
1572
1599
  return response.json();
1573
1600
  },
1574
- enabled: !!activeUsername
1601
+ enabled: !!activeUsername && !!code
1575
1602
  });
1576
1603
  }
1577
- function getDraftsQueryOptions(activeUsername) {
1604
+ function getDraftsQueryOptions(activeUsername, code) {
1578
1605
  return queryOptions({
1579
1606
  queryKey: ["posts", "drafts", activeUsername],
1580
1607
  queryFn: async () => {
1581
- if (!activeUsername) {
1608
+ if (!activeUsername || !code) {
1582
1609
  return [];
1583
1610
  }
1584
- const response = await fetch(CONFIG.privateApiHost + "/private-api/drafts", {
1611
+ const fetchApi = getBoundFetch();
1612
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/drafts", {
1585
1613
  method: "POST",
1586
1614
  headers: {
1587
1615
  "Content-Type": "application/json"
1588
1616
  },
1589
1617
  body: JSON.stringify({
1590
- code: getAccessToken(activeUsername)
1618
+ code
1591
1619
  })
1592
1620
  });
1593
1621
  if (!response.ok) {
@@ -1595,17 +1623,18 @@ function getDraftsQueryOptions(activeUsername) {
1595
1623
  }
1596
1624
  return response.json();
1597
1625
  },
1598
- enabled: !!activeUsername
1626
+ enabled: !!activeUsername && !!code
1599
1627
  });
1600
1628
  }
1601
- async function fetchUserImages(username) {
1602
- const response = await fetch(CONFIG.privateApiHost + "/private-api/images", {
1629
+ async function fetchUserImages(code) {
1630
+ const fetchApi = getBoundFetch();
1631
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/images", {
1603
1632
  method: "POST",
1604
1633
  headers: {
1605
1634
  "Content-Type": "application/json"
1606
1635
  },
1607
1636
  body: JSON.stringify({
1608
- code: getAccessToken(username)
1637
+ code
1609
1638
  })
1610
1639
  });
1611
1640
  if (!response.ok) {
@@ -1613,28 +1642,28 @@ async function fetchUserImages(username) {
1613
1642
  }
1614
1643
  return response.json();
1615
1644
  }
1616
- function getImagesQueryOptions(username) {
1645
+ function getImagesQueryOptions(username, code) {
1617
1646
  return queryOptions({
1618
1647
  queryKey: ["posts", "images", username],
1619
1648
  queryFn: async () => {
1620
- if (!username) {
1649
+ if (!username || !code) {
1621
1650
  return [];
1622
1651
  }
1623
- return fetchUserImages(username);
1652
+ return fetchUserImages(code);
1624
1653
  },
1625
- enabled: !!username
1654
+ enabled: !!username && !!code
1626
1655
  });
1627
1656
  }
1628
- function getGalleryImagesQueryOptions(activeUsername) {
1657
+ function getGalleryImagesQueryOptions(activeUsername, code) {
1629
1658
  return queryOptions({
1630
1659
  queryKey: ["posts", "gallery-images", activeUsername],
1631
1660
  queryFn: async () => {
1632
- if (!activeUsername) {
1661
+ if (!activeUsername || !code) {
1633
1662
  return [];
1634
1663
  }
1635
- return fetchUserImages(activeUsername);
1664
+ return fetchUserImages(code);
1636
1665
  },
1637
- enabled: !!activeUsername
1666
+ enabled: !!activeUsername && !!code
1638
1667
  });
1639
1668
  }
1640
1669
  function getCommentHistoryQueryOptions(author, permlink, onlyMeta = false) {
@@ -2030,12 +2059,13 @@ function getAccountVoteHistoryInfiniteQueryOptions(username, options) {
2030
2059
  }
2031
2060
 
2032
2061
  // src/modules/accounts/mutations/use-account-update.ts
2033
- function useAccountUpdate(username) {
2062
+ function useAccountUpdate(username, accessToken, auth) {
2034
2063
  const queryClient = useQueryClient();
2035
2064
  const { data } = useQuery(getAccountFullQueryOptions(username));
2036
2065
  return useBroadcastMutation(
2037
2066
  ["accounts", "update"],
2038
2067
  username,
2068
+ accessToken,
2039
2069
  (payload) => {
2040
2070
  if (!data) {
2041
2071
  throw new Error("[SDK][Accounts] \u2013 cannot update not existing account");
@@ -2059,7 +2089,7 @@ function useAccountUpdate(username) {
2059
2089
  ]
2060
2090
  ];
2061
2091
  },
2062
- (_, variables) => queryClient.setQueryData(
2092
+ (_data, variables) => queryClient.setQueryData(
2063
2093
  getAccountFullQueryOptions(username).queryKey,
2064
2094
  (data2) => {
2065
2095
  if (!data2) {
@@ -2073,7 +2103,8 @@ function useAccountUpdate(username) {
2073
2103
  });
2074
2104
  return obj;
2075
2105
  }
2076
- )
2106
+ ),
2107
+ auth
2077
2108
  );
2078
2109
  }
2079
2110
  function useAccountRelationsUpdate(reference, target, onSuccess, onError) {
@@ -2115,12 +2146,12 @@ function useAccountRelationsUpdate(reference, target, onSuccess, onError) {
2115
2146
  }
2116
2147
  });
2117
2148
  }
2118
- function useBookmarkAdd(username, onSuccess, onError) {
2149
+ function useBookmarkAdd(username, code, onSuccess, onError) {
2119
2150
  return useMutation({
2120
2151
  mutationKey: ["accounts", "bookmarks", "add", username],
2121
2152
  mutationFn: async ({ author, permlink }) => {
2122
- if (!username) {
2123
- throw new Error("[SDK][Account][Bookmarks] \u2013 no active user");
2153
+ if (!username || !code) {
2154
+ throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
2124
2155
  }
2125
2156
  const fetchApi = getBoundFetch();
2126
2157
  const response = await fetchApi(
@@ -2133,7 +2164,7 @@ function useBookmarkAdd(username, onSuccess, onError) {
2133
2164
  body: JSON.stringify({
2134
2165
  author,
2135
2166
  permlink,
2136
- code: getAccessToken(username)
2167
+ code
2137
2168
  })
2138
2169
  }
2139
2170
  );
@@ -2148,12 +2179,12 @@ function useBookmarkAdd(username, onSuccess, onError) {
2148
2179
  onError
2149
2180
  });
2150
2181
  }
2151
- function useBookmarkDelete(username, onSuccess, onError) {
2182
+ function useBookmarkDelete(username, code, onSuccess, onError) {
2152
2183
  return useMutation({
2153
2184
  mutationKey: ["accounts", "bookmarks", "delete", username],
2154
2185
  mutationFn: async (bookmarkId) => {
2155
- if (!username) {
2156
- throw new Error("[SDK][Account][Bookmarks] \u2013 no active user");
2186
+ if (!username || !code) {
2187
+ throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
2157
2188
  }
2158
2189
  const fetchApi = getBoundFetch();
2159
2190
  const response = await fetchApi(
@@ -2165,7 +2196,7 @@ function useBookmarkDelete(username, onSuccess, onError) {
2165
2196
  },
2166
2197
  body: JSON.stringify({
2167
2198
  id: bookmarkId,
2168
- code: getAccessToken(username)
2199
+ code
2169
2200
  })
2170
2201
  }
2171
2202
  );
@@ -2180,12 +2211,12 @@ function useBookmarkDelete(username, onSuccess, onError) {
2180
2211
  onError
2181
2212
  });
2182
2213
  }
2183
- function useAccountFavouriteAdd(username, onSuccess, onError) {
2214
+ function useAccountFavouriteAdd(username, code, onSuccess, onError) {
2184
2215
  return useMutation({
2185
2216
  mutationKey: ["accounts", "favourites", "add", username],
2186
2217
  mutationFn: async (account) => {
2187
- if (!username) {
2188
- throw new Error("[SDK][Account][Bookmarks] \u2013 no active user");
2218
+ if (!username || !code) {
2219
+ throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
2189
2220
  }
2190
2221
  const fetchApi = getBoundFetch();
2191
2222
  const response = await fetchApi(
@@ -2197,7 +2228,7 @@ function useAccountFavouriteAdd(username, onSuccess, onError) {
2197
2228
  },
2198
2229
  body: JSON.stringify({
2199
2230
  account,
2200
- code: getAccessToken(username)
2231
+ code
2201
2232
  })
2202
2233
  }
2203
2234
  );
@@ -2212,12 +2243,12 @@ function useAccountFavouriteAdd(username, onSuccess, onError) {
2212
2243
  onError
2213
2244
  });
2214
2245
  }
2215
- function useAccountFavouriteDelete(username, onSuccess, onError) {
2246
+ function useAccountFavouriteDelete(username, code, onSuccess, onError) {
2216
2247
  return useMutation({
2217
2248
  mutationKey: ["accounts", "favourites", "add", username],
2218
2249
  mutationFn: async (account) => {
2219
- if (!username) {
2220
- throw new Error("[SDK][Account][Bookmarks] \u2013 no active user");
2250
+ if (!username || !code) {
2251
+ throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
2221
2252
  }
2222
2253
  const fetchApi = getBoundFetch();
2223
2254
  const response = await fetchApi(
@@ -2229,7 +2260,7 @@ function useAccountFavouriteDelete(username, onSuccess, onError) {
2229
2260
  },
2230
2261
  body: JSON.stringify({
2231
2262
  account,
2232
- code: getAccessToken(username)
2263
+ code
2233
2264
  })
2234
2265
  }
2235
2266
  );
@@ -2387,7 +2418,7 @@ function useAccountRevokePosting(username, options) {
2387
2418
  }
2388
2419
  });
2389
2420
  }
2390
- function useAccountUpdateRecovery(username, options) {
2421
+ function useAccountUpdateRecovery(username, code, options) {
2391
2422
  const { data } = useQuery(getAccountFullQueryOptions(username));
2392
2423
  return useMutation({
2393
2424
  mutationKey: ["accounts", "recovery", data?.name],
@@ -2403,11 +2434,14 @@ function useAccountUpdateRecovery(username, options) {
2403
2434
  extensions: []
2404
2435
  };
2405
2436
  if (type === "ecency") {
2437
+ if (!code) {
2438
+ throw new Error("[SDK][Accounts] \u2013 missing access token");
2439
+ }
2406
2440
  const fetchApi = getBoundFetch();
2407
2441
  return fetchApi(CONFIG.privateApiHost + "/private-api/recoveries-add", {
2408
2442
  method: "POST",
2409
2443
  body: JSON.stringify({
2410
- code: getAccessToken(data.name),
2444
+ code,
2411
2445
  email,
2412
2446
  publicKeys: [
2413
2447
  ...data.owner.key_auths,
@@ -2531,17 +2565,20 @@ function getChainPropertiesQueryOptions() {
2531
2565
  }
2532
2566
  });
2533
2567
  }
2534
- function useAddFragment(username) {
2568
+ function useAddFragment(username, code) {
2535
2569
  return useMutation({
2536
2570
  mutationKey: ["posts", "add-fragment", username],
2537
2571
  mutationFn: async ({ title, body }) => {
2572
+ if (!code) {
2573
+ throw new Error("[SDK][Posts] Missing access token");
2574
+ }
2538
2575
  const fetchApi = getBoundFetch();
2539
2576
  const response = await fetchApi(
2540
2577
  CONFIG.privateApiHost + "/private-api/fragments-add",
2541
2578
  {
2542
2579
  method: "POST",
2543
2580
  body: JSON.stringify({
2544
- code: getAccessToken(username),
2581
+ code,
2545
2582
  title,
2546
2583
  body
2547
2584
  }),
@@ -2554,23 +2591,26 @@ function useAddFragment(username) {
2554
2591
  },
2555
2592
  onSuccess(response) {
2556
2593
  getQueryClient().setQueryData(
2557
- getFragmentsQueryOptions(username).queryKey,
2594
+ getFragmentsQueryOptions(username, code).queryKey,
2558
2595
  (data) => [response, ...data ?? []]
2559
2596
  );
2560
2597
  }
2561
2598
  });
2562
2599
  }
2563
- function useEditFragment(username, fragmentId) {
2600
+ function useEditFragment(username, fragmentId, code) {
2564
2601
  return useMutation({
2565
2602
  mutationKey: ["posts", "edit-fragment", username, fragmentId],
2566
2603
  mutationFn: async ({ title, body }) => {
2604
+ if (!code) {
2605
+ throw new Error("[SDK][Posts] Missing access token");
2606
+ }
2567
2607
  const fetchApi = getBoundFetch();
2568
2608
  const response = await fetchApi(
2569
2609
  CONFIG.privateApiHost + "/private-api/fragments-update",
2570
2610
  {
2571
2611
  method: "POST",
2572
2612
  body: JSON.stringify({
2573
- code: getAccessToken(username),
2613
+ code,
2574
2614
  id: fragmentId,
2575
2615
  title,
2576
2616
  body
@@ -2584,7 +2624,7 @@ function useEditFragment(username, fragmentId) {
2584
2624
  },
2585
2625
  onSuccess(response) {
2586
2626
  getQueryClient().setQueryData(
2587
- getFragmentsQueryOptions(username).queryKey,
2627
+ getFragmentsQueryOptions(username, code).queryKey,
2588
2628
  (data) => {
2589
2629
  if (!data) {
2590
2630
  return [];
@@ -2599,15 +2639,18 @@ function useEditFragment(username, fragmentId) {
2599
2639
  }
2600
2640
  });
2601
2641
  }
2602
- function useRemoveFragment(username, fragmentId) {
2642
+ function useRemoveFragment(username, fragmentId, code) {
2603
2643
  return useMutation({
2604
2644
  mutationKey: ["posts", "remove-fragment", username],
2605
2645
  mutationFn: async () => {
2646
+ if (!code) {
2647
+ throw new Error("[SDK][Posts] Missing access token");
2648
+ }
2606
2649
  const fetchApi = getBoundFetch();
2607
2650
  return fetchApi(CONFIG.privateApiHost + "/private-api/fragments-delete", {
2608
2651
  method: "POST",
2609
2652
  body: JSON.stringify({
2610
- code: getAccessToken(username),
2653
+ code,
2611
2654
  id: fragmentId
2612
2655
  }),
2613
2656
  headers: {
@@ -2617,7 +2660,7 @@ function useRemoveFragment(username, fragmentId) {
2617
2660
  },
2618
2661
  onSuccess() {
2619
2662
  getQueryClient().setQueryData(
2620
- getFragmentsQueryOptions(username).queryKey,
2663
+ getFragmentsQueryOptions(username, code).queryKey,
2621
2664
  (data) => [...data ?? []].filter(({ id }) => id !== fragmentId)
2622
2665
  );
2623
2666
  }
@@ -2736,11 +2779,10 @@ var queries_exports = {};
2736
2779
  __export(queries_exports, {
2737
2780
  getDecodeMemoQueryOptions: () => getDecodeMemoQueryOptions
2738
2781
  });
2739
- function getDecodeMemoQueryOptions(username, memo) {
2782
+ function getDecodeMemoQueryOptions(username, memo, accessToken) {
2740
2783
  return queryOptions({
2741
2784
  queryKey: ["integrations", "hivesigner", "decode-memo", username],
2742
2785
  queryFn: async () => {
2743
- const accessToken = getAccessToken(username);
2744
2786
  if (accessToken) {
2745
2787
  const hsClient = new hs.Client({
2746
2788
  accessToken
@@ -2757,12 +2799,12 @@ var HiveSignerIntegration = {
2757
2799
  };
2758
2800
 
2759
2801
  // src/modules/integrations/3speak/queries/get-account-token-query-options.ts
2760
- function getAccountTokenQueryOptions(username) {
2802
+ function getAccountTokenQueryOptions(username, accessToken) {
2761
2803
  return queryOptions({
2762
2804
  queryKey: ["integrations", "3speak", "authenticate", username],
2763
- enabled: !!username,
2805
+ enabled: !!username && !!accessToken,
2764
2806
  queryFn: async () => {
2765
- if (!username) {
2807
+ if (!username || !accessToken) {
2766
2808
  throw new Error("[SDK][Integrations][3Speak] \u2013\xA0anon user");
2767
2809
  }
2768
2810
  const fetchApi = getBoundFetch();
@@ -2776,7 +2818,8 @@ function getAccountTokenQueryOptions(username) {
2776
2818
  );
2777
2819
  const memoQueryOptions = HiveSignerIntegration.queries.getDecodeMemoQueryOptions(
2778
2820
  username,
2779
- (await response.json()).memo
2821
+ (await response.json()).memo,
2822
+ accessToken
2780
2823
  );
2781
2824
  await getQueryClient().prefetchQuery(memoQueryOptions);
2782
2825
  const { memoDecoded } = getQueryClient().getQueryData(
@@ -2786,17 +2829,23 @@ function getAccountTokenQueryOptions(username) {
2786
2829
  }
2787
2830
  });
2788
2831
  }
2789
- function getAccountVideosQueryOptions(username) {
2832
+ function getAccountVideosQueryOptions(username, accessToken) {
2790
2833
  return queryOptions({
2791
2834
  queryKey: ["integrations", "3speak", "videos", username],
2792
- enabled: !!username,
2835
+ enabled: !!username && !!accessToken,
2793
2836
  queryFn: async () => {
2794
- await getQueryClient().prefetchQuery(
2795
- getAccountTokenQueryOptions(username)
2796
- );
2797
- const token = getQueryClient().getQueryData(
2798
- getAccountTokenQueryOptions(username).queryKey
2837
+ if (!username || !accessToken) {
2838
+ throw new Error("[SDK][Integrations][3Speak] \u2013\xA0anon user");
2839
+ }
2840
+ const tokenQueryOptions = getAccountTokenQueryOptions(
2841
+ username,
2842
+ accessToken
2799
2843
  );
2844
+ await getQueryClient().prefetchQuery(tokenQueryOptions);
2845
+ const token = getQueryClient().getQueryData(tokenQueryOptions.queryKey);
2846
+ if (!token) {
2847
+ throw new Error("[SDK][Integrations][3Speak] \u2013 missing account token");
2848
+ }
2800
2849
  const fetchApi = getBoundFetch();
2801
2850
  const response = await fetchApi(
2802
2851
  `https://studio.3speak.tv/mobile/api/my-videos`,
@@ -2907,13 +2956,13 @@ function getAccountRcQueryOptions(username) {
2907
2956
  enabled: !!username
2908
2957
  });
2909
2958
  }
2910
- function getGameStatusCheckQueryOptions(username, gameType) {
2959
+ function getGameStatusCheckQueryOptions(username, code, gameType) {
2911
2960
  return queryOptions({
2912
2961
  queryKey: ["games", "status-check", gameType, username],
2913
- enabled: !!username,
2962
+ enabled: !!username && !!code,
2914
2963
  queryFn: async () => {
2915
- if (!username) {
2916
- throw new Error("[SDK][Games] \u2013 anon user in status check");
2964
+ if (!username || !code) {
2965
+ throw new Error("[SDK][Games] \u2013 missing auth");
2917
2966
  }
2918
2967
  const fetchApi = getBoundFetch();
2919
2968
  const response = await fetchApi(
@@ -2922,7 +2971,7 @@ function getGameStatusCheckQueryOptions(username, gameType) {
2922
2971
  method: "POST",
2923
2972
  body: JSON.stringify({
2924
2973
  game_type: gameType,
2925
- code: getAccessToken(username)
2974
+ code
2926
2975
  }),
2927
2976
  headers: {
2928
2977
  "Content-Type": "application/json"
@@ -2933,7 +2982,7 @@ function getGameStatusCheckQueryOptions(username, gameType) {
2933
2982
  }
2934
2983
  });
2935
2984
  }
2936
- function useGameClaim(username, gameType, key) {
2985
+ function useGameClaim(username, code, gameType, key) {
2937
2986
  const { mutateAsync: recordActivity } = useRecordActivity(
2938
2987
  username,
2939
2988
  "spin-rolled"
@@ -2941,8 +2990,8 @@ function useGameClaim(username, gameType, key) {
2941
2990
  return useMutation({
2942
2991
  mutationKey: ["games", "post", gameType, username],
2943
2992
  mutationFn: async () => {
2944
- if (!username) {
2945
- throw new Error("[SDK][Games] \u2013 anon user in game post");
2993
+ if (!username || !code) {
2994
+ throw new Error("[SDK][Games] \u2013 missing auth");
2946
2995
  }
2947
2996
  const fetchApi = getBoundFetch();
2948
2997
  const response = await fetchApi(
@@ -2951,7 +3000,7 @@ function useGameClaim(username, gameType, key) {
2951
3000
  method: "POST",
2952
3001
  body: JSON.stringify({
2953
3002
  game_type: gameType,
2954
- code: getAccessToken(username),
3003
+ code,
2955
3004
  key
2956
3005
  }),
2957
3006
  headers: {
@@ -3116,15 +3165,18 @@ function getCommunityPermissions({
3116
3165
  isModerator
3117
3166
  };
3118
3167
  }
3119
- function getNotificationsUnreadCountQueryOptions(activeUsername) {
3168
+ function getNotificationsUnreadCountQueryOptions(activeUsername, code) {
3120
3169
  return queryOptions({
3121
3170
  queryKey: ["notifications", "unread", activeUsername],
3122
3171
  queryFn: async () => {
3172
+ if (!code) {
3173
+ return 0;
3174
+ }
3123
3175
  const response = await fetch(
3124
3176
  `${CONFIG.privateApiHost}/private-api/notifications/unread`,
3125
3177
  {
3126
3178
  method: "POST",
3127
- body: JSON.stringify({ code: getAccessToken(activeUsername) }),
3179
+ body: JSON.stringify({ code }),
3128
3180
  headers: {
3129
3181
  "Content-Type": "application/json"
3130
3182
  }
@@ -3133,17 +3185,20 @@ function getNotificationsUnreadCountQueryOptions(activeUsername) {
3133
3185
  const data = await response.json();
3134
3186
  return data.count;
3135
3187
  },
3136
- enabled: !!activeUsername,
3188
+ enabled: !!activeUsername && !!code,
3137
3189
  initialData: 0,
3138
3190
  refetchInterval: 6e4
3139
3191
  });
3140
3192
  }
3141
- function getNotificationsInfiniteQueryOptions(activeUsername, filter = void 0) {
3193
+ function getNotificationsInfiniteQueryOptions(activeUsername, code, filter = void 0) {
3142
3194
  return infiniteQueryOptions({
3143
3195
  queryKey: ["notifications", activeUsername, filter],
3144
3196
  queryFn: async ({ pageParam }) => {
3197
+ if (!code) {
3198
+ return [];
3199
+ }
3145
3200
  const data = {
3146
- code: getAccessToken(activeUsername),
3201
+ code,
3147
3202
  filter,
3148
3203
  since: pageParam,
3149
3204
  user: void 0
@@ -3160,7 +3215,7 @@ function getNotificationsInfiniteQueryOptions(activeUsername, filter = void 0) {
3160
3215
  );
3161
3216
  return response.json();
3162
3217
  },
3163
- enabled: !!activeUsername,
3218
+ enabled: !!activeUsername && !!code,
3164
3219
  initialData: { pages: [], pageParams: [] },
3165
3220
  initialPageParam: "",
3166
3221
  getNextPageParam: (lastPage) => lastPage?.[lastPage.length - 1]?.id ?? "",
@@ -3213,16 +3268,19 @@ var NotificationViewType = /* @__PURE__ */ ((NotificationViewType2) => {
3213
3268
  })(NotificationViewType || {});
3214
3269
 
3215
3270
  // src/modules/notifications/queries/get-notifications-settings-query-options.ts
3216
- function getNotificationsSettingsQueryOptions(activeUsername) {
3271
+ function getNotificationsSettingsQueryOptions(activeUsername, code) {
3217
3272
  return queryOptions({
3218
3273
  queryKey: ["notifications", "settings", activeUsername],
3219
3274
  queryFn: async () => {
3220
3275
  let token = activeUsername + "-web";
3276
+ if (!code) {
3277
+ throw new Error("Missing access token");
3278
+ }
3221
3279
  const response = await fetch(
3222
3280
  CONFIG.privateApiHost + "/private-api/detail-device",
3223
3281
  {
3224
3282
  body: JSON.stringify({
3225
- code: getAccessToken(activeUsername),
3283
+ code,
3226
3284
  username: activeUsername,
3227
3285
  token
3228
3286
  }),
@@ -3237,7 +3295,7 @@ function getNotificationsSettingsQueryOptions(activeUsername) {
3237
3295
  }
3238
3296
  return response.json();
3239
3297
  },
3240
- enabled: !!activeUsername,
3298
+ enabled: !!activeUsername && !!code,
3241
3299
  refetchOnMount: false,
3242
3300
  initialData: () => {
3243
3301
  const wasMutedPreviously = typeof window !== "undefined" ? localStorage.getItem("notifications") !== "true" : false;
@@ -3531,8 +3589,9 @@ function getMarketDataQueryOptions(coin, vsCurrency, fromTs, toTs) {
3531
3589
  return queryOptions({
3532
3590
  queryKey: ["market", "data", coin, vsCurrency, fromTs, toTs],
3533
3591
  queryFn: async ({ signal }) => {
3592
+ const fetchApi = getBoundFetch();
3534
3593
  const url = `https://api.coingecko.com/api/v3/coins/${coin}/market_chart/range?vs_currency=${vsCurrency}&from=${fromTs}&to=${toTs}`;
3535
- const response = await fetch(url, { signal });
3594
+ const response = await fetchApi(url, { signal });
3536
3595
  if (!response.ok) {
3537
3596
  throw new Error(`Failed to fetch market data: ${response.status}`);
3538
3597
  }
@@ -3540,6 +3599,46 @@ function getMarketDataQueryOptions(coin, vsCurrency, fromTs, toTs) {
3540
3599
  }
3541
3600
  });
3542
3601
  }
3602
+
3603
+ // src/modules/market/requests.ts
3604
+ async function parseJsonResponse(response) {
3605
+ const data = await response.json();
3606
+ if (!response.ok) {
3607
+ const error = new Error(`Request failed with status ${response.status}`);
3608
+ error.status = response.status;
3609
+ error.data = data;
3610
+ throw error;
3611
+ }
3612
+ return data;
3613
+ }
3614
+ async function getMarketData(coin, vsCurrency, fromTs, toTs) {
3615
+ const fetchApi = getBoundFetch();
3616
+ const url = `https://api.coingecko.com/api/v3/coins/${coin}/market_chart/range?vs_currency=${vsCurrency}&from=${fromTs}&to=${toTs}`;
3617
+ const response = await fetchApi(url);
3618
+ return parseJsonResponse(response);
3619
+ }
3620
+ async function getCurrencyRate(cur) {
3621
+ if (cur === "hbd") {
3622
+ return 1;
3623
+ }
3624
+ const fetchApi = getBoundFetch();
3625
+ const url = `https://api.coingecko.com/api/v3/simple/price?ids=hive_dollar&vs_currencies=${cur}`;
3626
+ const response = await fetchApi(url);
3627
+ const data = await parseJsonResponse(response);
3628
+ return data.hive_dollar[cur];
3629
+ }
3630
+ async function getCurrencyTokenRate(currency, token) {
3631
+ const fetchApi = getBoundFetch();
3632
+ const response = await fetchApi(
3633
+ CONFIG.privateApiHost + `/private-api/market-data/${currency === "hbd" ? "usd" : currency}/${token}`
3634
+ );
3635
+ return parseJsonResponse(response);
3636
+ }
3637
+ async function getCurrencyRates() {
3638
+ const fetchApi = getBoundFetch();
3639
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/market-data/latest");
3640
+ return parseJsonResponse(response);
3641
+ }
3543
3642
  function getPointsQueryOptions(username, filter = 0) {
3544
3643
  return queryOptions({
3545
3644
  queryKey: ["points", username, filter],
@@ -3880,6 +3979,311 @@ function getBoostPlusAccountPricesQueryOptions(account, accessToken) {
3880
3979
  });
3881
3980
  }
3882
3981
 
3883
- 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 };
3982
+ // src/modules/private-api/requests.ts
3983
+ async function parseJsonResponse2(response) {
3984
+ if (!response.ok) {
3985
+ let errorData = void 0;
3986
+ try {
3987
+ errorData = await response.json();
3988
+ } catch {
3989
+ errorData = void 0;
3990
+ }
3991
+ const error = new Error(`Request failed with status ${response.status}`);
3992
+ error.status = response.status;
3993
+ error.data = errorData;
3994
+ throw error;
3995
+ }
3996
+ return await response.json();
3997
+ }
3998
+ async function signUp(username, email, referral) {
3999
+ const fetchApi = getBoundFetch();
4000
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/account-create", {
4001
+ method: "POST",
4002
+ headers: {
4003
+ "Content-Type": "application/json"
4004
+ },
4005
+ body: JSON.stringify({ username, email, referral })
4006
+ });
4007
+ const data = await parseJsonResponse2(response);
4008
+ return { status: response.status, data };
4009
+ }
4010
+ async function subscribeEmail(email) {
4011
+ const fetchApi = getBoundFetch();
4012
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/subscribe", {
4013
+ method: "POST",
4014
+ headers: {
4015
+ "Content-Type": "application/json"
4016
+ },
4017
+ body: JSON.stringify({ email })
4018
+ });
4019
+ const data = await parseJsonResponse2(response);
4020
+ return { status: response.status, data };
4021
+ }
4022
+ async function usrActivity(code, ty, bl = "", tx = "") {
4023
+ const params = { code, ty };
4024
+ if (bl) {
4025
+ params.bl = bl;
4026
+ }
4027
+ if (tx) {
4028
+ params.tx = tx;
4029
+ }
4030
+ const fetchApi = getBoundFetch();
4031
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/usr-activity", {
4032
+ method: "POST",
4033
+ headers: {
4034
+ "Content-Type": "application/json"
4035
+ },
4036
+ body: JSON.stringify(params)
4037
+ });
4038
+ await parseJsonResponse2(response);
4039
+ }
4040
+ async function getNotifications(code, filter, since = null, user = null) {
4041
+ const data = {
4042
+ code
4043
+ };
4044
+ if (filter) {
4045
+ data.filter = filter;
4046
+ }
4047
+ if (since) {
4048
+ data.since = since;
4049
+ }
4050
+ if (user) {
4051
+ data.user = user;
4052
+ }
4053
+ const fetchApi = getBoundFetch();
4054
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/notifications", {
4055
+ method: "POST",
4056
+ headers: {
4057
+ "Content-Type": "application/json"
4058
+ },
4059
+ body: JSON.stringify(data)
4060
+ });
4061
+ return parseJsonResponse2(response);
4062
+ }
4063
+ async function saveNotificationSetting(code, username, system, allows_notify, notify_types, token) {
4064
+ const data = {
4065
+ code,
4066
+ username,
4067
+ token,
4068
+ system,
4069
+ allows_notify,
4070
+ notify_types
4071
+ };
4072
+ const fetchApi = getBoundFetch();
4073
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/register-device", {
4074
+ method: "POST",
4075
+ headers: {
4076
+ "Content-Type": "application/json"
4077
+ },
4078
+ body: JSON.stringify(data)
4079
+ });
4080
+ return parseJsonResponse2(response);
4081
+ }
4082
+ async function getNotificationSetting(code, username, token) {
4083
+ const data = { code, username, token };
4084
+ const fetchApi = getBoundFetch();
4085
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/detail-device", {
4086
+ method: "POST",
4087
+ headers: {
4088
+ "Content-Type": "application/json"
4089
+ },
4090
+ body: JSON.stringify(data)
4091
+ });
4092
+ return parseJsonResponse2(response);
4093
+ }
4094
+ async function markNotifications(code, id) {
4095
+ const data = {
4096
+ code
4097
+ };
4098
+ if (id) {
4099
+ data.id = id;
4100
+ }
4101
+ const fetchApi = getBoundFetch();
4102
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/notifications/mark", {
4103
+ method: "POST",
4104
+ headers: {
4105
+ "Content-Type": "application/json"
4106
+ },
4107
+ body: JSON.stringify(data)
4108
+ });
4109
+ return parseJsonResponse2(response);
4110
+ }
4111
+ async function addImage(code, url) {
4112
+ const data = { code, url };
4113
+ const fetchApi = getBoundFetch();
4114
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/images-add", {
4115
+ method: "POST",
4116
+ headers: {
4117
+ "Content-Type": "application/json"
4118
+ },
4119
+ body: JSON.stringify(data)
4120
+ });
4121
+ return parseJsonResponse2(response);
4122
+ }
4123
+ async function uploadImage(file, token, signal) {
4124
+ const fetchApi = getBoundFetch();
4125
+ const formData = new FormData();
4126
+ formData.append("file", file);
4127
+ const response = await fetchApi(`${CONFIG.imageHost}/hs/${token}`, {
4128
+ method: "POST",
4129
+ body: formData,
4130
+ signal
4131
+ });
4132
+ return parseJsonResponse2(response);
4133
+ }
4134
+ async function deleteImage(code, imageId) {
4135
+ const data = { code, id: imageId };
4136
+ const fetchApi = getBoundFetch();
4137
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/images-delete", {
4138
+ method: "POST",
4139
+ headers: {
4140
+ "Content-Type": "application/json"
4141
+ },
4142
+ body: JSON.stringify(data)
4143
+ });
4144
+ return parseJsonResponse2(response);
4145
+ }
4146
+ async function addDraft(code, title, body, tags, meta) {
4147
+ const data = { code, title, body, tags, meta };
4148
+ const fetchApi = getBoundFetch();
4149
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/drafts-add", {
4150
+ method: "POST",
4151
+ headers: {
4152
+ "Content-Type": "application/json"
4153
+ },
4154
+ body: JSON.stringify(data)
4155
+ });
4156
+ return parseJsonResponse2(response);
4157
+ }
4158
+ async function updateDraft(code, draftId, title, body, tags, meta) {
4159
+ const data = { code, id: draftId, title, body, tags, meta };
4160
+ const fetchApi = getBoundFetch();
4161
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/drafts-update", {
4162
+ method: "POST",
4163
+ headers: {
4164
+ "Content-Type": "application/json"
4165
+ },
4166
+ body: JSON.stringify(data)
4167
+ });
4168
+ return parseJsonResponse2(response);
4169
+ }
4170
+ async function deleteDraft(code, draftId) {
4171
+ const data = { code, id: draftId };
4172
+ const fetchApi = getBoundFetch();
4173
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/drafts-delete", {
4174
+ method: "POST",
4175
+ headers: {
4176
+ "Content-Type": "application/json"
4177
+ },
4178
+ body: JSON.stringify(data)
4179
+ });
4180
+ return parseJsonResponse2(response);
4181
+ }
4182
+ async function addSchedule(code, permlink, title, body, meta, options, schedule, reblog) {
4183
+ const data = {
4184
+ code,
4185
+ permlink,
4186
+ title,
4187
+ body,
4188
+ meta,
4189
+ schedule,
4190
+ reblog
4191
+ };
4192
+ if (options) {
4193
+ data.options = options;
4194
+ }
4195
+ const fetchApi = getBoundFetch();
4196
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/schedules-add", {
4197
+ method: "POST",
4198
+ headers: {
4199
+ "Content-Type": "application/json"
4200
+ },
4201
+ body: JSON.stringify(data)
4202
+ });
4203
+ return parseJsonResponse2(response);
4204
+ }
4205
+ async function deleteSchedule(code, id) {
4206
+ const data = { code, id };
4207
+ const fetchApi = getBoundFetch();
4208
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/schedules-delete", {
4209
+ method: "POST",
4210
+ headers: {
4211
+ "Content-Type": "application/json"
4212
+ },
4213
+ body: JSON.stringify(data)
4214
+ });
4215
+ return parseJsonResponse2(response);
4216
+ }
4217
+ async function moveSchedule(code, id) {
4218
+ const data = { code, id };
4219
+ const fetchApi = getBoundFetch();
4220
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/schedules-move", {
4221
+ method: "POST",
4222
+ headers: {
4223
+ "Content-Type": "application/json"
4224
+ },
4225
+ body: JSON.stringify(data)
4226
+ });
4227
+ return parseJsonResponse2(response);
4228
+ }
4229
+ async function getPromotedPost(code, author, permlink) {
4230
+ const data = { code, author, permlink };
4231
+ const fetchApi = getBoundFetch();
4232
+ const response = await fetchApi(CONFIG.privateApiHost + "/private-api/promoted-post", {
4233
+ method: "POST",
4234
+ headers: {
4235
+ "Content-Type": "application/json"
4236
+ },
4237
+ body: JSON.stringify(data)
4238
+ });
4239
+ return parseJsonResponse2(response);
4240
+ }
4241
+ async function onboardEmail(username, email, friend) {
4242
+ const dataBody = {
4243
+ username,
4244
+ email,
4245
+ friend
4246
+ };
4247
+ const fetchApi = getBoundFetch();
4248
+ const response = await fetchApi(
4249
+ CONFIG.privateApiHost + "/private-api/account-create-friend",
4250
+ {
4251
+ method: "POST",
4252
+ headers: {
4253
+ "Content-Type": "application/json"
4254
+ },
4255
+ body: JSON.stringify(dataBody)
4256
+ }
4257
+ );
4258
+ return parseJsonResponse2(response);
4259
+ }
4260
+
4261
+ // src/modules/auth/requests.ts
4262
+ async function hsTokenRenew(code) {
4263
+ const fetchApi = getBoundFetch();
4264
+ const response = await fetchApi(CONFIG.privateApiHost + "/auth-api/hs-token-refresh", {
4265
+ method: "POST",
4266
+ headers: {
4267
+ "Content-Type": "application/json"
4268
+ },
4269
+ body: JSON.stringify({ code })
4270
+ });
4271
+ if (!response.ok) {
4272
+ let data2 = void 0;
4273
+ try {
4274
+ data2 = await response.json();
4275
+ } catch {
4276
+ data2 = void 0;
4277
+ }
4278
+ const error = new Error(`Failed to refresh token: ${response.status}`);
4279
+ error.status = response.status;
4280
+ error.data = data2;
4281
+ throw error;
4282
+ }
4283
+ const data = await response.json();
4284
+ return data;
4285
+ }
4286
+
4287
+ 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 };
3884
4288
  //# sourceMappingURL=index.js.map
3885
4289
  //# sourceMappingURL=index.js.map