@ecency/sdk 1.4.1 → 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.
- package/dist/browser/index.d.ts +146 -73
- package/dist/browser/index.js +624 -237
- package/dist/browser/index.js.map +1 -1
- package/dist/index.browser.mjs +41 -30
- package/dist/index.cjs +41 -30
- package/dist/index.d.ts +16 -7
- package/dist/index.mjs +41 -30
- package/dist/node/index.cjs +646 -236
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +624 -237
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -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) {
|
|
@@ -259,143 +399,6 @@ var getAccessToken = (username) => getUser(username) && getUser(username).access
|
|
|
259
399
|
var getPostingKey = (username) => getUser(username) && getUser(username).postingKey;
|
|
260
400
|
var getLoginType = (username) => getUser(username) && getUser(username).loginType;
|
|
261
401
|
var getRefreshToken = (username) => getUser(username) && getUser(username).refreshToken;
|
|
262
|
-
|
|
263
|
-
// src/modules/keychain/keychain.ts
|
|
264
|
-
var keychain_exports = {};
|
|
265
|
-
__export(keychain_exports, {
|
|
266
|
-
broadcast: () => broadcast,
|
|
267
|
-
customJson: () => customJson,
|
|
268
|
-
handshake: () => handshake
|
|
269
|
-
});
|
|
270
|
-
function handshake() {
|
|
271
|
-
return new Promise((resolve) => {
|
|
272
|
-
window.hive_keychain?.requestHandshake(() => {
|
|
273
|
-
resolve();
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
var broadcast = (account, operations, key, rpc = null) => new Promise((resolve, reject) => {
|
|
278
|
-
window.hive_keychain?.requestBroadcast(
|
|
279
|
-
account,
|
|
280
|
-
operations,
|
|
281
|
-
key,
|
|
282
|
-
(resp) => {
|
|
283
|
-
if (!resp.success) {
|
|
284
|
-
reject({ message: "Operation cancelled" });
|
|
285
|
-
}
|
|
286
|
-
resolve(resp);
|
|
287
|
-
},
|
|
288
|
-
rpc
|
|
289
|
-
);
|
|
290
|
-
});
|
|
291
|
-
var customJson = (account, id, key, json, display_msg, rpc = null) => new Promise((resolve, reject) => {
|
|
292
|
-
window.hive_keychain?.requestCustomJson(
|
|
293
|
-
account,
|
|
294
|
-
id,
|
|
295
|
-
key,
|
|
296
|
-
json,
|
|
297
|
-
display_msg,
|
|
298
|
-
(resp) => {
|
|
299
|
-
if (!resp.success) {
|
|
300
|
-
reject({ message: "Operation cancelled" });
|
|
301
|
-
}
|
|
302
|
-
resolve(resp);
|
|
303
|
-
},
|
|
304
|
-
rpc
|
|
305
|
-
);
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
// src/modules/core/mutations/use-broadcast-mutation.ts
|
|
309
|
-
function useBroadcastMutation(mutationKey = [], username, operations, onSuccess = () => {
|
|
310
|
-
}) {
|
|
311
|
-
return useMutation({
|
|
312
|
-
onSuccess,
|
|
313
|
-
mutationKey: [...mutationKey, username],
|
|
314
|
-
mutationFn: async (payload) => {
|
|
315
|
-
if (!username) {
|
|
316
|
-
throw new Error(
|
|
317
|
-
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
|
318
|
-
);
|
|
319
|
-
}
|
|
320
|
-
const postingKey = getPostingKey(username);
|
|
321
|
-
if (postingKey) {
|
|
322
|
-
const privateKey = PrivateKey.fromString(postingKey);
|
|
323
|
-
return CONFIG.hiveClient.broadcast.sendOperations(
|
|
324
|
-
operations(payload),
|
|
325
|
-
privateKey
|
|
326
|
-
);
|
|
327
|
-
}
|
|
328
|
-
const loginType = getLoginType(username);
|
|
329
|
-
if (loginType && loginType == "keychain") {
|
|
330
|
-
return keychain_exports.broadcast(
|
|
331
|
-
username,
|
|
332
|
-
operations(payload),
|
|
333
|
-
"Posting"
|
|
334
|
-
).then((r) => r.result);
|
|
335
|
-
}
|
|
336
|
-
let token = getAccessToken(username);
|
|
337
|
-
if (token) {
|
|
338
|
-
const f = getBoundFetch();
|
|
339
|
-
const res = await f("https://hivesigner.com/api/broadcast", {
|
|
340
|
-
method: "POST",
|
|
341
|
-
headers: {
|
|
342
|
-
Authorization: token,
|
|
343
|
-
"Content-Type": "application/json",
|
|
344
|
-
Accept: "application/json"
|
|
345
|
-
},
|
|
346
|
-
body: JSON.stringify({ operations: operations(payload) })
|
|
347
|
-
});
|
|
348
|
-
if (!res.ok) {
|
|
349
|
-
const txt = await res.text().catch(() => "");
|
|
350
|
-
throw new Error(`[Hivesigner] ${res.status} ${res.statusText} ${txt}`);
|
|
351
|
-
}
|
|
352
|
-
const json = await res.json();
|
|
353
|
-
if (json?.errors) {
|
|
354
|
-
throw new Error(`[Hivesigner] ${JSON.stringify(json.errors)}`);
|
|
355
|
-
}
|
|
356
|
-
return json.result;
|
|
357
|
-
}
|
|
358
|
-
throw new Error(
|
|
359
|
-
"[SDK][Broadcast] \u2013 cannot broadcast w/o posting key or token"
|
|
360
|
-
);
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
async function broadcastJson(username, id, payload) {
|
|
365
|
-
if (!username) {
|
|
366
|
-
throw new Error(
|
|
367
|
-
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
|
368
|
-
);
|
|
369
|
-
}
|
|
370
|
-
const jjson = {
|
|
371
|
-
id,
|
|
372
|
-
required_auths: [],
|
|
373
|
-
required_posting_auths: [username],
|
|
374
|
-
json: JSON.stringify(payload)
|
|
375
|
-
};
|
|
376
|
-
const postingKey = getPostingKey(username);
|
|
377
|
-
if (postingKey) {
|
|
378
|
-
const privateKey = PrivateKey.fromString(postingKey);
|
|
379
|
-
return CONFIG.hiveClient.broadcast.json(
|
|
380
|
-
jjson,
|
|
381
|
-
privateKey
|
|
382
|
-
);
|
|
383
|
-
}
|
|
384
|
-
const loginType = getLoginType(username);
|
|
385
|
-
if (loginType && loginType == "keychain") {
|
|
386
|
-
return keychain_exports.broadcast(username, [["custom_json", jjson]], "Posting").then((r) => r.result);
|
|
387
|
-
}
|
|
388
|
-
let token = getAccessToken(username);
|
|
389
|
-
if (token) {
|
|
390
|
-
const response = await new hs.Client({
|
|
391
|
-
accessToken: token
|
|
392
|
-
}).customJson([], [username], id, JSON.stringify(payload));
|
|
393
|
-
return response.result;
|
|
394
|
-
}
|
|
395
|
-
throw new Error(
|
|
396
|
-
"[SDK][Broadcast] \u2013 cannot broadcast w/o posting key or token"
|
|
397
|
-
);
|
|
398
|
-
}
|
|
399
402
|
function makeQueryClient() {
|
|
400
403
|
return new QueryClient({
|
|
401
404
|
defaultOptions: {
|
|
@@ -903,13 +906,13 @@ function getAccountSubscriptionsQueryOptions(username) {
|
|
|
903
906
|
}
|
|
904
907
|
});
|
|
905
908
|
}
|
|
906
|
-
function getActiveAccountBookmarksQueryOptions(activeUsername) {
|
|
909
|
+
function getActiveAccountBookmarksQueryOptions(activeUsername, code) {
|
|
907
910
|
return queryOptions({
|
|
908
911
|
queryKey: ["accounts", "bookmarks", activeUsername],
|
|
909
|
-
enabled: !!activeUsername,
|
|
912
|
+
enabled: !!activeUsername && !!code,
|
|
910
913
|
queryFn: async () => {
|
|
911
|
-
if (!activeUsername) {
|
|
912
|
-
throw new Error("[SDK][Accounts][Bookmarks] \u2013
|
|
914
|
+
if (!activeUsername || !code) {
|
|
915
|
+
throw new Error("[SDK][Accounts][Bookmarks] \u2013 missing auth");
|
|
913
916
|
}
|
|
914
917
|
const fetchApi = getBoundFetch();
|
|
915
918
|
const response = await fetchApi(
|
|
@@ -919,20 +922,20 @@ function getActiveAccountBookmarksQueryOptions(activeUsername) {
|
|
|
919
922
|
headers: {
|
|
920
923
|
"Content-Type": "application/json"
|
|
921
924
|
},
|
|
922
|
-
body: JSON.stringify({ code
|
|
925
|
+
body: JSON.stringify({ code })
|
|
923
926
|
}
|
|
924
927
|
);
|
|
925
928
|
return await response.json();
|
|
926
929
|
}
|
|
927
930
|
});
|
|
928
931
|
}
|
|
929
|
-
function getActiveAccountFavouritesQueryOptions(activeUsername) {
|
|
932
|
+
function getActiveAccountFavouritesQueryOptions(activeUsername, code) {
|
|
930
933
|
return queryOptions({
|
|
931
934
|
queryKey: ["accounts", "favourites", activeUsername],
|
|
932
|
-
enabled: !!activeUsername,
|
|
935
|
+
enabled: !!activeUsername && !!code,
|
|
933
936
|
queryFn: async () => {
|
|
934
|
-
if (!activeUsername) {
|
|
935
|
-
throw new Error("[SDK][Accounts][Favourites] \u2013
|
|
937
|
+
if (!activeUsername || !code) {
|
|
938
|
+
throw new Error("[SDK][Accounts][Favourites] \u2013 missing auth");
|
|
936
939
|
}
|
|
937
940
|
const fetchApi = getBoundFetch();
|
|
938
941
|
const response = await fetchApi(
|
|
@@ -942,18 +945,21 @@ function getActiveAccountFavouritesQueryOptions(activeUsername) {
|
|
|
942
945
|
headers: {
|
|
943
946
|
"Content-Type": "application/json"
|
|
944
947
|
},
|
|
945
|
-
body: JSON.stringify({ code
|
|
948
|
+
body: JSON.stringify({ code })
|
|
946
949
|
}
|
|
947
950
|
);
|
|
948
951
|
return await response.json();
|
|
949
952
|
}
|
|
950
953
|
});
|
|
951
954
|
}
|
|
952
|
-
function getAccountRecoveriesQueryOptions(username) {
|
|
955
|
+
function getAccountRecoveriesQueryOptions(username, code) {
|
|
953
956
|
return queryOptions({
|
|
954
|
-
enabled: !!username,
|
|
957
|
+
enabled: !!username && !!code,
|
|
955
958
|
queryKey: ["accounts", "recoveries", username],
|
|
956
959
|
queryFn: async () => {
|
|
960
|
+
if (!username || !code) {
|
|
961
|
+
throw new Error("[SDK][Accounts] Missing username or access token");
|
|
962
|
+
}
|
|
957
963
|
const fetchApi = getBoundFetch();
|
|
958
964
|
const response = await fetchApi(
|
|
959
965
|
CONFIG.privateApiHost + "/private-api/recoveries",
|
|
@@ -962,7 +968,7 @@ function getAccountRecoveriesQueryOptions(username) {
|
|
|
962
968
|
headers: {
|
|
963
969
|
"Content-Type": "application/json"
|
|
964
970
|
},
|
|
965
|
-
body: JSON.stringify({ code
|
|
971
|
+
body: JSON.stringify({ code })
|
|
966
972
|
}
|
|
967
973
|
);
|
|
968
974
|
return response.json();
|
|
@@ -1237,17 +1243,20 @@ function getTrendingTagsWithStatsQueryOptions(limit = 250) {
|
|
|
1237
1243
|
refetchOnMount: true
|
|
1238
1244
|
});
|
|
1239
1245
|
}
|
|
1240
|
-
function getFragmentsQueryOptions(username) {
|
|
1246
|
+
function getFragmentsQueryOptions(username, code) {
|
|
1241
1247
|
return queryOptions({
|
|
1242
1248
|
queryKey: ["posts", "fragments", username],
|
|
1243
1249
|
queryFn: async () => {
|
|
1250
|
+
if (!code) {
|
|
1251
|
+
return [];
|
|
1252
|
+
}
|
|
1244
1253
|
const fetchApi = getBoundFetch();
|
|
1245
1254
|
const response = await fetchApi(
|
|
1246
1255
|
CONFIG.privateApiHost + "/private-api/fragments",
|
|
1247
1256
|
{
|
|
1248
1257
|
method: "POST",
|
|
1249
1258
|
body: JSON.stringify({
|
|
1250
|
-
code
|
|
1259
|
+
code
|
|
1251
1260
|
}),
|
|
1252
1261
|
headers: {
|
|
1253
1262
|
"Content-Type": "application/json"
|
|
@@ -1256,7 +1265,7 @@ function getFragmentsQueryOptions(username) {
|
|
|
1256
1265
|
);
|
|
1257
1266
|
return response.json();
|
|
1258
1267
|
},
|
|
1259
|
-
enabled: !!username
|
|
1268
|
+
enabled: !!username && !!code
|
|
1260
1269
|
});
|
|
1261
1270
|
}
|
|
1262
1271
|
function getPromotedPostsQuery(type = "feed") {
|
|
@@ -1563,20 +1572,21 @@ function getReblogsQueryOptions(username, activeUsername, limit = 200) {
|
|
|
1563
1572
|
enabled: !!username
|
|
1564
1573
|
});
|
|
1565
1574
|
}
|
|
1566
|
-
function getSchedulesQueryOptions(activeUsername) {
|
|
1575
|
+
function getSchedulesQueryOptions(activeUsername, code) {
|
|
1567
1576
|
return queryOptions({
|
|
1568
1577
|
queryKey: ["posts", "schedules", activeUsername],
|
|
1569
1578
|
queryFn: async () => {
|
|
1570
|
-
if (!activeUsername) {
|
|
1579
|
+
if (!activeUsername || !code) {
|
|
1571
1580
|
return [];
|
|
1572
1581
|
}
|
|
1573
|
-
const
|
|
1582
|
+
const fetchApi = getBoundFetch();
|
|
1583
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/schedules", {
|
|
1574
1584
|
method: "POST",
|
|
1575
1585
|
headers: {
|
|
1576
1586
|
"Content-Type": "application/json"
|
|
1577
1587
|
},
|
|
1578
1588
|
body: JSON.stringify({
|
|
1579
|
-
code
|
|
1589
|
+
code
|
|
1580
1590
|
})
|
|
1581
1591
|
});
|
|
1582
1592
|
if (!response.ok) {
|
|
@@ -1584,23 +1594,24 @@ function getSchedulesQueryOptions(activeUsername) {
|
|
|
1584
1594
|
}
|
|
1585
1595
|
return response.json();
|
|
1586
1596
|
},
|
|
1587
|
-
enabled: !!activeUsername
|
|
1597
|
+
enabled: !!activeUsername && !!code
|
|
1588
1598
|
});
|
|
1589
1599
|
}
|
|
1590
|
-
function getDraftsQueryOptions(activeUsername) {
|
|
1600
|
+
function getDraftsQueryOptions(activeUsername, code) {
|
|
1591
1601
|
return queryOptions({
|
|
1592
1602
|
queryKey: ["posts", "drafts", activeUsername],
|
|
1593
1603
|
queryFn: async () => {
|
|
1594
|
-
if (!activeUsername) {
|
|
1604
|
+
if (!activeUsername || !code) {
|
|
1595
1605
|
return [];
|
|
1596
1606
|
}
|
|
1597
|
-
const
|
|
1607
|
+
const fetchApi = getBoundFetch();
|
|
1608
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/drafts", {
|
|
1598
1609
|
method: "POST",
|
|
1599
1610
|
headers: {
|
|
1600
1611
|
"Content-Type": "application/json"
|
|
1601
1612
|
},
|
|
1602
1613
|
body: JSON.stringify({
|
|
1603
|
-
code
|
|
1614
|
+
code
|
|
1604
1615
|
})
|
|
1605
1616
|
});
|
|
1606
1617
|
if (!response.ok) {
|
|
@@ -1608,17 +1619,18 @@ function getDraftsQueryOptions(activeUsername) {
|
|
|
1608
1619
|
}
|
|
1609
1620
|
return response.json();
|
|
1610
1621
|
},
|
|
1611
|
-
enabled: !!activeUsername
|
|
1622
|
+
enabled: !!activeUsername && !!code
|
|
1612
1623
|
});
|
|
1613
1624
|
}
|
|
1614
|
-
async function fetchUserImages(
|
|
1615
|
-
const
|
|
1625
|
+
async function fetchUserImages(code) {
|
|
1626
|
+
const fetchApi = getBoundFetch();
|
|
1627
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/images", {
|
|
1616
1628
|
method: "POST",
|
|
1617
1629
|
headers: {
|
|
1618
1630
|
"Content-Type": "application/json"
|
|
1619
1631
|
},
|
|
1620
1632
|
body: JSON.stringify({
|
|
1621
|
-
code
|
|
1633
|
+
code
|
|
1622
1634
|
})
|
|
1623
1635
|
});
|
|
1624
1636
|
if (!response.ok) {
|
|
@@ -1626,28 +1638,28 @@ async function fetchUserImages(username) {
|
|
|
1626
1638
|
}
|
|
1627
1639
|
return response.json();
|
|
1628
1640
|
}
|
|
1629
|
-
function getImagesQueryOptions(username) {
|
|
1641
|
+
function getImagesQueryOptions(username, code) {
|
|
1630
1642
|
return queryOptions({
|
|
1631
1643
|
queryKey: ["posts", "images", username],
|
|
1632
1644
|
queryFn: async () => {
|
|
1633
|
-
if (!username) {
|
|
1645
|
+
if (!username || !code) {
|
|
1634
1646
|
return [];
|
|
1635
1647
|
}
|
|
1636
|
-
return fetchUserImages(
|
|
1648
|
+
return fetchUserImages(code);
|
|
1637
1649
|
},
|
|
1638
|
-
enabled: !!username
|
|
1650
|
+
enabled: !!username && !!code
|
|
1639
1651
|
});
|
|
1640
1652
|
}
|
|
1641
|
-
function getGalleryImagesQueryOptions(activeUsername) {
|
|
1653
|
+
function getGalleryImagesQueryOptions(activeUsername, code) {
|
|
1642
1654
|
return queryOptions({
|
|
1643
1655
|
queryKey: ["posts", "gallery-images", activeUsername],
|
|
1644
1656
|
queryFn: async () => {
|
|
1645
|
-
if (!activeUsername) {
|
|
1657
|
+
if (!activeUsername || !code) {
|
|
1646
1658
|
return [];
|
|
1647
1659
|
}
|
|
1648
|
-
return fetchUserImages(
|
|
1660
|
+
return fetchUserImages(code);
|
|
1649
1661
|
},
|
|
1650
|
-
enabled: !!activeUsername
|
|
1662
|
+
enabled: !!activeUsername && !!code
|
|
1651
1663
|
});
|
|
1652
1664
|
}
|
|
1653
1665
|
function getCommentHistoryQueryOptions(author, permlink, onlyMeta = false) {
|
|
@@ -2043,12 +2055,13 @@ function getAccountVoteHistoryInfiniteQueryOptions(username, options) {
|
|
|
2043
2055
|
}
|
|
2044
2056
|
|
|
2045
2057
|
// src/modules/accounts/mutations/use-account-update.ts
|
|
2046
|
-
function useAccountUpdate(username) {
|
|
2058
|
+
function useAccountUpdate(username, accessToken, auth) {
|
|
2047
2059
|
const queryClient = useQueryClient();
|
|
2048
2060
|
const { data } = useQuery(getAccountFullQueryOptions(username));
|
|
2049
2061
|
return useBroadcastMutation(
|
|
2050
2062
|
["accounts", "update"],
|
|
2051
2063
|
username,
|
|
2064
|
+
accessToken,
|
|
2052
2065
|
(payload) => {
|
|
2053
2066
|
if (!data) {
|
|
2054
2067
|
throw new Error("[SDK][Accounts] \u2013 cannot update not existing account");
|
|
@@ -2072,7 +2085,7 @@ function useAccountUpdate(username) {
|
|
|
2072
2085
|
]
|
|
2073
2086
|
];
|
|
2074
2087
|
},
|
|
2075
|
-
(
|
|
2088
|
+
(_data, variables) => queryClient.setQueryData(
|
|
2076
2089
|
getAccountFullQueryOptions(username).queryKey,
|
|
2077
2090
|
(data2) => {
|
|
2078
2091
|
if (!data2) {
|
|
@@ -2086,7 +2099,8 @@ function useAccountUpdate(username) {
|
|
|
2086
2099
|
});
|
|
2087
2100
|
return obj;
|
|
2088
2101
|
}
|
|
2089
|
-
)
|
|
2102
|
+
),
|
|
2103
|
+
auth
|
|
2090
2104
|
);
|
|
2091
2105
|
}
|
|
2092
2106
|
function useAccountRelationsUpdate(reference, target, onSuccess, onError) {
|
|
@@ -2128,12 +2142,12 @@ function useAccountRelationsUpdate(reference, target, onSuccess, onError) {
|
|
|
2128
2142
|
}
|
|
2129
2143
|
});
|
|
2130
2144
|
}
|
|
2131
|
-
function useBookmarkAdd(username, onSuccess, onError) {
|
|
2145
|
+
function useBookmarkAdd(username, code, onSuccess, onError) {
|
|
2132
2146
|
return useMutation({
|
|
2133
2147
|
mutationKey: ["accounts", "bookmarks", "add", username],
|
|
2134
2148
|
mutationFn: async ({ author, permlink }) => {
|
|
2135
|
-
if (!username) {
|
|
2136
|
-
throw new Error("[SDK][Account][Bookmarks] \u2013
|
|
2149
|
+
if (!username || !code) {
|
|
2150
|
+
throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
|
|
2137
2151
|
}
|
|
2138
2152
|
const fetchApi = getBoundFetch();
|
|
2139
2153
|
const response = await fetchApi(
|
|
@@ -2146,7 +2160,7 @@ function useBookmarkAdd(username, onSuccess, onError) {
|
|
|
2146
2160
|
body: JSON.stringify({
|
|
2147
2161
|
author,
|
|
2148
2162
|
permlink,
|
|
2149
|
-
code
|
|
2163
|
+
code
|
|
2150
2164
|
})
|
|
2151
2165
|
}
|
|
2152
2166
|
);
|
|
@@ -2161,12 +2175,12 @@ function useBookmarkAdd(username, onSuccess, onError) {
|
|
|
2161
2175
|
onError
|
|
2162
2176
|
});
|
|
2163
2177
|
}
|
|
2164
|
-
function useBookmarkDelete(username, onSuccess, onError) {
|
|
2178
|
+
function useBookmarkDelete(username, code, onSuccess, onError) {
|
|
2165
2179
|
return useMutation({
|
|
2166
2180
|
mutationKey: ["accounts", "bookmarks", "delete", username],
|
|
2167
2181
|
mutationFn: async (bookmarkId) => {
|
|
2168
|
-
if (!username) {
|
|
2169
|
-
throw new Error("[SDK][Account][Bookmarks] \u2013
|
|
2182
|
+
if (!username || !code) {
|
|
2183
|
+
throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
|
|
2170
2184
|
}
|
|
2171
2185
|
const fetchApi = getBoundFetch();
|
|
2172
2186
|
const response = await fetchApi(
|
|
@@ -2178,7 +2192,7 @@ function useBookmarkDelete(username, onSuccess, onError) {
|
|
|
2178
2192
|
},
|
|
2179
2193
|
body: JSON.stringify({
|
|
2180
2194
|
id: bookmarkId,
|
|
2181
|
-
code
|
|
2195
|
+
code
|
|
2182
2196
|
})
|
|
2183
2197
|
}
|
|
2184
2198
|
);
|
|
@@ -2193,12 +2207,12 @@ function useBookmarkDelete(username, onSuccess, onError) {
|
|
|
2193
2207
|
onError
|
|
2194
2208
|
});
|
|
2195
2209
|
}
|
|
2196
|
-
function useAccountFavouriteAdd(username, onSuccess, onError) {
|
|
2210
|
+
function useAccountFavouriteAdd(username, code, onSuccess, onError) {
|
|
2197
2211
|
return useMutation({
|
|
2198
2212
|
mutationKey: ["accounts", "favourites", "add", username],
|
|
2199
2213
|
mutationFn: async (account) => {
|
|
2200
|
-
if (!username) {
|
|
2201
|
-
throw new Error("[SDK][Account][Bookmarks] \u2013
|
|
2214
|
+
if (!username || !code) {
|
|
2215
|
+
throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
|
|
2202
2216
|
}
|
|
2203
2217
|
const fetchApi = getBoundFetch();
|
|
2204
2218
|
const response = await fetchApi(
|
|
@@ -2210,7 +2224,7 @@ function useAccountFavouriteAdd(username, onSuccess, onError) {
|
|
|
2210
2224
|
},
|
|
2211
2225
|
body: JSON.stringify({
|
|
2212
2226
|
account,
|
|
2213
|
-
code
|
|
2227
|
+
code
|
|
2214
2228
|
})
|
|
2215
2229
|
}
|
|
2216
2230
|
);
|
|
@@ -2225,12 +2239,12 @@ function useAccountFavouriteAdd(username, onSuccess, onError) {
|
|
|
2225
2239
|
onError
|
|
2226
2240
|
});
|
|
2227
2241
|
}
|
|
2228
|
-
function useAccountFavouriteDelete(username, onSuccess, onError) {
|
|
2242
|
+
function useAccountFavouriteDelete(username, code, onSuccess, onError) {
|
|
2229
2243
|
return useMutation({
|
|
2230
2244
|
mutationKey: ["accounts", "favourites", "add", username],
|
|
2231
2245
|
mutationFn: async (account) => {
|
|
2232
|
-
if (!username) {
|
|
2233
|
-
throw new Error("[SDK][Account][Bookmarks] \u2013
|
|
2246
|
+
if (!username || !code) {
|
|
2247
|
+
throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
|
|
2234
2248
|
}
|
|
2235
2249
|
const fetchApi = getBoundFetch();
|
|
2236
2250
|
const response = await fetchApi(
|
|
@@ -2242,7 +2256,7 @@ function useAccountFavouriteDelete(username, onSuccess, onError) {
|
|
|
2242
2256
|
},
|
|
2243
2257
|
body: JSON.stringify({
|
|
2244
2258
|
account,
|
|
2245
|
-
code
|
|
2259
|
+
code
|
|
2246
2260
|
})
|
|
2247
2261
|
}
|
|
2248
2262
|
);
|
|
@@ -2400,7 +2414,7 @@ function useAccountRevokePosting(username, options) {
|
|
|
2400
2414
|
}
|
|
2401
2415
|
});
|
|
2402
2416
|
}
|
|
2403
|
-
function useAccountUpdateRecovery(username, options) {
|
|
2417
|
+
function useAccountUpdateRecovery(username, code, options) {
|
|
2404
2418
|
const { data } = useQuery(getAccountFullQueryOptions(username));
|
|
2405
2419
|
return useMutation({
|
|
2406
2420
|
mutationKey: ["accounts", "recovery", data?.name],
|
|
@@ -2416,11 +2430,14 @@ function useAccountUpdateRecovery(username, options) {
|
|
|
2416
2430
|
extensions: []
|
|
2417
2431
|
};
|
|
2418
2432
|
if (type === "ecency") {
|
|
2433
|
+
if (!code) {
|
|
2434
|
+
throw new Error("[SDK][Accounts] \u2013 missing access token");
|
|
2435
|
+
}
|
|
2419
2436
|
const fetchApi = getBoundFetch();
|
|
2420
2437
|
return fetchApi(CONFIG.privateApiHost + "/private-api/recoveries-add", {
|
|
2421
2438
|
method: "POST",
|
|
2422
2439
|
body: JSON.stringify({
|
|
2423
|
-
code
|
|
2440
|
+
code,
|
|
2424
2441
|
email,
|
|
2425
2442
|
publicKeys: [
|
|
2426
2443
|
...data.owner.key_auths,
|
|
@@ -2544,17 +2561,20 @@ function getChainPropertiesQueryOptions() {
|
|
|
2544
2561
|
}
|
|
2545
2562
|
});
|
|
2546
2563
|
}
|
|
2547
|
-
function useAddFragment(username) {
|
|
2564
|
+
function useAddFragment(username, code) {
|
|
2548
2565
|
return useMutation({
|
|
2549
2566
|
mutationKey: ["posts", "add-fragment", username],
|
|
2550
2567
|
mutationFn: async ({ title, body }) => {
|
|
2568
|
+
if (!code) {
|
|
2569
|
+
throw new Error("[SDK][Posts] Missing access token");
|
|
2570
|
+
}
|
|
2551
2571
|
const fetchApi = getBoundFetch();
|
|
2552
2572
|
const response = await fetchApi(
|
|
2553
2573
|
CONFIG.privateApiHost + "/private-api/fragments-add",
|
|
2554
2574
|
{
|
|
2555
2575
|
method: "POST",
|
|
2556
2576
|
body: JSON.stringify({
|
|
2557
|
-
code
|
|
2577
|
+
code,
|
|
2558
2578
|
title,
|
|
2559
2579
|
body
|
|
2560
2580
|
}),
|
|
@@ -2567,23 +2587,26 @@ function useAddFragment(username) {
|
|
|
2567
2587
|
},
|
|
2568
2588
|
onSuccess(response) {
|
|
2569
2589
|
getQueryClient().setQueryData(
|
|
2570
|
-
getFragmentsQueryOptions(username).queryKey,
|
|
2590
|
+
getFragmentsQueryOptions(username, code).queryKey,
|
|
2571
2591
|
(data) => [response, ...data ?? []]
|
|
2572
2592
|
);
|
|
2573
2593
|
}
|
|
2574
2594
|
});
|
|
2575
2595
|
}
|
|
2576
|
-
function useEditFragment(username, fragmentId) {
|
|
2596
|
+
function useEditFragment(username, fragmentId, code) {
|
|
2577
2597
|
return useMutation({
|
|
2578
2598
|
mutationKey: ["posts", "edit-fragment", username, fragmentId],
|
|
2579
2599
|
mutationFn: async ({ title, body }) => {
|
|
2600
|
+
if (!code) {
|
|
2601
|
+
throw new Error("[SDK][Posts] Missing access token");
|
|
2602
|
+
}
|
|
2580
2603
|
const fetchApi = getBoundFetch();
|
|
2581
2604
|
const response = await fetchApi(
|
|
2582
2605
|
CONFIG.privateApiHost + "/private-api/fragments-update",
|
|
2583
2606
|
{
|
|
2584
2607
|
method: "POST",
|
|
2585
2608
|
body: JSON.stringify({
|
|
2586
|
-
code
|
|
2609
|
+
code,
|
|
2587
2610
|
id: fragmentId,
|
|
2588
2611
|
title,
|
|
2589
2612
|
body
|
|
@@ -2597,7 +2620,7 @@ function useEditFragment(username, fragmentId) {
|
|
|
2597
2620
|
},
|
|
2598
2621
|
onSuccess(response) {
|
|
2599
2622
|
getQueryClient().setQueryData(
|
|
2600
|
-
getFragmentsQueryOptions(username).queryKey,
|
|
2623
|
+
getFragmentsQueryOptions(username, code).queryKey,
|
|
2601
2624
|
(data) => {
|
|
2602
2625
|
if (!data) {
|
|
2603
2626
|
return [];
|
|
@@ -2612,15 +2635,18 @@ function useEditFragment(username, fragmentId) {
|
|
|
2612
2635
|
}
|
|
2613
2636
|
});
|
|
2614
2637
|
}
|
|
2615
|
-
function useRemoveFragment(username, fragmentId) {
|
|
2638
|
+
function useRemoveFragment(username, fragmentId, code) {
|
|
2616
2639
|
return useMutation({
|
|
2617
2640
|
mutationKey: ["posts", "remove-fragment", username],
|
|
2618
2641
|
mutationFn: async () => {
|
|
2642
|
+
if (!code) {
|
|
2643
|
+
throw new Error("[SDK][Posts] Missing access token");
|
|
2644
|
+
}
|
|
2619
2645
|
const fetchApi = getBoundFetch();
|
|
2620
2646
|
return fetchApi(CONFIG.privateApiHost + "/private-api/fragments-delete", {
|
|
2621
2647
|
method: "POST",
|
|
2622
2648
|
body: JSON.stringify({
|
|
2623
|
-
code
|
|
2649
|
+
code,
|
|
2624
2650
|
id: fragmentId
|
|
2625
2651
|
}),
|
|
2626
2652
|
headers: {
|
|
@@ -2630,7 +2656,7 @@ function useRemoveFragment(username, fragmentId) {
|
|
|
2630
2656
|
},
|
|
2631
2657
|
onSuccess() {
|
|
2632
2658
|
getQueryClient().setQueryData(
|
|
2633
|
-
getFragmentsQueryOptions(username).queryKey,
|
|
2659
|
+
getFragmentsQueryOptions(username, code).queryKey,
|
|
2634
2660
|
(data) => [...data ?? []].filter(({ id }) => id !== fragmentId)
|
|
2635
2661
|
);
|
|
2636
2662
|
}
|
|
@@ -2749,11 +2775,10 @@ var queries_exports = {};
|
|
|
2749
2775
|
__export(queries_exports, {
|
|
2750
2776
|
getDecodeMemoQueryOptions: () => getDecodeMemoQueryOptions
|
|
2751
2777
|
});
|
|
2752
|
-
function getDecodeMemoQueryOptions(username, memo) {
|
|
2778
|
+
function getDecodeMemoQueryOptions(username, memo, accessToken) {
|
|
2753
2779
|
return queryOptions({
|
|
2754
2780
|
queryKey: ["integrations", "hivesigner", "decode-memo", username],
|
|
2755
2781
|
queryFn: async () => {
|
|
2756
|
-
const accessToken = getAccessToken(username);
|
|
2757
2782
|
if (accessToken) {
|
|
2758
2783
|
const hsClient = new hs.Client({
|
|
2759
2784
|
accessToken
|
|
@@ -2770,12 +2795,12 @@ var HiveSignerIntegration = {
|
|
|
2770
2795
|
};
|
|
2771
2796
|
|
|
2772
2797
|
// src/modules/integrations/3speak/queries/get-account-token-query-options.ts
|
|
2773
|
-
function getAccountTokenQueryOptions(username) {
|
|
2798
|
+
function getAccountTokenQueryOptions(username, accessToken) {
|
|
2774
2799
|
return queryOptions({
|
|
2775
2800
|
queryKey: ["integrations", "3speak", "authenticate", username],
|
|
2776
|
-
enabled: !!username,
|
|
2801
|
+
enabled: !!username && !!accessToken,
|
|
2777
2802
|
queryFn: async () => {
|
|
2778
|
-
if (!username) {
|
|
2803
|
+
if (!username || !accessToken) {
|
|
2779
2804
|
throw new Error("[SDK][Integrations][3Speak] \u2013\xA0anon user");
|
|
2780
2805
|
}
|
|
2781
2806
|
const fetchApi = getBoundFetch();
|
|
@@ -2789,7 +2814,8 @@ function getAccountTokenQueryOptions(username) {
|
|
|
2789
2814
|
);
|
|
2790
2815
|
const memoQueryOptions = HiveSignerIntegration.queries.getDecodeMemoQueryOptions(
|
|
2791
2816
|
username,
|
|
2792
|
-
(await response.json()).memo
|
|
2817
|
+
(await response.json()).memo,
|
|
2818
|
+
accessToken
|
|
2793
2819
|
);
|
|
2794
2820
|
await getQueryClient().prefetchQuery(memoQueryOptions);
|
|
2795
2821
|
const { memoDecoded } = getQueryClient().getQueryData(
|
|
@@ -2799,17 +2825,23 @@ function getAccountTokenQueryOptions(username) {
|
|
|
2799
2825
|
}
|
|
2800
2826
|
});
|
|
2801
2827
|
}
|
|
2802
|
-
function getAccountVideosQueryOptions(username) {
|
|
2828
|
+
function getAccountVideosQueryOptions(username, accessToken) {
|
|
2803
2829
|
return queryOptions({
|
|
2804
2830
|
queryKey: ["integrations", "3speak", "videos", username],
|
|
2805
|
-
enabled: !!username,
|
|
2831
|
+
enabled: !!username && !!accessToken,
|
|
2806
2832
|
queryFn: async () => {
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
const
|
|
2811
|
-
|
|
2833
|
+
if (!username || !accessToken) {
|
|
2834
|
+
throw new Error("[SDK][Integrations][3Speak] \u2013\xA0anon user");
|
|
2835
|
+
}
|
|
2836
|
+
const tokenQueryOptions = getAccountTokenQueryOptions(
|
|
2837
|
+
username,
|
|
2838
|
+
accessToken
|
|
2812
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
|
+
}
|
|
2813
2845
|
const fetchApi = getBoundFetch();
|
|
2814
2846
|
const response = await fetchApi(
|
|
2815
2847
|
`https://studio.3speak.tv/mobile/api/my-videos`,
|
|
@@ -2920,13 +2952,13 @@ function getAccountRcQueryOptions(username) {
|
|
|
2920
2952
|
enabled: !!username
|
|
2921
2953
|
});
|
|
2922
2954
|
}
|
|
2923
|
-
function getGameStatusCheckQueryOptions(username, gameType) {
|
|
2955
|
+
function getGameStatusCheckQueryOptions(username, code, gameType) {
|
|
2924
2956
|
return queryOptions({
|
|
2925
2957
|
queryKey: ["games", "status-check", gameType, username],
|
|
2926
|
-
enabled: !!username,
|
|
2958
|
+
enabled: !!username && !!code,
|
|
2927
2959
|
queryFn: async () => {
|
|
2928
|
-
if (!username) {
|
|
2929
|
-
throw new Error("[SDK][Games] \u2013
|
|
2960
|
+
if (!username || !code) {
|
|
2961
|
+
throw new Error("[SDK][Games] \u2013 missing auth");
|
|
2930
2962
|
}
|
|
2931
2963
|
const fetchApi = getBoundFetch();
|
|
2932
2964
|
const response = await fetchApi(
|
|
@@ -2935,7 +2967,7 @@ function getGameStatusCheckQueryOptions(username, gameType) {
|
|
|
2935
2967
|
method: "POST",
|
|
2936
2968
|
body: JSON.stringify({
|
|
2937
2969
|
game_type: gameType,
|
|
2938
|
-
code
|
|
2970
|
+
code
|
|
2939
2971
|
}),
|
|
2940
2972
|
headers: {
|
|
2941
2973
|
"Content-Type": "application/json"
|
|
@@ -2946,7 +2978,7 @@ function getGameStatusCheckQueryOptions(username, gameType) {
|
|
|
2946
2978
|
}
|
|
2947
2979
|
});
|
|
2948
2980
|
}
|
|
2949
|
-
function useGameClaim(username, gameType, key) {
|
|
2981
|
+
function useGameClaim(username, code, gameType, key) {
|
|
2950
2982
|
const { mutateAsync: recordActivity } = useRecordActivity(
|
|
2951
2983
|
username,
|
|
2952
2984
|
"spin-rolled"
|
|
@@ -2954,8 +2986,8 @@ function useGameClaim(username, gameType, key) {
|
|
|
2954
2986
|
return useMutation({
|
|
2955
2987
|
mutationKey: ["games", "post", gameType, username],
|
|
2956
2988
|
mutationFn: async () => {
|
|
2957
|
-
if (!username) {
|
|
2958
|
-
throw new Error("[SDK][Games] \u2013
|
|
2989
|
+
if (!username || !code) {
|
|
2990
|
+
throw new Error("[SDK][Games] \u2013 missing auth");
|
|
2959
2991
|
}
|
|
2960
2992
|
const fetchApi = getBoundFetch();
|
|
2961
2993
|
const response = await fetchApi(
|
|
@@ -2964,7 +2996,7 @@ function useGameClaim(username, gameType, key) {
|
|
|
2964
2996
|
method: "POST",
|
|
2965
2997
|
body: JSON.stringify({
|
|
2966
2998
|
game_type: gameType,
|
|
2967
|
-
code
|
|
2999
|
+
code,
|
|
2968
3000
|
key
|
|
2969
3001
|
}),
|
|
2970
3002
|
headers: {
|
|
@@ -3129,15 +3161,18 @@ function getCommunityPermissions({
|
|
|
3129
3161
|
isModerator
|
|
3130
3162
|
};
|
|
3131
3163
|
}
|
|
3132
|
-
function getNotificationsUnreadCountQueryOptions(activeUsername) {
|
|
3164
|
+
function getNotificationsUnreadCountQueryOptions(activeUsername, code) {
|
|
3133
3165
|
return queryOptions({
|
|
3134
3166
|
queryKey: ["notifications", "unread", activeUsername],
|
|
3135
3167
|
queryFn: async () => {
|
|
3168
|
+
if (!code) {
|
|
3169
|
+
return 0;
|
|
3170
|
+
}
|
|
3136
3171
|
const response = await fetch(
|
|
3137
3172
|
`${CONFIG.privateApiHost}/private-api/notifications/unread`,
|
|
3138
3173
|
{
|
|
3139
3174
|
method: "POST",
|
|
3140
|
-
body: JSON.stringify({ code
|
|
3175
|
+
body: JSON.stringify({ code }),
|
|
3141
3176
|
headers: {
|
|
3142
3177
|
"Content-Type": "application/json"
|
|
3143
3178
|
}
|
|
@@ -3146,17 +3181,20 @@ function getNotificationsUnreadCountQueryOptions(activeUsername) {
|
|
|
3146
3181
|
const data = await response.json();
|
|
3147
3182
|
return data.count;
|
|
3148
3183
|
},
|
|
3149
|
-
enabled: !!activeUsername,
|
|
3184
|
+
enabled: !!activeUsername && !!code,
|
|
3150
3185
|
initialData: 0,
|
|
3151
3186
|
refetchInterval: 6e4
|
|
3152
3187
|
});
|
|
3153
3188
|
}
|
|
3154
|
-
function getNotificationsInfiniteQueryOptions(activeUsername, filter = void 0) {
|
|
3189
|
+
function getNotificationsInfiniteQueryOptions(activeUsername, code, filter = void 0) {
|
|
3155
3190
|
return infiniteQueryOptions({
|
|
3156
3191
|
queryKey: ["notifications", activeUsername, filter],
|
|
3157
3192
|
queryFn: async ({ pageParam }) => {
|
|
3193
|
+
if (!code) {
|
|
3194
|
+
return [];
|
|
3195
|
+
}
|
|
3158
3196
|
const data = {
|
|
3159
|
-
code
|
|
3197
|
+
code,
|
|
3160
3198
|
filter,
|
|
3161
3199
|
since: pageParam,
|
|
3162
3200
|
user: void 0
|
|
@@ -3173,7 +3211,7 @@ function getNotificationsInfiniteQueryOptions(activeUsername, filter = void 0) {
|
|
|
3173
3211
|
);
|
|
3174
3212
|
return response.json();
|
|
3175
3213
|
},
|
|
3176
|
-
enabled: !!activeUsername,
|
|
3214
|
+
enabled: !!activeUsername && !!code,
|
|
3177
3215
|
initialData: { pages: [], pageParams: [] },
|
|
3178
3216
|
initialPageParam: "",
|
|
3179
3217
|
getNextPageParam: (lastPage) => lastPage?.[lastPage.length - 1]?.id ?? "",
|
|
@@ -3226,16 +3264,19 @@ var NotificationViewType = /* @__PURE__ */ ((NotificationViewType2) => {
|
|
|
3226
3264
|
})(NotificationViewType || {});
|
|
3227
3265
|
|
|
3228
3266
|
// src/modules/notifications/queries/get-notifications-settings-query-options.ts
|
|
3229
|
-
function getNotificationsSettingsQueryOptions(activeUsername) {
|
|
3267
|
+
function getNotificationsSettingsQueryOptions(activeUsername, code) {
|
|
3230
3268
|
return queryOptions({
|
|
3231
3269
|
queryKey: ["notifications", "settings", activeUsername],
|
|
3232
3270
|
queryFn: async () => {
|
|
3233
3271
|
let token = activeUsername + "-web";
|
|
3272
|
+
if (!code) {
|
|
3273
|
+
throw new Error("Missing access token");
|
|
3274
|
+
}
|
|
3234
3275
|
const response = await fetch(
|
|
3235
3276
|
CONFIG.privateApiHost + "/private-api/detail-device",
|
|
3236
3277
|
{
|
|
3237
3278
|
body: JSON.stringify({
|
|
3238
|
-
code
|
|
3279
|
+
code,
|
|
3239
3280
|
username: activeUsername,
|
|
3240
3281
|
token
|
|
3241
3282
|
}),
|
|
@@ -3250,7 +3291,7 @@ function getNotificationsSettingsQueryOptions(activeUsername) {
|
|
|
3250
3291
|
}
|
|
3251
3292
|
return response.json();
|
|
3252
3293
|
},
|
|
3253
|
-
enabled: !!activeUsername,
|
|
3294
|
+
enabled: !!activeUsername && !!code,
|
|
3254
3295
|
refetchOnMount: false,
|
|
3255
3296
|
initialData: () => {
|
|
3256
3297
|
const wasMutedPreviously = typeof window !== "undefined" ? localStorage.getItem("notifications") !== "true" : false;
|
|
@@ -3544,8 +3585,9 @@ function getMarketDataQueryOptions(coin, vsCurrency, fromTs, toTs) {
|
|
|
3544
3585
|
return queryOptions({
|
|
3545
3586
|
queryKey: ["market", "data", coin, vsCurrency, fromTs, toTs],
|
|
3546
3587
|
queryFn: async ({ signal }) => {
|
|
3588
|
+
const fetchApi = getBoundFetch();
|
|
3547
3589
|
const url = `https://api.coingecko.com/api/v3/coins/${coin}/market_chart/range?vs_currency=${vsCurrency}&from=${fromTs}&to=${toTs}`;
|
|
3548
|
-
const response = await
|
|
3590
|
+
const response = await fetchApi(url, { signal });
|
|
3549
3591
|
if (!response.ok) {
|
|
3550
3592
|
throw new Error(`Failed to fetch market data: ${response.status}`);
|
|
3551
3593
|
}
|
|
@@ -3553,6 +3595,46 @@ function getMarketDataQueryOptions(coin, vsCurrency, fromTs, toTs) {
|
|
|
3553
3595
|
}
|
|
3554
3596
|
});
|
|
3555
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
|
+
}
|
|
3556
3638
|
function getPointsQueryOptions(username, filter = 0) {
|
|
3557
3639
|
return queryOptions({
|
|
3558
3640
|
queryKey: ["points", username, filter],
|
|
@@ -3893,6 +3975,311 @@ function getBoostPlusAccountPricesQueryOptions(account, accessToken) {
|
|
|
3893
3975
|
});
|
|
3894
3976
|
}
|
|
3895
3977
|
|
|
3896
|
-
|
|
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 };
|
|
3897
4284
|
//# sourceMappingURL=index.mjs.map
|
|
3898
4285
|
//# sourceMappingURL=index.mjs.map
|