@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/browser/index.js
CHANGED
|
@@ -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) {
|
|
@@ -263,143 +403,6 @@ var getAccessToken = (username) => getUser(username) && getUser(username).access
|
|
|
263
403
|
var getPostingKey = (username) => getUser(username) && getUser(username).postingKey;
|
|
264
404
|
var getLoginType = (username) => getUser(username) && getUser(username).loginType;
|
|
265
405
|
var getRefreshToken = (username) => getUser(username) && getUser(username).refreshToken;
|
|
266
|
-
|
|
267
|
-
// src/modules/keychain/keychain.ts
|
|
268
|
-
var keychain_exports = {};
|
|
269
|
-
__export(keychain_exports, {
|
|
270
|
-
broadcast: () => broadcast,
|
|
271
|
-
customJson: () => customJson,
|
|
272
|
-
handshake: () => handshake
|
|
273
|
-
});
|
|
274
|
-
function handshake() {
|
|
275
|
-
return new Promise((resolve) => {
|
|
276
|
-
window.hive_keychain?.requestHandshake(() => {
|
|
277
|
-
resolve();
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
var broadcast = (account, operations, key, rpc = null) => new Promise((resolve, reject) => {
|
|
282
|
-
window.hive_keychain?.requestBroadcast(
|
|
283
|
-
account,
|
|
284
|
-
operations,
|
|
285
|
-
key,
|
|
286
|
-
(resp) => {
|
|
287
|
-
if (!resp.success) {
|
|
288
|
-
reject({ message: "Operation cancelled" });
|
|
289
|
-
}
|
|
290
|
-
resolve(resp);
|
|
291
|
-
},
|
|
292
|
-
rpc
|
|
293
|
-
);
|
|
294
|
-
});
|
|
295
|
-
var customJson = (account, id, key, json, display_msg, rpc = null) => new Promise((resolve, reject) => {
|
|
296
|
-
window.hive_keychain?.requestCustomJson(
|
|
297
|
-
account,
|
|
298
|
-
id,
|
|
299
|
-
key,
|
|
300
|
-
json,
|
|
301
|
-
display_msg,
|
|
302
|
-
(resp) => {
|
|
303
|
-
if (!resp.success) {
|
|
304
|
-
reject({ message: "Operation cancelled" });
|
|
305
|
-
}
|
|
306
|
-
resolve(resp);
|
|
307
|
-
},
|
|
308
|
-
rpc
|
|
309
|
-
);
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
// src/modules/core/mutations/use-broadcast-mutation.ts
|
|
313
|
-
function useBroadcastMutation(mutationKey = [], username, operations, onSuccess = () => {
|
|
314
|
-
}) {
|
|
315
|
-
return useMutation({
|
|
316
|
-
onSuccess,
|
|
317
|
-
mutationKey: [...mutationKey, username],
|
|
318
|
-
mutationFn: async (payload) => {
|
|
319
|
-
if (!username) {
|
|
320
|
-
throw new Error(
|
|
321
|
-
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
const postingKey = getPostingKey(username);
|
|
325
|
-
if (postingKey) {
|
|
326
|
-
const privateKey = PrivateKey.fromString(postingKey);
|
|
327
|
-
return CONFIG.hiveClient.broadcast.sendOperations(
|
|
328
|
-
operations(payload),
|
|
329
|
-
privateKey
|
|
330
|
-
);
|
|
331
|
-
}
|
|
332
|
-
const loginType = getLoginType(username);
|
|
333
|
-
if (loginType && loginType == "keychain") {
|
|
334
|
-
return keychain_exports.broadcast(
|
|
335
|
-
username,
|
|
336
|
-
operations(payload),
|
|
337
|
-
"Posting"
|
|
338
|
-
).then((r) => r.result);
|
|
339
|
-
}
|
|
340
|
-
let token = getAccessToken(username);
|
|
341
|
-
if (token) {
|
|
342
|
-
const f = getBoundFetch();
|
|
343
|
-
const res = await f("https://hivesigner.com/api/broadcast", {
|
|
344
|
-
method: "POST",
|
|
345
|
-
headers: {
|
|
346
|
-
Authorization: token,
|
|
347
|
-
"Content-Type": "application/json",
|
|
348
|
-
Accept: "application/json"
|
|
349
|
-
},
|
|
350
|
-
body: JSON.stringify({ operations: operations(payload) })
|
|
351
|
-
});
|
|
352
|
-
if (!res.ok) {
|
|
353
|
-
const txt = await res.text().catch(() => "");
|
|
354
|
-
throw new Error(`[Hivesigner] ${res.status} ${res.statusText} ${txt}`);
|
|
355
|
-
}
|
|
356
|
-
const json = await res.json();
|
|
357
|
-
if (json?.errors) {
|
|
358
|
-
throw new Error(`[Hivesigner] ${JSON.stringify(json.errors)}`);
|
|
359
|
-
}
|
|
360
|
-
return json.result;
|
|
361
|
-
}
|
|
362
|
-
throw new Error(
|
|
363
|
-
"[SDK][Broadcast] \u2013 cannot broadcast w/o posting key or token"
|
|
364
|
-
);
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
async function broadcastJson(username, id, payload) {
|
|
369
|
-
if (!username) {
|
|
370
|
-
throw new Error(
|
|
371
|
-
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
const jjson = {
|
|
375
|
-
id,
|
|
376
|
-
required_auths: [],
|
|
377
|
-
required_posting_auths: [username],
|
|
378
|
-
json: JSON.stringify(payload)
|
|
379
|
-
};
|
|
380
|
-
const postingKey = getPostingKey(username);
|
|
381
|
-
if (postingKey) {
|
|
382
|
-
const privateKey = PrivateKey.fromString(postingKey);
|
|
383
|
-
return CONFIG.hiveClient.broadcast.json(
|
|
384
|
-
jjson,
|
|
385
|
-
privateKey
|
|
386
|
-
);
|
|
387
|
-
}
|
|
388
|
-
const loginType = getLoginType(username);
|
|
389
|
-
if (loginType && loginType == "keychain") {
|
|
390
|
-
return keychain_exports.broadcast(username, [["custom_json", jjson]], "Posting").then((r) => r.result);
|
|
391
|
-
}
|
|
392
|
-
let token = getAccessToken(username);
|
|
393
|
-
if (token) {
|
|
394
|
-
const response = await new hs.Client({
|
|
395
|
-
accessToken: token
|
|
396
|
-
}).customJson([], [username], id, JSON.stringify(payload));
|
|
397
|
-
return response.result;
|
|
398
|
-
}
|
|
399
|
-
throw new Error(
|
|
400
|
-
"[SDK][Broadcast] \u2013 cannot broadcast w/o posting key or token"
|
|
401
|
-
);
|
|
402
|
-
}
|
|
403
406
|
function makeQueryClient() {
|
|
404
407
|
return new QueryClient({
|
|
405
408
|
defaultOptions: {
|
|
@@ -907,13 +910,13 @@ function getAccountSubscriptionsQueryOptions(username) {
|
|
|
907
910
|
}
|
|
908
911
|
});
|
|
909
912
|
}
|
|
910
|
-
function getActiveAccountBookmarksQueryOptions(activeUsername) {
|
|
913
|
+
function getActiveAccountBookmarksQueryOptions(activeUsername, code) {
|
|
911
914
|
return queryOptions({
|
|
912
915
|
queryKey: ["accounts", "bookmarks", activeUsername],
|
|
913
|
-
enabled: !!activeUsername,
|
|
916
|
+
enabled: !!activeUsername && !!code,
|
|
914
917
|
queryFn: async () => {
|
|
915
|
-
if (!activeUsername) {
|
|
916
|
-
throw new Error("[SDK][Accounts][Bookmarks] \u2013
|
|
918
|
+
if (!activeUsername || !code) {
|
|
919
|
+
throw new Error("[SDK][Accounts][Bookmarks] \u2013 missing auth");
|
|
917
920
|
}
|
|
918
921
|
const fetchApi = getBoundFetch();
|
|
919
922
|
const response = await fetchApi(
|
|
@@ -923,20 +926,20 @@ function getActiveAccountBookmarksQueryOptions(activeUsername) {
|
|
|
923
926
|
headers: {
|
|
924
927
|
"Content-Type": "application/json"
|
|
925
928
|
},
|
|
926
|
-
body: JSON.stringify({ code
|
|
929
|
+
body: JSON.stringify({ code })
|
|
927
930
|
}
|
|
928
931
|
);
|
|
929
932
|
return await response.json();
|
|
930
933
|
}
|
|
931
934
|
});
|
|
932
935
|
}
|
|
933
|
-
function getActiveAccountFavouritesQueryOptions(activeUsername) {
|
|
936
|
+
function getActiveAccountFavouritesQueryOptions(activeUsername, code) {
|
|
934
937
|
return queryOptions({
|
|
935
938
|
queryKey: ["accounts", "favourites", activeUsername],
|
|
936
|
-
enabled: !!activeUsername,
|
|
939
|
+
enabled: !!activeUsername && !!code,
|
|
937
940
|
queryFn: async () => {
|
|
938
|
-
if (!activeUsername) {
|
|
939
|
-
throw new Error("[SDK][Accounts][Favourites] \u2013
|
|
941
|
+
if (!activeUsername || !code) {
|
|
942
|
+
throw new Error("[SDK][Accounts][Favourites] \u2013 missing auth");
|
|
940
943
|
}
|
|
941
944
|
const fetchApi = getBoundFetch();
|
|
942
945
|
const response = await fetchApi(
|
|
@@ -946,18 +949,21 @@ function getActiveAccountFavouritesQueryOptions(activeUsername) {
|
|
|
946
949
|
headers: {
|
|
947
950
|
"Content-Type": "application/json"
|
|
948
951
|
},
|
|
949
|
-
body: JSON.stringify({ code
|
|
952
|
+
body: JSON.stringify({ code })
|
|
950
953
|
}
|
|
951
954
|
);
|
|
952
955
|
return await response.json();
|
|
953
956
|
}
|
|
954
957
|
});
|
|
955
958
|
}
|
|
956
|
-
function getAccountRecoveriesQueryOptions(username) {
|
|
959
|
+
function getAccountRecoveriesQueryOptions(username, code) {
|
|
957
960
|
return queryOptions({
|
|
958
|
-
enabled: !!username,
|
|
961
|
+
enabled: !!username && !!code,
|
|
959
962
|
queryKey: ["accounts", "recoveries", username],
|
|
960
963
|
queryFn: async () => {
|
|
964
|
+
if (!username || !code) {
|
|
965
|
+
throw new Error("[SDK][Accounts] Missing username or access token");
|
|
966
|
+
}
|
|
961
967
|
const fetchApi = getBoundFetch();
|
|
962
968
|
const response = await fetchApi(
|
|
963
969
|
CONFIG.privateApiHost + "/private-api/recoveries",
|
|
@@ -966,7 +972,7 @@ function getAccountRecoveriesQueryOptions(username) {
|
|
|
966
972
|
headers: {
|
|
967
973
|
"Content-Type": "application/json"
|
|
968
974
|
},
|
|
969
|
-
body: JSON.stringify({ code
|
|
975
|
+
body: JSON.stringify({ code })
|
|
970
976
|
}
|
|
971
977
|
);
|
|
972
978
|
return response.json();
|
|
@@ -1241,17 +1247,20 @@ function getTrendingTagsWithStatsQueryOptions(limit = 250) {
|
|
|
1241
1247
|
refetchOnMount: true
|
|
1242
1248
|
});
|
|
1243
1249
|
}
|
|
1244
|
-
function getFragmentsQueryOptions(username) {
|
|
1250
|
+
function getFragmentsQueryOptions(username, code) {
|
|
1245
1251
|
return queryOptions({
|
|
1246
1252
|
queryKey: ["posts", "fragments", username],
|
|
1247
1253
|
queryFn: async () => {
|
|
1254
|
+
if (!code) {
|
|
1255
|
+
return [];
|
|
1256
|
+
}
|
|
1248
1257
|
const fetchApi = getBoundFetch();
|
|
1249
1258
|
const response = await fetchApi(
|
|
1250
1259
|
CONFIG.privateApiHost + "/private-api/fragments",
|
|
1251
1260
|
{
|
|
1252
1261
|
method: "POST",
|
|
1253
1262
|
body: JSON.stringify({
|
|
1254
|
-
code
|
|
1263
|
+
code
|
|
1255
1264
|
}),
|
|
1256
1265
|
headers: {
|
|
1257
1266
|
"Content-Type": "application/json"
|
|
@@ -1260,7 +1269,7 @@ function getFragmentsQueryOptions(username) {
|
|
|
1260
1269
|
);
|
|
1261
1270
|
return response.json();
|
|
1262
1271
|
},
|
|
1263
|
-
enabled: !!username
|
|
1272
|
+
enabled: !!username && !!code
|
|
1264
1273
|
});
|
|
1265
1274
|
}
|
|
1266
1275
|
function getPromotedPostsQuery(type = "feed") {
|
|
@@ -1567,20 +1576,21 @@ function getReblogsQueryOptions(username, activeUsername, limit = 200) {
|
|
|
1567
1576
|
enabled: !!username
|
|
1568
1577
|
});
|
|
1569
1578
|
}
|
|
1570
|
-
function getSchedulesQueryOptions(activeUsername) {
|
|
1579
|
+
function getSchedulesQueryOptions(activeUsername, code) {
|
|
1571
1580
|
return queryOptions({
|
|
1572
1581
|
queryKey: ["posts", "schedules", activeUsername],
|
|
1573
1582
|
queryFn: async () => {
|
|
1574
|
-
if (!activeUsername) {
|
|
1583
|
+
if (!activeUsername || !code) {
|
|
1575
1584
|
return [];
|
|
1576
1585
|
}
|
|
1577
|
-
const
|
|
1586
|
+
const fetchApi = getBoundFetch();
|
|
1587
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/schedules", {
|
|
1578
1588
|
method: "POST",
|
|
1579
1589
|
headers: {
|
|
1580
1590
|
"Content-Type": "application/json"
|
|
1581
1591
|
},
|
|
1582
1592
|
body: JSON.stringify({
|
|
1583
|
-
code
|
|
1593
|
+
code
|
|
1584
1594
|
})
|
|
1585
1595
|
});
|
|
1586
1596
|
if (!response.ok) {
|
|
@@ -1588,23 +1598,24 @@ function getSchedulesQueryOptions(activeUsername) {
|
|
|
1588
1598
|
}
|
|
1589
1599
|
return response.json();
|
|
1590
1600
|
},
|
|
1591
|
-
enabled: !!activeUsername
|
|
1601
|
+
enabled: !!activeUsername && !!code
|
|
1592
1602
|
});
|
|
1593
1603
|
}
|
|
1594
|
-
function getDraftsQueryOptions(activeUsername) {
|
|
1604
|
+
function getDraftsQueryOptions(activeUsername, code) {
|
|
1595
1605
|
return queryOptions({
|
|
1596
1606
|
queryKey: ["posts", "drafts", activeUsername],
|
|
1597
1607
|
queryFn: async () => {
|
|
1598
|
-
if (!activeUsername) {
|
|
1608
|
+
if (!activeUsername || !code) {
|
|
1599
1609
|
return [];
|
|
1600
1610
|
}
|
|
1601
|
-
const
|
|
1611
|
+
const fetchApi = getBoundFetch();
|
|
1612
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/drafts", {
|
|
1602
1613
|
method: "POST",
|
|
1603
1614
|
headers: {
|
|
1604
1615
|
"Content-Type": "application/json"
|
|
1605
1616
|
},
|
|
1606
1617
|
body: JSON.stringify({
|
|
1607
|
-
code
|
|
1618
|
+
code
|
|
1608
1619
|
})
|
|
1609
1620
|
});
|
|
1610
1621
|
if (!response.ok) {
|
|
@@ -1612,17 +1623,18 @@ function getDraftsQueryOptions(activeUsername) {
|
|
|
1612
1623
|
}
|
|
1613
1624
|
return response.json();
|
|
1614
1625
|
},
|
|
1615
|
-
enabled: !!activeUsername
|
|
1626
|
+
enabled: !!activeUsername && !!code
|
|
1616
1627
|
});
|
|
1617
1628
|
}
|
|
1618
|
-
async function fetchUserImages(
|
|
1619
|
-
const
|
|
1629
|
+
async function fetchUserImages(code) {
|
|
1630
|
+
const fetchApi = getBoundFetch();
|
|
1631
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/images", {
|
|
1620
1632
|
method: "POST",
|
|
1621
1633
|
headers: {
|
|
1622
1634
|
"Content-Type": "application/json"
|
|
1623
1635
|
},
|
|
1624
1636
|
body: JSON.stringify({
|
|
1625
|
-
code
|
|
1637
|
+
code
|
|
1626
1638
|
})
|
|
1627
1639
|
});
|
|
1628
1640
|
if (!response.ok) {
|
|
@@ -1630,28 +1642,28 @@ async function fetchUserImages(username) {
|
|
|
1630
1642
|
}
|
|
1631
1643
|
return response.json();
|
|
1632
1644
|
}
|
|
1633
|
-
function getImagesQueryOptions(username) {
|
|
1645
|
+
function getImagesQueryOptions(username, code) {
|
|
1634
1646
|
return queryOptions({
|
|
1635
1647
|
queryKey: ["posts", "images", username],
|
|
1636
1648
|
queryFn: async () => {
|
|
1637
|
-
if (!username) {
|
|
1649
|
+
if (!username || !code) {
|
|
1638
1650
|
return [];
|
|
1639
1651
|
}
|
|
1640
|
-
return fetchUserImages(
|
|
1652
|
+
return fetchUserImages(code);
|
|
1641
1653
|
},
|
|
1642
|
-
enabled: !!username
|
|
1654
|
+
enabled: !!username && !!code
|
|
1643
1655
|
});
|
|
1644
1656
|
}
|
|
1645
|
-
function getGalleryImagesQueryOptions(activeUsername) {
|
|
1657
|
+
function getGalleryImagesQueryOptions(activeUsername, code) {
|
|
1646
1658
|
return queryOptions({
|
|
1647
1659
|
queryKey: ["posts", "gallery-images", activeUsername],
|
|
1648
1660
|
queryFn: async () => {
|
|
1649
|
-
if (!activeUsername) {
|
|
1661
|
+
if (!activeUsername || !code) {
|
|
1650
1662
|
return [];
|
|
1651
1663
|
}
|
|
1652
|
-
return fetchUserImages(
|
|
1664
|
+
return fetchUserImages(code);
|
|
1653
1665
|
},
|
|
1654
|
-
enabled: !!activeUsername
|
|
1666
|
+
enabled: !!activeUsername && !!code
|
|
1655
1667
|
});
|
|
1656
1668
|
}
|
|
1657
1669
|
function getCommentHistoryQueryOptions(author, permlink, onlyMeta = false) {
|
|
@@ -2047,12 +2059,13 @@ function getAccountVoteHistoryInfiniteQueryOptions(username, options) {
|
|
|
2047
2059
|
}
|
|
2048
2060
|
|
|
2049
2061
|
// src/modules/accounts/mutations/use-account-update.ts
|
|
2050
|
-
function useAccountUpdate(username) {
|
|
2062
|
+
function useAccountUpdate(username, accessToken, auth) {
|
|
2051
2063
|
const queryClient = useQueryClient();
|
|
2052
2064
|
const { data } = useQuery(getAccountFullQueryOptions(username));
|
|
2053
2065
|
return useBroadcastMutation(
|
|
2054
2066
|
["accounts", "update"],
|
|
2055
2067
|
username,
|
|
2068
|
+
accessToken,
|
|
2056
2069
|
(payload) => {
|
|
2057
2070
|
if (!data) {
|
|
2058
2071
|
throw new Error("[SDK][Accounts] \u2013 cannot update not existing account");
|
|
@@ -2076,7 +2089,7 @@ function useAccountUpdate(username) {
|
|
|
2076
2089
|
]
|
|
2077
2090
|
];
|
|
2078
2091
|
},
|
|
2079
|
-
(
|
|
2092
|
+
(_data, variables) => queryClient.setQueryData(
|
|
2080
2093
|
getAccountFullQueryOptions(username).queryKey,
|
|
2081
2094
|
(data2) => {
|
|
2082
2095
|
if (!data2) {
|
|
@@ -2090,7 +2103,8 @@ function useAccountUpdate(username) {
|
|
|
2090
2103
|
});
|
|
2091
2104
|
return obj;
|
|
2092
2105
|
}
|
|
2093
|
-
)
|
|
2106
|
+
),
|
|
2107
|
+
auth
|
|
2094
2108
|
);
|
|
2095
2109
|
}
|
|
2096
2110
|
function useAccountRelationsUpdate(reference, target, onSuccess, onError) {
|
|
@@ -2132,12 +2146,12 @@ function useAccountRelationsUpdate(reference, target, onSuccess, onError) {
|
|
|
2132
2146
|
}
|
|
2133
2147
|
});
|
|
2134
2148
|
}
|
|
2135
|
-
function useBookmarkAdd(username, onSuccess, onError) {
|
|
2149
|
+
function useBookmarkAdd(username, code, onSuccess, onError) {
|
|
2136
2150
|
return useMutation({
|
|
2137
2151
|
mutationKey: ["accounts", "bookmarks", "add", username],
|
|
2138
2152
|
mutationFn: async ({ author, permlink }) => {
|
|
2139
|
-
if (!username) {
|
|
2140
|
-
throw new Error("[SDK][Account][Bookmarks] \u2013
|
|
2153
|
+
if (!username || !code) {
|
|
2154
|
+
throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
|
|
2141
2155
|
}
|
|
2142
2156
|
const fetchApi = getBoundFetch();
|
|
2143
2157
|
const response = await fetchApi(
|
|
@@ -2150,7 +2164,7 @@ function useBookmarkAdd(username, onSuccess, onError) {
|
|
|
2150
2164
|
body: JSON.stringify({
|
|
2151
2165
|
author,
|
|
2152
2166
|
permlink,
|
|
2153
|
-
code
|
|
2167
|
+
code
|
|
2154
2168
|
})
|
|
2155
2169
|
}
|
|
2156
2170
|
);
|
|
@@ -2165,12 +2179,12 @@ function useBookmarkAdd(username, onSuccess, onError) {
|
|
|
2165
2179
|
onError
|
|
2166
2180
|
});
|
|
2167
2181
|
}
|
|
2168
|
-
function useBookmarkDelete(username, onSuccess, onError) {
|
|
2182
|
+
function useBookmarkDelete(username, code, onSuccess, onError) {
|
|
2169
2183
|
return useMutation({
|
|
2170
2184
|
mutationKey: ["accounts", "bookmarks", "delete", username],
|
|
2171
2185
|
mutationFn: async (bookmarkId) => {
|
|
2172
|
-
if (!username) {
|
|
2173
|
-
throw new Error("[SDK][Account][Bookmarks] \u2013
|
|
2186
|
+
if (!username || !code) {
|
|
2187
|
+
throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
|
|
2174
2188
|
}
|
|
2175
2189
|
const fetchApi = getBoundFetch();
|
|
2176
2190
|
const response = await fetchApi(
|
|
@@ -2182,7 +2196,7 @@ function useBookmarkDelete(username, onSuccess, onError) {
|
|
|
2182
2196
|
},
|
|
2183
2197
|
body: JSON.stringify({
|
|
2184
2198
|
id: bookmarkId,
|
|
2185
|
-
code
|
|
2199
|
+
code
|
|
2186
2200
|
})
|
|
2187
2201
|
}
|
|
2188
2202
|
);
|
|
@@ -2197,12 +2211,12 @@ function useBookmarkDelete(username, onSuccess, onError) {
|
|
|
2197
2211
|
onError
|
|
2198
2212
|
});
|
|
2199
2213
|
}
|
|
2200
|
-
function useAccountFavouriteAdd(username, onSuccess, onError) {
|
|
2214
|
+
function useAccountFavouriteAdd(username, code, onSuccess, onError) {
|
|
2201
2215
|
return useMutation({
|
|
2202
2216
|
mutationKey: ["accounts", "favourites", "add", username],
|
|
2203
2217
|
mutationFn: async (account) => {
|
|
2204
|
-
if (!username) {
|
|
2205
|
-
throw new Error("[SDK][Account][Bookmarks] \u2013
|
|
2218
|
+
if (!username || !code) {
|
|
2219
|
+
throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
|
|
2206
2220
|
}
|
|
2207
2221
|
const fetchApi = getBoundFetch();
|
|
2208
2222
|
const response = await fetchApi(
|
|
@@ -2214,7 +2228,7 @@ function useAccountFavouriteAdd(username, onSuccess, onError) {
|
|
|
2214
2228
|
},
|
|
2215
2229
|
body: JSON.stringify({
|
|
2216
2230
|
account,
|
|
2217
|
-
code
|
|
2231
|
+
code
|
|
2218
2232
|
})
|
|
2219
2233
|
}
|
|
2220
2234
|
);
|
|
@@ -2229,12 +2243,12 @@ function useAccountFavouriteAdd(username, onSuccess, onError) {
|
|
|
2229
2243
|
onError
|
|
2230
2244
|
});
|
|
2231
2245
|
}
|
|
2232
|
-
function useAccountFavouriteDelete(username, onSuccess, onError) {
|
|
2246
|
+
function useAccountFavouriteDelete(username, code, onSuccess, onError) {
|
|
2233
2247
|
return useMutation({
|
|
2234
2248
|
mutationKey: ["accounts", "favourites", "add", username],
|
|
2235
2249
|
mutationFn: async (account) => {
|
|
2236
|
-
if (!username) {
|
|
2237
|
-
throw new Error("[SDK][Account][Bookmarks] \u2013
|
|
2250
|
+
if (!username || !code) {
|
|
2251
|
+
throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
|
|
2238
2252
|
}
|
|
2239
2253
|
const fetchApi = getBoundFetch();
|
|
2240
2254
|
const response = await fetchApi(
|
|
@@ -2246,7 +2260,7 @@ function useAccountFavouriteDelete(username, onSuccess, onError) {
|
|
|
2246
2260
|
},
|
|
2247
2261
|
body: JSON.stringify({
|
|
2248
2262
|
account,
|
|
2249
|
-
code
|
|
2263
|
+
code
|
|
2250
2264
|
})
|
|
2251
2265
|
}
|
|
2252
2266
|
);
|
|
@@ -2404,7 +2418,7 @@ function useAccountRevokePosting(username, options) {
|
|
|
2404
2418
|
}
|
|
2405
2419
|
});
|
|
2406
2420
|
}
|
|
2407
|
-
function useAccountUpdateRecovery(username, options) {
|
|
2421
|
+
function useAccountUpdateRecovery(username, code, options) {
|
|
2408
2422
|
const { data } = useQuery(getAccountFullQueryOptions(username));
|
|
2409
2423
|
return useMutation({
|
|
2410
2424
|
mutationKey: ["accounts", "recovery", data?.name],
|
|
@@ -2420,11 +2434,14 @@ function useAccountUpdateRecovery(username, options) {
|
|
|
2420
2434
|
extensions: []
|
|
2421
2435
|
};
|
|
2422
2436
|
if (type === "ecency") {
|
|
2437
|
+
if (!code) {
|
|
2438
|
+
throw new Error("[SDK][Accounts] \u2013 missing access token");
|
|
2439
|
+
}
|
|
2423
2440
|
const fetchApi = getBoundFetch();
|
|
2424
2441
|
return fetchApi(CONFIG.privateApiHost + "/private-api/recoveries-add", {
|
|
2425
2442
|
method: "POST",
|
|
2426
2443
|
body: JSON.stringify({
|
|
2427
|
-
code
|
|
2444
|
+
code,
|
|
2428
2445
|
email,
|
|
2429
2446
|
publicKeys: [
|
|
2430
2447
|
...data.owner.key_auths,
|
|
@@ -2548,17 +2565,20 @@ function getChainPropertiesQueryOptions() {
|
|
|
2548
2565
|
}
|
|
2549
2566
|
});
|
|
2550
2567
|
}
|
|
2551
|
-
function useAddFragment(username) {
|
|
2568
|
+
function useAddFragment(username, code) {
|
|
2552
2569
|
return useMutation({
|
|
2553
2570
|
mutationKey: ["posts", "add-fragment", username],
|
|
2554
2571
|
mutationFn: async ({ title, body }) => {
|
|
2572
|
+
if (!code) {
|
|
2573
|
+
throw new Error("[SDK][Posts] Missing access token");
|
|
2574
|
+
}
|
|
2555
2575
|
const fetchApi = getBoundFetch();
|
|
2556
2576
|
const response = await fetchApi(
|
|
2557
2577
|
CONFIG.privateApiHost + "/private-api/fragments-add",
|
|
2558
2578
|
{
|
|
2559
2579
|
method: "POST",
|
|
2560
2580
|
body: JSON.stringify({
|
|
2561
|
-
code
|
|
2581
|
+
code,
|
|
2562
2582
|
title,
|
|
2563
2583
|
body
|
|
2564
2584
|
}),
|
|
@@ -2571,23 +2591,26 @@ function useAddFragment(username) {
|
|
|
2571
2591
|
},
|
|
2572
2592
|
onSuccess(response) {
|
|
2573
2593
|
getQueryClient().setQueryData(
|
|
2574
|
-
getFragmentsQueryOptions(username).queryKey,
|
|
2594
|
+
getFragmentsQueryOptions(username, code).queryKey,
|
|
2575
2595
|
(data) => [response, ...data ?? []]
|
|
2576
2596
|
);
|
|
2577
2597
|
}
|
|
2578
2598
|
});
|
|
2579
2599
|
}
|
|
2580
|
-
function useEditFragment(username, fragmentId) {
|
|
2600
|
+
function useEditFragment(username, fragmentId, code) {
|
|
2581
2601
|
return useMutation({
|
|
2582
2602
|
mutationKey: ["posts", "edit-fragment", username, fragmentId],
|
|
2583
2603
|
mutationFn: async ({ title, body }) => {
|
|
2604
|
+
if (!code) {
|
|
2605
|
+
throw new Error("[SDK][Posts] Missing access token");
|
|
2606
|
+
}
|
|
2584
2607
|
const fetchApi = getBoundFetch();
|
|
2585
2608
|
const response = await fetchApi(
|
|
2586
2609
|
CONFIG.privateApiHost + "/private-api/fragments-update",
|
|
2587
2610
|
{
|
|
2588
2611
|
method: "POST",
|
|
2589
2612
|
body: JSON.stringify({
|
|
2590
|
-
code
|
|
2613
|
+
code,
|
|
2591
2614
|
id: fragmentId,
|
|
2592
2615
|
title,
|
|
2593
2616
|
body
|
|
@@ -2601,7 +2624,7 @@ function useEditFragment(username, fragmentId) {
|
|
|
2601
2624
|
},
|
|
2602
2625
|
onSuccess(response) {
|
|
2603
2626
|
getQueryClient().setQueryData(
|
|
2604
|
-
getFragmentsQueryOptions(username).queryKey,
|
|
2627
|
+
getFragmentsQueryOptions(username, code).queryKey,
|
|
2605
2628
|
(data) => {
|
|
2606
2629
|
if (!data) {
|
|
2607
2630
|
return [];
|
|
@@ -2616,15 +2639,18 @@ function useEditFragment(username, fragmentId) {
|
|
|
2616
2639
|
}
|
|
2617
2640
|
});
|
|
2618
2641
|
}
|
|
2619
|
-
function useRemoveFragment(username, fragmentId) {
|
|
2642
|
+
function useRemoveFragment(username, fragmentId, code) {
|
|
2620
2643
|
return useMutation({
|
|
2621
2644
|
mutationKey: ["posts", "remove-fragment", username],
|
|
2622
2645
|
mutationFn: async () => {
|
|
2646
|
+
if (!code) {
|
|
2647
|
+
throw new Error("[SDK][Posts] Missing access token");
|
|
2648
|
+
}
|
|
2623
2649
|
const fetchApi = getBoundFetch();
|
|
2624
2650
|
return fetchApi(CONFIG.privateApiHost + "/private-api/fragments-delete", {
|
|
2625
2651
|
method: "POST",
|
|
2626
2652
|
body: JSON.stringify({
|
|
2627
|
-
code
|
|
2653
|
+
code,
|
|
2628
2654
|
id: fragmentId
|
|
2629
2655
|
}),
|
|
2630
2656
|
headers: {
|
|
@@ -2634,7 +2660,7 @@ function useRemoveFragment(username, fragmentId) {
|
|
|
2634
2660
|
},
|
|
2635
2661
|
onSuccess() {
|
|
2636
2662
|
getQueryClient().setQueryData(
|
|
2637
|
-
getFragmentsQueryOptions(username).queryKey,
|
|
2663
|
+
getFragmentsQueryOptions(username, code).queryKey,
|
|
2638
2664
|
(data) => [...data ?? []].filter(({ id }) => id !== fragmentId)
|
|
2639
2665
|
);
|
|
2640
2666
|
}
|
|
@@ -2753,11 +2779,10 @@ var queries_exports = {};
|
|
|
2753
2779
|
__export(queries_exports, {
|
|
2754
2780
|
getDecodeMemoQueryOptions: () => getDecodeMemoQueryOptions
|
|
2755
2781
|
});
|
|
2756
|
-
function getDecodeMemoQueryOptions(username, memo) {
|
|
2782
|
+
function getDecodeMemoQueryOptions(username, memo, accessToken) {
|
|
2757
2783
|
return queryOptions({
|
|
2758
2784
|
queryKey: ["integrations", "hivesigner", "decode-memo", username],
|
|
2759
2785
|
queryFn: async () => {
|
|
2760
|
-
const accessToken = getAccessToken(username);
|
|
2761
2786
|
if (accessToken) {
|
|
2762
2787
|
const hsClient = new hs.Client({
|
|
2763
2788
|
accessToken
|
|
@@ -2774,12 +2799,12 @@ var HiveSignerIntegration = {
|
|
|
2774
2799
|
};
|
|
2775
2800
|
|
|
2776
2801
|
// src/modules/integrations/3speak/queries/get-account-token-query-options.ts
|
|
2777
|
-
function getAccountTokenQueryOptions(username) {
|
|
2802
|
+
function getAccountTokenQueryOptions(username, accessToken) {
|
|
2778
2803
|
return queryOptions({
|
|
2779
2804
|
queryKey: ["integrations", "3speak", "authenticate", username],
|
|
2780
|
-
enabled: !!username,
|
|
2805
|
+
enabled: !!username && !!accessToken,
|
|
2781
2806
|
queryFn: async () => {
|
|
2782
|
-
if (!username) {
|
|
2807
|
+
if (!username || !accessToken) {
|
|
2783
2808
|
throw new Error("[SDK][Integrations][3Speak] \u2013\xA0anon user");
|
|
2784
2809
|
}
|
|
2785
2810
|
const fetchApi = getBoundFetch();
|
|
@@ -2793,7 +2818,8 @@ function getAccountTokenQueryOptions(username) {
|
|
|
2793
2818
|
);
|
|
2794
2819
|
const memoQueryOptions = HiveSignerIntegration.queries.getDecodeMemoQueryOptions(
|
|
2795
2820
|
username,
|
|
2796
|
-
(await response.json()).memo
|
|
2821
|
+
(await response.json()).memo,
|
|
2822
|
+
accessToken
|
|
2797
2823
|
);
|
|
2798
2824
|
await getQueryClient().prefetchQuery(memoQueryOptions);
|
|
2799
2825
|
const { memoDecoded } = getQueryClient().getQueryData(
|
|
@@ -2803,17 +2829,23 @@ function getAccountTokenQueryOptions(username) {
|
|
|
2803
2829
|
}
|
|
2804
2830
|
});
|
|
2805
2831
|
}
|
|
2806
|
-
function getAccountVideosQueryOptions(username) {
|
|
2832
|
+
function getAccountVideosQueryOptions(username, accessToken) {
|
|
2807
2833
|
return queryOptions({
|
|
2808
2834
|
queryKey: ["integrations", "3speak", "videos", username],
|
|
2809
|
-
enabled: !!username,
|
|
2835
|
+
enabled: !!username && !!accessToken,
|
|
2810
2836
|
queryFn: async () => {
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
const
|
|
2815
|
-
|
|
2837
|
+
if (!username || !accessToken) {
|
|
2838
|
+
throw new Error("[SDK][Integrations][3Speak] \u2013\xA0anon user");
|
|
2839
|
+
}
|
|
2840
|
+
const tokenQueryOptions = getAccountTokenQueryOptions(
|
|
2841
|
+
username,
|
|
2842
|
+
accessToken
|
|
2816
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
|
+
}
|
|
2817
2849
|
const fetchApi = getBoundFetch();
|
|
2818
2850
|
const response = await fetchApi(
|
|
2819
2851
|
`https://studio.3speak.tv/mobile/api/my-videos`,
|
|
@@ -2924,13 +2956,13 @@ function getAccountRcQueryOptions(username) {
|
|
|
2924
2956
|
enabled: !!username
|
|
2925
2957
|
});
|
|
2926
2958
|
}
|
|
2927
|
-
function getGameStatusCheckQueryOptions(username, gameType) {
|
|
2959
|
+
function getGameStatusCheckQueryOptions(username, code, gameType) {
|
|
2928
2960
|
return queryOptions({
|
|
2929
2961
|
queryKey: ["games", "status-check", gameType, username],
|
|
2930
|
-
enabled: !!username,
|
|
2962
|
+
enabled: !!username && !!code,
|
|
2931
2963
|
queryFn: async () => {
|
|
2932
|
-
if (!username) {
|
|
2933
|
-
throw new Error("[SDK][Games] \u2013
|
|
2964
|
+
if (!username || !code) {
|
|
2965
|
+
throw new Error("[SDK][Games] \u2013 missing auth");
|
|
2934
2966
|
}
|
|
2935
2967
|
const fetchApi = getBoundFetch();
|
|
2936
2968
|
const response = await fetchApi(
|
|
@@ -2939,7 +2971,7 @@ function getGameStatusCheckQueryOptions(username, gameType) {
|
|
|
2939
2971
|
method: "POST",
|
|
2940
2972
|
body: JSON.stringify({
|
|
2941
2973
|
game_type: gameType,
|
|
2942
|
-
code
|
|
2974
|
+
code
|
|
2943
2975
|
}),
|
|
2944
2976
|
headers: {
|
|
2945
2977
|
"Content-Type": "application/json"
|
|
@@ -2950,7 +2982,7 @@ function getGameStatusCheckQueryOptions(username, gameType) {
|
|
|
2950
2982
|
}
|
|
2951
2983
|
});
|
|
2952
2984
|
}
|
|
2953
|
-
function useGameClaim(username, gameType, key) {
|
|
2985
|
+
function useGameClaim(username, code, gameType, key) {
|
|
2954
2986
|
const { mutateAsync: recordActivity } = useRecordActivity(
|
|
2955
2987
|
username,
|
|
2956
2988
|
"spin-rolled"
|
|
@@ -2958,8 +2990,8 @@ function useGameClaim(username, gameType, key) {
|
|
|
2958
2990
|
return useMutation({
|
|
2959
2991
|
mutationKey: ["games", "post", gameType, username],
|
|
2960
2992
|
mutationFn: async () => {
|
|
2961
|
-
if (!username) {
|
|
2962
|
-
throw new Error("[SDK][Games] \u2013
|
|
2993
|
+
if (!username || !code) {
|
|
2994
|
+
throw new Error("[SDK][Games] \u2013 missing auth");
|
|
2963
2995
|
}
|
|
2964
2996
|
const fetchApi = getBoundFetch();
|
|
2965
2997
|
const response = await fetchApi(
|
|
@@ -2968,7 +3000,7 @@ function useGameClaim(username, gameType, key) {
|
|
|
2968
3000
|
method: "POST",
|
|
2969
3001
|
body: JSON.stringify({
|
|
2970
3002
|
game_type: gameType,
|
|
2971
|
-
code
|
|
3003
|
+
code,
|
|
2972
3004
|
key
|
|
2973
3005
|
}),
|
|
2974
3006
|
headers: {
|
|
@@ -3133,15 +3165,18 @@ function getCommunityPermissions({
|
|
|
3133
3165
|
isModerator
|
|
3134
3166
|
};
|
|
3135
3167
|
}
|
|
3136
|
-
function getNotificationsUnreadCountQueryOptions(activeUsername) {
|
|
3168
|
+
function getNotificationsUnreadCountQueryOptions(activeUsername, code) {
|
|
3137
3169
|
return queryOptions({
|
|
3138
3170
|
queryKey: ["notifications", "unread", activeUsername],
|
|
3139
3171
|
queryFn: async () => {
|
|
3172
|
+
if (!code) {
|
|
3173
|
+
return 0;
|
|
3174
|
+
}
|
|
3140
3175
|
const response = await fetch(
|
|
3141
3176
|
`${CONFIG.privateApiHost}/private-api/notifications/unread`,
|
|
3142
3177
|
{
|
|
3143
3178
|
method: "POST",
|
|
3144
|
-
body: JSON.stringify({ code
|
|
3179
|
+
body: JSON.stringify({ code }),
|
|
3145
3180
|
headers: {
|
|
3146
3181
|
"Content-Type": "application/json"
|
|
3147
3182
|
}
|
|
@@ -3150,17 +3185,20 @@ function getNotificationsUnreadCountQueryOptions(activeUsername) {
|
|
|
3150
3185
|
const data = await response.json();
|
|
3151
3186
|
return data.count;
|
|
3152
3187
|
},
|
|
3153
|
-
enabled: !!activeUsername,
|
|
3188
|
+
enabled: !!activeUsername && !!code,
|
|
3154
3189
|
initialData: 0,
|
|
3155
3190
|
refetchInterval: 6e4
|
|
3156
3191
|
});
|
|
3157
3192
|
}
|
|
3158
|
-
function getNotificationsInfiniteQueryOptions(activeUsername, filter = void 0) {
|
|
3193
|
+
function getNotificationsInfiniteQueryOptions(activeUsername, code, filter = void 0) {
|
|
3159
3194
|
return infiniteQueryOptions({
|
|
3160
3195
|
queryKey: ["notifications", activeUsername, filter],
|
|
3161
3196
|
queryFn: async ({ pageParam }) => {
|
|
3197
|
+
if (!code) {
|
|
3198
|
+
return [];
|
|
3199
|
+
}
|
|
3162
3200
|
const data = {
|
|
3163
|
-
code
|
|
3201
|
+
code,
|
|
3164
3202
|
filter,
|
|
3165
3203
|
since: pageParam,
|
|
3166
3204
|
user: void 0
|
|
@@ -3177,7 +3215,7 @@ function getNotificationsInfiniteQueryOptions(activeUsername, filter = void 0) {
|
|
|
3177
3215
|
);
|
|
3178
3216
|
return response.json();
|
|
3179
3217
|
},
|
|
3180
|
-
enabled: !!activeUsername,
|
|
3218
|
+
enabled: !!activeUsername && !!code,
|
|
3181
3219
|
initialData: { pages: [], pageParams: [] },
|
|
3182
3220
|
initialPageParam: "",
|
|
3183
3221
|
getNextPageParam: (lastPage) => lastPage?.[lastPage.length - 1]?.id ?? "",
|
|
@@ -3230,16 +3268,19 @@ var NotificationViewType = /* @__PURE__ */ ((NotificationViewType2) => {
|
|
|
3230
3268
|
})(NotificationViewType || {});
|
|
3231
3269
|
|
|
3232
3270
|
// src/modules/notifications/queries/get-notifications-settings-query-options.ts
|
|
3233
|
-
function getNotificationsSettingsQueryOptions(activeUsername) {
|
|
3271
|
+
function getNotificationsSettingsQueryOptions(activeUsername, code) {
|
|
3234
3272
|
return queryOptions({
|
|
3235
3273
|
queryKey: ["notifications", "settings", activeUsername],
|
|
3236
3274
|
queryFn: async () => {
|
|
3237
3275
|
let token = activeUsername + "-web";
|
|
3276
|
+
if (!code) {
|
|
3277
|
+
throw new Error("Missing access token");
|
|
3278
|
+
}
|
|
3238
3279
|
const response = await fetch(
|
|
3239
3280
|
CONFIG.privateApiHost + "/private-api/detail-device",
|
|
3240
3281
|
{
|
|
3241
3282
|
body: JSON.stringify({
|
|
3242
|
-
code
|
|
3283
|
+
code,
|
|
3243
3284
|
username: activeUsername,
|
|
3244
3285
|
token
|
|
3245
3286
|
}),
|
|
@@ -3254,7 +3295,7 @@ function getNotificationsSettingsQueryOptions(activeUsername) {
|
|
|
3254
3295
|
}
|
|
3255
3296
|
return response.json();
|
|
3256
3297
|
},
|
|
3257
|
-
enabled: !!activeUsername,
|
|
3298
|
+
enabled: !!activeUsername && !!code,
|
|
3258
3299
|
refetchOnMount: false,
|
|
3259
3300
|
initialData: () => {
|
|
3260
3301
|
const wasMutedPreviously = typeof window !== "undefined" ? localStorage.getItem("notifications") !== "true" : false;
|
|
@@ -3548,8 +3589,9 @@ function getMarketDataQueryOptions(coin, vsCurrency, fromTs, toTs) {
|
|
|
3548
3589
|
return queryOptions({
|
|
3549
3590
|
queryKey: ["market", "data", coin, vsCurrency, fromTs, toTs],
|
|
3550
3591
|
queryFn: async ({ signal }) => {
|
|
3592
|
+
const fetchApi = getBoundFetch();
|
|
3551
3593
|
const url = `https://api.coingecko.com/api/v3/coins/${coin}/market_chart/range?vs_currency=${vsCurrency}&from=${fromTs}&to=${toTs}`;
|
|
3552
|
-
const response = await
|
|
3594
|
+
const response = await fetchApi(url, { signal });
|
|
3553
3595
|
if (!response.ok) {
|
|
3554
3596
|
throw new Error(`Failed to fetch market data: ${response.status}`);
|
|
3555
3597
|
}
|
|
@@ -3557,6 +3599,46 @@ function getMarketDataQueryOptions(coin, vsCurrency, fromTs, toTs) {
|
|
|
3557
3599
|
}
|
|
3558
3600
|
});
|
|
3559
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
|
+
}
|
|
3560
3642
|
function getPointsQueryOptions(username, filter = 0) {
|
|
3561
3643
|
return queryOptions({
|
|
3562
3644
|
queryKey: ["points", username, filter],
|
|
@@ -3897,6 +3979,311 @@ function getBoostPlusAccountPricesQueryOptions(account, accessToken) {
|
|
|
3897
3979
|
});
|
|
3898
3980
|
}
|
|
3899
3981
|
|
|
3900
|
-
|
|
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 };
|
|
3901
4288
|
//# sourceMappingURL=index.js.map
|
|
3902
4289
|
//# sourceMappingURL=index.js.map
|