@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.cjs
CHANGED
|
@@ -34,6 +34,107 @@ var __export = (target, all) => {
|
|
|
34
34
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
// src/modules/keychain/keychain.ts
|
|
38
|
+
var keychain_exports = {};
|
|
39
|
+
__export(keychain_exports, {
|
|
40
|
+
broadcast: () => broadcast,
|
|
41
|
+
customJson: () => customJson,
|
|
42
|
+
handshake: () => handshake
|
|
43
|
+
});
|
|
44
|
+
function handshake() {
|
|
45
|
+
return new Promise((resolve) => {
|
|
46
|
+
window.hive_keychain?.requestHandshake(() => {
|
|
47
|
+
resolve();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
var broadcast = (account, operations, key, rpc = null) => new Promise((resolve, reject) => {
|
|
52
|
+
window.hive_keychain?.requestBroadcast(
|
|
53
|
+
account,
|
|
54
|
+
operations,
|
|
55
|
+
key,
|
|
56
|
+
(resp) => {
|
|
57
|
+
if (!resp.success) {
|
|
58
|
+
reject({ message: "Operation cancelled" });
|
|
59
|
+
}
|
|
60
|
+
resolve(resp);
|
|
61
|
+
},
|
|
62
|
+
rpc
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
var customJson = (account, id, key, json, display_msg, rpc = null) => new Promise((resolve, reject) => {
|
|
66
|
+
window.hive_keychain?.requestCustomJson(
|
|
67
|
+
account,
|
|
68
|
+
id,
|
|
69
|
+
key,
|
|
70
|
+
json,
|
|
71
|
+
display_msg,
|
|
72
|
+
(resp) => {
|
|
73
|
+
if (!resp.success) {
|
|
74
|
+
reject({ message: "Operation cancelled" });
|
|
75
|
+
}
|
|
76
|
+
resolve(resp);
|
|
77
|
+
},
|
|
78
|
+
rpc
|
|
79
|
+
);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// src/modules/core/mutations/use-broadcast-mutation.ts
|
|
83
|
+
function useBroadcastMutation(mutationKey = [], username, accessToken, operations, onSuccess = () => {
|
|
84
|
+
}, auth) {
|
|
85
|
+
return reactQuery.useMutation({
|
|
86
|
+
onSuccess,
|
|
87
|
+
mutationKey: [...mutationKey, username],
|
|
88
|
+
mutationFn: async (payload) => {
|
|
89
|
+
if (!username) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
const postingKey = auth?.postingKey;
|
|
95
|
+
if (postingKey) {
|
|
96
|
+
const privateKey = dhive.PrivateKey.fromString(postingKey);
|
|
97
|
+
return CONFIG.hiveClient.broadcast.sendOperations(
|
|
98
|
+
operations(payload),
|
|
99
|
+
privateKey
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
const loginType = auth?.loginType;
|
|
103
|
+
if (loginType && loginType == "keychain") {
|
|
104
|
+
return keychain_exports.broadcast(
|
|
105
|
+
username,
|
|
106
|
+
operations(payload),
|
|
107
|
+
"Posting"
|
|
108
|
+
).then((r) => r.result);
|
|
109
|
+
}
|
|
110
|
+
if (accessToken) {
|
|
111
|
+
const f = getBoundFetch();
|
|
112
|
+
const res = await f("https://hivesigner.com/api/broadcast", {
|
|
113
|
+
method: "POST",
|
|
114
|
+
headers: {
|
|
115
|
+
Authorization: accessToken,
|
|
116
|
+
"Content-Type": "application/json",
|
|
117
|
+
Accept: "application/json"
|
|
118
|
+
},
|
|
119
|
+
body: JSON.stringify({ operations: operations(payload) })
|
|
120
|
+
});
|
|
121
|
+
if (!res.ok) {
|
|
122
|
+
const txt = await res.text().catch(() => "");
|
|
123
|
+
throw new Error(`[Hivesigner] ${res.status} ${res.statusText} ${txt}`);
|
|
124
|
+
}
|
|
125
|
+
const json = await res.json();
|
|
126
|
+
if (json?.errors) {
|
|
127
|
+
throw new Error(`[Hivesigner] ${JSON.stringify(json.errors)}`);
|
|
128
|
+
}
|
|
129
|
+
return json.result;
|
|
130
|
+
}
|
|
131
|
+
throw new Error(
|
|
132
|
+
"[SDK][Broadcast] \u2013 cannot broadcast w/o posting key or token"
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
37
138
|
// src/modules/core/mock-storage.ts
|
|
38
139
|
var MockStorage = class {
|
|
39
140
|
length = 0;
|
|
@@ -55,6 +156,7 @@ var MockStorage = class {
|
|
|
55
156
|
};
|
|
56
157
|
var CONFIG = {
|
|
57
158
|
privateApiHost: "https://ecency.com",
|
|
159
|
+
imageHost: "https://images.ecency.com",
|
|
58
160
|
storage: typeof window === "undefined" ? new MockStorage() : window.localStorage,
|
|
59
161
|
storagePrefix: "ecency",
|
|
60
162
|
hiveClient: new dhive.Client(
|
|
@@ -101,6 +203,10 @@ exports.ConfigManager = void 0;
|
|
|
101
203
|
CONFIG.privateApiHost = host;
|
|
102
204
|
}
|
|
103
205
|
ConfigManager2.setPrivateApiHost = setPrivateApiHost;
|
|
206
|
+
function setImageHost(host) {
|
|
207
|
+
CONFIG.imageHost = host;
|
|
208
|
+
}
|
|
209
|
+
ConfigManager2.setImageHost = setImageHost;
|
|
104
210
|
function analyzeRedosRisk(pattern) {
|
|
105
211
|
if (/(\([^)]*[*+{][^)]*\))[*+{]/.test(pattern)) {
|
|
106
212
|
return { safe: false, reason: "nested quantifiers detected" };
|
|
@@ -207,6 +313,40 @@ exports.ConfigManager = void 0;
|
|
|
207
313
|
}
|
|
208
314
|
ConfigManager2.setDmcaLists = setDmcaLists;
|
|
209
315
|
})(exports.ConfigManager || (exports.ConfigManager = {}));
|
|
316
|
+
async function broadcastJson(username, id, payload, accessToken, auth) {
|
|
317
|
+
if (!username) {
|
|
318
|
+
throw new Error(
|
|
319
|
+
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
const jjson = {
|
|
323
|
+
id,
|
|
324
|
+
required_auths: [],
|
|
325
|
+
required_posting_auths: [username],
|
|
326
|
+
json: JSON.stringify(payload)
|
|
327
|
+
};
|
|
328
|
+
const postingKey = auth?.postingKey;
|
|
329
|
+
if (postingKey) {
|
|
330
|
+
const privateKey = dhive.PrivateKey.fromString(postingKey);
|
|
331
|
+
return CONFIG.hiveClient.broadcast.json(
|
|
332
|
+
jjson,
|
|
333
|
+
privateKey
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
const loginType = auth?.loginType;
|
|
337
|
+
if (loginType && loginType == "keychain") {
|
|
338
|
+
return keychain_exports.broadcast(username, [["custom_json", jjson]], "Posting").then((r) => r.result);
|
|
339
|
+
}
|
|
340
|
+
if (accessToken) {
|
|
341
|
+
const response = await new hs__default.default.Client({
|
|
342
|
+
accessToken
|
|
343
|
+
}).customJson([], [username], id, JSON.stringify(payload));
|
|
344
|
+
return response.result;
|
|
345
|
+
}
|
|
346
|
+
throw new Error(
|
|
347
|
+
"[SDK][Broadcast] \u2013 cannot broadcast w/o posting key or token"
|
|
348
|
+
);
|
|
349
|
+
}
|
|
210
350
|
|
|
211
351
|
// src/modules/core/utils/decoder-encoder.ts
|
|
212
352
|
function encodeObj(o) {
|
|
@@ -284,143 +424,6 @@ var getAccessToken = (username) => getUser(username) && getUser(username).access
|
|
|
284
424
|
var getPostingKey = (username) => getUser(username) && getUser(username).postingKey;
|
|
285
425
|
var getLoginType = (username) => getUser(username) && getUser(username).loginType;
|
|
286
426
|
var getRefreshToken = (username) => getUser(username) && getUser(username).refreshToken;
|
|
287
|
-
|
|
288
|
-
// src/modules/keychain/keychain.ts
|
|
289
|
-
var keychain_exports = {};
|
|
290
|
-
__export(keychain_exports, {
|
|
291
|
-
broadcast: () => broadcast,
|
|
292
|
-
customJson: () => customJson,
|
|
293
|
-
handshake: () => handshake
|
|
294
|
-
});
|
|
295
|
-
function handshake() {
|
|
296
|
-
return new Promise((resolve) => {
|
|
297
|
-
window.hive_keychain?.requestHandshake(() => {
|
|
298
|
-
resolve();
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
var broadcast = (account, operations, key, rpc = null) => new Promise((resolve, reject) => {
|
|
303
|
-
window.hive_keychain?.requestBroadcast(
|
|
304
|
-
account,
|
|
305
|
-
operations,
|
|
306
|
-
key,
|
|
307
|
-
(resp) => {
|
|
308
|
-
if (!resp.success) {
|
|
309
|
-
reject({ message: "Operation cancelled" });
|
|
310
|
-
}
|
|
311
|
-
resolve(resp);
|
|
312
|
-
},
|
|
313
|
-
rpc
|
|
314
|
-
);
|
|
315
|
-
});
|
|
316
|
-
var customJson = (account, id, key, json, display_msg, rpc = null) => new Promise((resolve, reject) => {
|
|
317
|
-
window.hive_keychain?.requestCustomJson(
|
|
318
|
-
account,
|
|
319
|
-
id,
|
|
320
|
-
key,
|
|
321
|
-
json,
|
|
322
|
-
display_msg,
|
|
323
|
-
(resp) => {
|
|
324
|
-
if (!resp.success) {
|
|
325
|
-
reject({ message: "Operation cancelled" });
|
|
326
|
-
}
|
|
327
|
-
resolve(resp);
|
|
328
|
-
},
|
|
329
|
-
rpc
|
|
330
|
-
);
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
// src/modules/core/mutations/use-broadcast-mutation.ts
|
|
334
|
-
function useBroadcastMutation(mutationKey = [], username, operations, onSuccess = () => {
|
|
335
|
-
}) {
|
|
336
|
-
return reactQuery.useMutation({
|
|
337
|
-
onSuccess,
|
|
338
|
-
mutationKey: [...mutationKey, username],
|
|
339
|
-
mutationFn: async (payload) => {
|
|
340
|
-
if (!username) {
|
|
341
|
-
throw new Error(
|
|
342
|
-
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
|
343
|
-
);
|
|
344
|
-
}
|
|
345
|
-
const postingKey = getPostingKey(username);
|
|
346
|
-
if (postingKey) {
|
|
347
|
-
const privateKey = dhive.PrivateKey.fromString(postingKey);
|
|
348
|
-
return CONFIG.hiveClient.broadcast.sendOperations(
|
|
349
|
-
operations(payload),
|
|
350
|
-
privateKey
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
const loginType = getLoginType(username);
|
|
354
|
-
if (loginType && loginType == "keychain") {
|
|
355
|
-
return keychain_exports.broadcast(
|
|
356
|
-
username,
|
|
357
|
-
operations(payload),
|
|
358
|
-
"Posting"
|
|
359
|
-
).then((r) => r.result);
|
|
360
|
-
}
|
|
361
|
-
let token = getAccessToken(username);
|
|
362
|
-
if (token) {
|
|
363
|
-
const f = getBoundFetch();
|
|
364
|
-
const res = await f("https://hivesigner.com/api/broadcast", {
|
|
365
|
-
method: "POST",
|
|
366
|
-
headers: {
|
|
367
|
-
Authorization: token,
|
|
368
|
-
"Content-Type": "application/json",
|
|
369
|
-
Accept: "application/json"
|
|
370
|
-
},
|
|
371
|
-
body: JSON.stringify({ operations: operations(payload) })
|
|
372
|
-
});
|
|
373
|
-
if (!res.ok) {
|
|
374
|
-
const txt = await res.text().catch(() => "");
|
|
375
|
-
throw new Error(`[Hivesigner] ${res.status} ${res.statusText} ${txt}`);
|
|
376
|
-
}
|
|
377
|
-
const json = await res.json();
|
|
378
|
-
if (json?.errors) {
|
|
379
|
-
throw new Error(`[Hivesigner] ${JSON.stringify(json.errors)}`);
|
|
380
|
-
}
|
|
381
|
-
return json.result;
|
|
382
|
-
}
|
|
383
|
-
throw new Error(
|
|
384
|
-
"[SDK][Broadcast] \u2013 cannot broadcast w/o posting key or token"
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
async function broadcastJson(username, id, payload) {
|
|
390
|
-
if (!username) {
|
|
391
|
-
throw new Error(
|
|
392
|
-
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
|
393
|
-
);
|
|
394
|
-
}
|
|
395
|
-
const jjson = {
|
|
396
|
-
id,
|
|
397
|
-
required_auths: [],
|
|
398
|
-
required_posting_auths: [username],
|
|
399
|
-
json: JSON.stringify(payload)
|
|
400
|
-
};
|
|
401
|
-
const postingKey = getPostingKey(username);
|
|
402
|
-
if (postingKey) {
|
|
403
|
-
const privateKey = dhive.PrivateKey.fromString(postingKey);
|
|
404
|
-
return CONFIG.hiveClient.broadcast.json(
|
|
405
|
-
jjson,
|
|
406
|
-
privateKey
|
|
407
|
-
);
|
|
408
|
-
}
|
|
409
|
-
const loginType = getLoginType(username);
|
|
410
|
-
if (loginType && loginType == "keychain") {
|
|
411
|
-
return keychain_exports.broadcast(username, [["custom_json", jjson]], "Posting").then((r) => r.result);
|
|
412
|
-
}
|
|
413
|
-
let token = getAccessToken(username);
|
|
414
|
-
if (token) {
|
|
415
|
-
const response = await new hs__default.default.Client({
|
|
416
|
-
accessToken: token
|
|
417
|
-
}).customJson([], [username], id, JSON.stringify(payload));
|
|
418
|
-
return response.result;
|
|
419
|
-
}
|
|
420
|
-
throw new Error(
|
|
421
|
-
"[SDK][Broadcast] \u2013 cannot broadcast w/o posting key or token"
|
|
422
|
-
);
|
|
423
|
-
}
|
|
424
427
|
function makeQueryClient() {
|
|
425
428
|
return new reactQuery.QueryClient({
|
|
426
429
|
defaultOptions: {
|
|
@@ -928,13 +931,13 @@ function getAccountSubscriptionsQueryOptions(username) {
|
|
|
928
931
|
}
|
|
929
932
|
});
|
|
930
933
|
}
|
|
931
|
-
function getActiveAccountBookmarksQueryOptions(activeUsername) {
|
|
934
|
+
function getActiveAccountBookmarksQueryOptions(activeUsername, code) {
|
|
932
935
|
return reactQuery.queryOptions({
|
|
933
936
|
queryKey: ["accounts", "bookmarks", activeUsername],
|
|
934
|
-
enabled: !!activeUsername,
|
|
937
|
+
enabled: !!activeUsername && !!code,
|
|
935
938
|
queryFn: async () => {
|
|
936
|
-
if (!activeUsername) {
|
|
937
|
-
throw new Error("[SDK][Accounts][Bookmarks] \u2013
|
|
939
|
+
if (!activeUsername || !code) {
|
|
940
|
+
throw new Error("[SDK][Accounts][Bookmarks] \u2013 missing auth");
|
|
938
941
|
}
|
|
939
942
|
const fetchApi = getBoundFetch();
|
|
940
943
|
const response = await fetchApi(
|
|
@@ -944,20 +947,20 @@ function getActiveAccountBookmarksQueryOptions(activeUsername) {
|
|
|
944
947
|
headers: {
|
|
945
948
|
"Content-Type": "application/json"
|
|
946
949
|
},
|
|
947
|
-
body: JSON.stringify({ code
|
|
950
|
+
body: JSON.stringify({ code })
|
|
948
951
|
}
|
|
949
952
|
);
|
|
950
953
|
return await response.json();
|
|
951
954
|
}
|
|
952
955
|
});
|
|
953
956
|
}
|
|
954
|
-
function getActiveAccountFavouritesQueryOptions(activeUsername) {
|
|
957
|
+
function getActiveAccountFavouritesQueryOptions(activeUsername, code) {
|
|
955
958
|
return reactQuery.queryOptions({
|
|
956
959
|
queryKey: ["accounts", "favourites", activeUsername],
|
|
957
|
-
enabled: !!activeUsername,
|
|
960
|
+
enabled: !!activeUsername && !!code,
|
|
958
961
|
queryFn: async () => {
|
|
959
|
-
if (!activeUsername) {
|
|
960
|
-
throw new Error("[SDK][Accounts][Favourites] \u2013
|
|
962
|
+
if (!activeUsername || !code) {
|
|
963
|
+
throw new Error("[SDK][Accounts][Favourites] \u2013 missing auth");
|
|
961
964
|
}
|
|
962
965
|
const fetchApi = getBoundFetch();
|
|
963
966
|
const response = await fetchApi(
|
|
@@ -967,18 +970,21 @@ function getActiveAccountFavouritesQueryOptions(activeUsername) {
|
|
|
967
970
|
headers: {
|
|
968
971
|
"Content-Type": "application/json"
|
|
969
972
|
},
|
|
970
|
-
body: JSON.stringify({ code
|
|
973
|
+
body: JSON.stringify({ code })
|
|
971
974
|
}
|
|
972
975
|
);
|
|
973
976
|
return await response.json();
|
|
974
977
|
}
|
|
975
978
|
});
|
|
976
979
|
}
|
|
977
|
-
function getAccountRecoveriesQueryOptions(username) {
|
|
980
|
+
function getAccountRecoveriesQueryOptions(username, code) {
|
|
978
981
|
return reactQuery.queryOptions({
|
|
979
|
-
enabled: !!username,
|
|
982
|
+
enabled: !!username && !!code,
|
|
980
983
|
queryKey: ["accounts", "recoveries", username],
|
|
981
984
|
queryFn: async () => {
|
|
985
|
+
if (!username || !code) {
|
|
986
|
+
throw new Error("[SDK][Accounts] Missing username or access token");
|
|
987
|
+
}
|
|
982
988
|
const fetchApi = getBoundFetch();
|
|
983
989
|
const response = await fetchApi(
|
|
984
990
|
CONFIG.privateApiHost + "/private-api/recoveries",
|
|
@@ -987,7 +993,7 @@ function getAccountRecoveriesQueryOptions(username) {
|
|
|
987
993
|
headers: {
|
|
988
994
|
"Content-Type": "application/json"
|
|
989
995
|
},
|
|
990
|
-
body: JSON.stringify({ code
|
|
996
|
+
body: JSON.stringify({ code })
|
|
991
997
|
}
|
|
992
998
|
);
|
|
993
999
|
return response.json();
|
|
@@ -1262,17 +1268,20 @@ function getTrendingTagsWithStatsQueryOptions(limit = 250) {
|
|
|
1262
1268
|
refetchOnMount: true
|
|
1263
1269
|
});
|
|
1264
1270
|
}
|
|
1265
|
-
function getFragmentsQueryOptions(username) {
|
|
1271
|
+
function getFragmentsQueryOptions(username, code) {
|
|
1266
1272
|
return reactQuery.queryOptions({
|
|
1267
1273
|
queryKey: ["posts", "fragments", username],
|
|
1268
1274
|
queryFn: async () => {
|
|
1275
|
+
if (!code) {
|
|
1276
|
+
return [];
|
|
1277
|
+
}
|
|
1269
1278
|
const fetchApi = getBoundFetch();
|
|
1270
1279
|
const response = await fetchApi(
|
|
1271
1280
|
CONFIG.privateApiHost + "/private-api/fragments",
|
|
1272
1281
|
{
|
|
1273
1282
|
method: "POST",
|
|
1274
1283
|
body: JSON.stringify({
|
|
1275
|
-
code
|
|
1284
|
+
code
|
|
1276
1285
|
}),
|
|
1277
1286
|
headers: {
|
|
1278
1287
|
"Content-Type": "application/json"
|
|
@@ -1281,7 +1290,7 @@ function getFragmentsQueryOptions(username) {
|
|
|
1281
1290
|
);
|
|
1282
1291
|
return response.json();
|
|
1283
1292
|
},
|
|
1284
|
-
enabled: !!username
|
|
1293
|
+
enabled: !!username && !!code
|
|
1285
1294
|
});
|
|
1286
1295
|
}
|
|
1287
1296
|
function getPromotedPostsQuery(type = "feed") {
|
|
@@ -1588,20 +1597,21 @@ function getReblogsQueryOptions(username, activeUsername, limit = 200) {
|
|
|
1588
1597
|
enabled: !!username
|
|
1589
1598
|
});
|
|
1590
1599
|
}
|
|
1591
|
-
function getSchedulesQueryOptions(activeUsername) {
|
|
1600
|
+
function getSchedulesQueryOptions(activeUsername, code) {
|
|
1592
1601
|
return reactQuery.queryOptions({
|
|
1593
1602
|
queryKey: ["posts", "schedules", activeUsername],
|
|
1594
1603
|
queryFn: async () => {
|
|
1595
|
-
if (!activeUsername) {
|
|
1604
|
+
if (!activeUsername || !code) {
|
|
1596
1605
|
return [];
|
|
1597
1606
|
}
|
|
1598
|
-
const
|
|
1607
|
+
const fetchApi = getBoundFetch();
|
|
1608
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/schedules", {
|
|
1599
1609
|
method: "POST",
|
|
1600
1610
|
headers: {
|
|
1601
1611
|
"Content-Type": "application/json"
|
|
1602
1612
|
},
|
|
1603
1613
|
body: JSON.stringify({
|
|
1604
|
-
code
|
|
1614
|
+
code
|
|
1605
1615
|
})
|
|
1606
1616
|
});
|
|
1607
1617
|
if (!response.ok) {
|
|
@@ -1609,23 +1619,24 @@ function getSchedulesQueryOptions(activeUsername) {
|
|
|
1609
1619
|
}
|
|
1610
1620
|
return response.json();
|
|
1611
1621
|
},
|
|
1612
|
-
enabled: !!activeUsername
|
|
1622
|
+
enabled: !!activeUsername && !!code
|
|
1613
1623
|
});
|
|
1614
1624
|
}
|
|
1615
|
-
function getDraftsQueryOptions(activeUsername) {
|
|
1625
|
+
function getDraftsQueryOptions(activeUsername, code) {
|
|
1616
1626
|
return reactQuery.queryOptions({
|
|
1617
1627
|
queryKey: ["posts", "drafts", activeUsername],
|
|
1618
1628
|
queryFn: async () => {
|
|
1619
|
-
if (!activeUsername) {
|
|
1629
|
+
if (!activeUsername || !code) {
|
|
1620
1630
|
return [];
|
|
1621
1631
|
}
|
|
1622
|
-
const
|
|
1632
|
+
const fetchApi = getBoundFetch();
|
|
1633
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/drafts", {
|
|
1623
1634
|
method: "POST",
|
|
1624
1635
|
headers: {
|
|
1625
1636
|
"Content-Type": "application/json"
|
|
1626
1637
|
},
|
|
1627
1638
|
body: JSON.stringify({
|
|
1628
|
-
code
|
|
1639
|
+
code
|
|
1629
1640
|
})
|
|
1630
1641
|
});
|
|
1631
1642
|
if (!response.ok) {
|
|
@@ -1633,17 +1644,18 @@ function getDraftsQueryOptions(activeUsername) {
|
|
|
1633
1644
|
}
|
|
1634
1645
|
return response.json();
|
|
1635
1646
|
},
|
|
1636
|
-
enabled: !!activeUsername
|
|
1647
|
+
enabled: !!activeUsername && !!code
|
|
1637
1648
|
});
|
|
1638
1649
|
}
|
|
1639
|
-
async function fetchUserImages(
|
|
1640
|
-
const
|
|
1650
|
+
async function fetchUserImages(code) {
|
|
1651
|
+
const fetchApi = getBoundFetch();
|
|
1652
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/images", {
|
|
1641
1653
|
method: "POST",
|
|
1642
1654
|
headers: {
|
|
1643
1655
|
"Content-Type": "application/json"
|
|
1644
1656
|
},
|
|
1645
1657
|
body: JSON.stringify({
|
|
1646
|
-
code
|
|
1658
|
+
code
|
|
1647
1659
|
})
|
|
1648
1660
|
});
|
|
1649
1661
|
if (!response.ok) {
|
|
@@ -1651,28 +1663,28 @@ async function fetchUserImages(username) {
|
|
|
1651
1663
|
}
|
|
1652
1664
|
return response.json();
|
|
1653
1665
|
}
|
|
1654
|
-
function getImagesQueryOptions(username) {
|
|
1666
|
+
function getImagesQueryOptions(username, code) {
|
|
1655
1667
|
return reactQuery.queryOptions({
|
|
1656
1668
|
queryKey: ["posts", "images", username],
|
|
1657
1669
|
queryFn: async () => {
|
|
1658
|
-
if (!username) {
|
|
1670
|
+
if (!username || !code) {
|
|
1659
1671
|
return [];
|
|
1660
1672
|
}
|
|
1661
|
-
return fetchUserImages(
|
|
1673
|
+
return fetchUserImages(code);
|
|
1662
1674
|
},
|
|
1663
|
-
enabled: !!username
|
|
1675
|
+
enabled: !!username && !!code
|
|
1664
1676
|
});
|
|
1665
1677
|
}
|
|
1666
|
-
function getGalleryImagesQueryOptions(activeUsername) {
|
|
1678
|
+
function getGalleryImagesQueryOptions(activeUsername, code) {
|
|
1667
1679
|
return reactQuery.queryOptions({
|
|
1668
1680
|
queryKey: ["posts", "gallery-images", activeUsername],
|
|
1669
1681
|
queryFn: async () => {
|
|
1670
|
-
if (!activeUsername) {
|
|
1682
|
+
if (!activeUsername || !code) {
|
|
1671
1683
|
return [];
|
|
1672
1684
|
}
|
|
1673
|
-
return fetchUserImages(
|
|
1685
|
+
return fetchUserImages(code);
|
|
1674
1686
|
},
|
|
1675
|
-
enabled: !!activeUsername
|
|
1687
|
+
enabled: !!activeUsername && !!code
|
|
1676
1688
|
});
|
|
1677
1689
|
}
|
|
1678
1690
|
function getCommentHistoryQueryOptions(author, permlink, onlyMeta = false) {
|
|
@@ -2068,12 +2080,13 @@ function getAccountVoteHistoryInfiniteQueryOptions(username, options) {
|
|
|
2068
2080
|
}
|
|
2069
2081
|
|
|
2070
2082
|
// src/modules/accounts/mutations/use-account-update.ts
|
|
2071
|
-
function useAccountUpdate(username) {
|
|
2083
|
+
function useAccountUpdate(username, accessToken, auth) {
|
|
2072
2084
|
const queryClient = reactQuery.useQueryClient();
|
|
2073
2085
|
const { data } = reactQuery.useQuery(getAccountFullQueryOptions(username));
|
|
2074
2086
|
return useBroadcastMutation(
|
|
2075
2087
|
["accounts", "update"],
|
|
2076
2088
|
username,
|
|
2089
|
+
accessToken,
|
|
2077
2090
|
(payload) => {
|
|
2078
2091
|
if (!data) {
|
|
2079
2092
|
throw new Error("[SDK][Accounts] \u2013 cannot update not existing account");
|
|
@@ -2097,7 +2110,7 @@ function useAccountUpdate(username) {
|
|
|
2097
2110
|
]
|
|
2098
2111
|
];
|
|
2099
2112
|
},
|
|
2100
|
-
(
|
|
2113
|
+
(_data, variables) => queryClient.setQueryData(
|
|
2101
2114
|
getAccountFullQueryOptions(username).queryKey,
|
|
2102
2115
|
(data2) => {
|
|
2103
2116
|
if (!data2) {
|
|
@@ -2111,7 +2124,8 @@ function useAccountUpdate(username) {
|
|
|
2111
2124
|
});
|
|
2112
2125
|
return obj;
|
|
2113
2126
|
}
|
|
2114
|
-
)
|
|
2127
|
+
),
|
|
2128
|
+
auth
|
|
2115
2129
|
);
|
|
2116
2130
|
}
|
|
2117
2131
|
function useAccountRelationsUpdate(reference, target, onSuccess, onError) {
|
|
@@ -2153,12 +2167,12 @@ function useAccountRelationsUpdate(reference, target, onSuccess, onError) {
|
|
|
2153
2167
|
}
|
|
2154
2168
|
});
|
|
2155
2169
|
}
|
|
2156
|
-
function useBookmarkAdd(username, onSuccess, onError) {
|
|
2170
|
+
function useBookmarkAdd(username, code, onSuccess, onError) {
|
|
2157
2171
|
return reactQuery.useMutation({
|
|
2158
2172
|
mutationKey: ["accounts", "bookmarks", "add", username],
|
|
2159
2173
|
mutationFn: async ({ author, permlink }) => {
|
|
2160
|
-
if (!username) {
|
|
2161
|
-
throw new Error("[SDK][Account][Bookmarks] \u2013
|
|
2174
|
+
if (!username || !code) {
|
|
2175
|
+
throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
|
|
2162
2176
|
}
|
|
2163
2177
|
const fetchApi = getBoundFetch();
|
|
2164
2178
|
const response = await fetchApi(
|
|
@@ -2171,7 +2185,7 @@ function useBookmarkAdd(username, onSuccess, onError) {
|
|
|
2171
2185
|
body: JSON.stringify({
|
|
2172
2186
|
author,
|
|
2173
2187
|
permlink,
|
|
2174
|
-
code
|
|
2188
|
+
code
|
|
2175
2189
|
})
|
|
2176
2190
|
}
|
|
2177
2191
|
);
|
|
@@ -2186,12 +2200,12 @@ function useBookmarkAdd(username, onSuccess, onError) {
|
|
|
2186
2200
|
onError
|
|
2187
2201
|
});
|
|
2188
2202
|
}
|
|
2189
|
-
function useBookmarkDelete(username, onSuccess, onError) {
|
|
2203
|
+
function useBookmarkDelete(username, code, onSuccess, onError) {
|
|
2190
2204
|
return reactQuery.useMutation({
|
|
2191
2205
|
mutationKey: ["accounts", "bookmarks", "delete", username],
|
|
2192
2206
|
mutationFn: async (bookmarkId) => {
|
|
2193
|
-
if (!username) {
|
|
2194
|
-
throw new Error("[SDK][Account][Bookmarks] \u2013
|
|
2207
|
+
if (!username || !code) {
|
|
2208
|
+
throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
|
|
2195
2209
|
}
|
|
2196
2210
|
const fetchApi = getBoundFetch();
|
|
2197
2211
|
const response = await fetchApi(
|
|
@@ -2203,7 +2217,7 @@ function useBookmarkDelete(username, onSuccess, onError) {
|
|
|
2203
2217
|
},
|
|
2204
2218
|
body: JSON.stringify({
|
|
2205
2219
|
id: bookmarkId,
|
|
2206
|
-
code
|
|
2220
|
+
code
|
|
2207
2221
|
})
|
|
2208
2222
|
}
|
|
2209
2223
|
);
|
|
@@ -2218,12 +2232,12 @@ function useBookmarkDelete(username, onSuccess, onError) {
|
|
|
2218
2232
|
onError
|
|
2219
2233
|
});
|
|
2220
2234
|
}
|
|
2221
|
-
function useAccountFavouriteAdd(username, onSuccess, onError) {
|
|
2235
|
+
function useAccountFavouriteAdd(username, code, onSuccess, onError) {
|
|
2222
2236
|
return reactQuery.useMutation({
|
|
2223
2237
|
mutationKey: ["accounts", "favourites", "add", username],
|
|
2224
2238
|
mutationFn: async (account) => {
|
|
2225
|
-
if (!username) {
|
|
2226
|
-
throw new Error("[SDK][Account][Bookmarks] \u2013
|
|
2239
|
+
if (!username || !code) {
|
|
2240
|
+
throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
|
|
2227
2241
|
}
|
|
2228
2242
|
const fetchApi = getBoundFetch();
|
|
2229
2243
|
const response = await fetchApi(
|
|
@@ -2235,7 +2249,7 @@ function useAccountFavouriteAdd(username, onSuccess, onError) {
|
|
|
2235
2249
|
},
|
|
2236
2250
|
body: JSON.stringify({
|
|
2237
2251
|
account,
|
|
2238
|
-
code
|
|
2252
|
+
code
|
|
2239
2253
|
})
|
|
2240
2254
|
}
|
|
2241
2255
|
);
|
|
@@ -2250,12 +2264,12 @@ function useAccountFavouriteAdd(username, onSuccess, onError) {
|
|
|
2250
2264
|
onError
|
|
2251
2265
|
});
|
|
2252
2266
|
}
|
|
2253
|
-
function useAccountFavouriteDelete(username, onSuccess, onError) {
|
|
2267
|
+
function useAccountFavouriteDelete(username, code, onSuccess, onError) {
|
|
2254
2268
|
return reactQuery.useMutation({
|
|
2255
2269
|
mutationKey: ["accounts", "favourites", "add", username],
|
|
2256
2270
|
mutationFn: async (account) => {
|
|
2257
|
-
if (!username) {
|
|
2258
|
-
throw new Error("[SDK][Account][Bookmarks] \u2013
|
|
2271
|
+
if (!username || !code) {
|
|
2272
|
+
throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
|
|
2259
2273
|
}
|
|
2260
2274
|
const fetchApi = getBoundFetch();
|
|
2261
2275
|
const response = await fetchApi(
|
|
@@ -2267,7 +2281,7 @@ function useAccountFavouriteDelete(username, onSuccess, onError) {
|
|
|
2267
2281
|
},
|
|
2268
2282
|
body: JSON.stringify({
|
|
2269
2283
|
account,
|
|
2270
|
-
code
|
|
2284
|
+
code
|
|
2271
2285
|
})
|
|
2272
2286
|
}
|
|
2273
2287
|
);
|
|
@@ -2425,7 +2439,7 @@ function useAccountRevokePosting(username, options) {
|
|
|
2425
2439
|
}
|
|
2426
2440
|
});
|
|
2427
2441
|
}
|
|
2428
|
-
function useAccountUpdateRecovery(username, options) {
|
|
2442
|
+
function useAccountUpdateRecovery(username, code, options) {
|
|
2429
2443
|
const { data } = reactQuery.useQuery(getAccountFullQueryOptions(username));
|
|
2430
2444
|
return reactQuery.useMutation({
|
|
2431
2445
|
mutationKey: ["accounts", "recovery", data?.name],
|
|
@@ -2441,11 +2455,14 @@ function useAccountUpdateRecovery(username, options) {
|
|
|
2441
2455
|
extensions: []
|
|
2442
2456
|
};
|
|
2443
2457
|
if (type === "ecency") {
|
|
2458
|
+
if (!code) {
|
|
2459
|
+
throw new Error("[SDK][Accounts] \u2013 missing access token");
|
|
2460
|
+
}
|
|
2444
2461
|
const fetchApi = getBoundFetch();
|
|
2445
2462
|
return fetchApi(CONFIG.privateApiHost + "/private-api/recoveries-add", {
|
|
2446
2463
|
method: "POST",
|
|
2447
2464
|
body: JSON.stringify({
|
|
2448
|
-
code
|
|
2465
|
+
code,
|
|
2449
2466
|
email,
|
|
2450
2467
|
publicKeys: [
|
|
2451
2468
|
...data.owner.key_auths,
|
|
@@ -2569,17 +2586,20 @@ function getChainPropertiesQueryOptions() {
|
|
|
2569
2586
|
}
|
|
2570
2587
|
});
|
|
2571
2588
|
}
|
|
2572
|
-
function useAddFragment(username) {
|
|
2589
|
+
function useAddFragment(username, code) {
|
|
2573
2590
|
return reactQuery.useMutation({
|
|
2574
2591
|
mutationKey: ["posts", "add-fragment", username],
|
|
2575
2592
|
mutationFn: async ({ title, body }) => {
|
|
2593
|
+
if (!code) {
|
|
2594
|
+
throw new Error("[SDK][Posts] Missing access token");
|
|
2595
|
+
}
|
|
2576
2596
|
const fetchApi = getBoundFetch();
|
|
2577
2597
|
const response = await fetchApi(
|
|
2578
2598
|
CONFIG.privateApiHost + "/private-api/fragments-add",
|
|
2579
2599
|
{
|
|
2580
2600
|
method: "POST",
|
|
2581
2601
|
body: JSON.stringify({
|
|
2582
|
-
code
|
|
2602
|
+
code,
|
|
2583
2603
|
title,
|
|
2584
2604
|
body
|
|
2585
2605
|
}),
|
|
@@ -2592,23 +2612,26 @@ function useAddFragment(username) {
|
|
|
2592
2612
|
},
|
|
2593
2613
|
onSuccess(response) {
|
|
2594
2614
|
getQueryClient().setQueryData(
|
|
2595
|
-
getFragmentsQueryOptions(username).queryKey,
|
|
2615
|
+
getFragmentsQueryOptions(username, code).queryKey,
|
|
2596
2616
|
(data) => [response, ...data ?? []]
|
|
2597
2617
|
);
|
|
2598
2618
|
}
|
|
2599
2619
|
});
|
|
2600
2620
|
}
|
|
2601
|
-
function useEditFragment(username, fragmentId) {
|
|
2621
|
+
function useEditFragment(username, fragmentId, code) {
|
|
2602
2622
|
return reactQuery.useMutation({
|
|
2603
2623
|
mutationKey: ["posts", "edit-fragment", username, fragmentId],
|
|
2604
2624
|
mutationFn: async ({ title, body }) => {
|
|
2625
|
+
if (!code) {
|
|
2626
|
+
throw new Error("[SDK][Posts] Missing access token");
|
|
2627
|
+
}
|
|
2605
2628
|
const fetchApi = getBoundFetch();
|
|
2606
2629
|
const response = await fetchApi(
|
|
2607
2630
|
CONFIG.privateApiHost + "/private-api/fragments-update",
|
|
2608
2631
|
{
|
|
2609
2632
|
method: "POST",
|
|
2610
2633
|
body: JSON.stringify({
|
|
2611
|
-
code
|
|
2634
|
+
code,
|
|
2612
2635
|
id: fragmentId,
|
|
2613
2636
|
title,
|
|
2614
2637
|
body
|
|
@@ -2622,7 +2645,7 @@ function useEditFragment(username, fragmentId) {
|
|
|
2622
2645
|
},
|
|
2623
2646
|
onSuccess(response) {
|
|
2624
2647
|
getQueryClient().setQueryData(
|
|
2625
|
-
getFragmentsQueryOptions(username).queryKey,
|
|
2648
|
+
getFragmentsQueryOptions(username, code).queryKey,
|
|
2626
2649
|
(data) => {
|
|
2627
2650
|
if (!data) {
|
|
2628
2651
|
return [];
|
|
@@ -2637,15 +2660,18 @@ function useEditFragment(username, fragmentId) {
|
|
|
2637
2660
|
}
|
|
2638
2661
|
});
|
|
2639
2662
|
}
|
|
2640
|
-
function useRemoveFragment(username, fragmentId) {
|
|
2663
|
+
function useRemoveFragment(username, fragmentId, code) {
|
|
2641
2664
|
return reactQuery.useMutation({
|
|
2642
2665
|
mutationKey: ["posts", "remove-fragment", username],
|
|
2643
2666
|
mutationFn: async () => {
|
|
2667
|
+
if (!code) {
|
|
2668
|
+
throw new Error("[SDK][Posts] Missing access token");
|
|
2669
|
+
}
|
|
2644
2670
|
const fetchApi = getBoundFetch();
|
|
2645
2671
|
return fetchApi(CONFIG.privateApiHost + "/private-api/fragments-delete", {
|
|
2646
2672
|
method: "POST",
|
|
2647
2673
|
body: JSON.stringify({
|
|
2648
|
-
code
|
|
2674
|
+
code,
|
|
2649
2675
|
id: fragmentId
|
|
2650
2676
|
}),
|
|
2651
2677
|
headers: {
|
|
@@ -2655,7 +2681,7 @@ function useRemoveFragment(username, fragmentId) {
|
|
|
2655
2681
|
},
|
|
2656
2682
|
onSuccess() {
|
|
2657
2683
|
getQueryClient().setQueryData(
|
|
2658
|
-
getFragmentsQueryOptions(username).queryKey,
|
|
2684
|
+
getFragmentsQueryOptions(username, code).queryKey,
|
|
2659
2685
|
(data) => [...data ?? []].filter(({ id }) => id !== fragmentId)
|
|
2660
2686
|
);
|
|
2661
2687
|
}
|
|
@@ -2774,11 +2800,10 @@ var queries_exports = {};
|
|
|
2774
2800
|
__export(queries_exports, {
|
|
2775
2801
|
getDecodeMemoQueryOptions: () => getDecodeMemoQueryOptions
|
|
2776
2802
|
});
|
|
2777
|
-
function getDecodeMemoQueryOptions(username, memo) {
|
|
2803
|
+
function getDecodeMemoQueryOptions(username, memo, accessToken) {
|
|
2778
2804
|
return reactQuery.queryOptions({
|
|
2779
2805
|
queryKey: ["integrations", "hivesigner", "decode-memo", username],
|
|
2780
2806
|
queryFn: async () => {
|
|
2781
|
-
const accessToken = getAccessToken(username);
|
|
2782
2807
|
if (accessToken) {
|
|
2783
2808
|
const hsClient = new hs__default.default.Client({
|
|
2784
2809
|
accessToken
|
|
@@ -2795,12 +2820,12 @@ var HiveSignerIntegration = {
|
|
|
2795
2820
|
};
|
|
2796
2821
|
|
|
2797
2822
|
// src/modules/integrations/3speak/queries/get-account-token-query-options.ts
|
|
2798
|
-
function getAccountTokenQueryOptions(username) {
|
|
2823
|
+
function getAccountTokenQueryOptions(username, accessToken) {
|
|
2799
2824
|
return reactQuery.queryOptions({
|
|
2800
2825
|
queryKey: ["integrations", "3speak", "authenticate", username],
|
|
2801
|
-
enabled: !!username,
|
|
2826
|
+
enabled: !!username && !!accessToken,
|
|
2802
2827
|
queryFn: async () => {
|
|
2803
|
-
if (!username) {
|
|
2828
|
+
if (!username || !accessToken) {
|
|
2804
2829
|
throw new Error("[SDK][Integrations][3Speak] \u2013\xA0anon user");
|
|
2805
2830
|
}
|
|
2806
2831
|
const fetchApi = getBoundFetch();
|
|
@@ -2814,7 +2839,8 @@ function getAccountTokenQueryOptions(username) {
|
|
|
2814
2839
|
);
|
|
2815
2840
|
const memoQueryOptions = HiveSignerIntegration.queries.getDecodeMemoQueryOptions(
|
|
2816
2841
|
username,
|
|
2817
|
-
(await response.json()).memo
|
|
2842
|
+
(await response.json()).memo,
|
|
2843
|
+
accessToken
|
|
2818
2844
|
);
|
|
2819
2845
|
await getQueryClient().prefetchQuery(memoQueryOptions);
|
|
2820
2846
|
const { memoDecoded } = getQueryClient().getQueryData(
|
|
@@ -2824,17 +2850,23 @@ function getAccountTokenQueryOptions(username) {
|
|
|
2824
2850
|
}
|
|
2825
2851
|
});
|
|
2826
2852
|
}
|
|
2827
|
-
function getAccountVideosQueryOptions(username) {
|
|
2853
|
+
function getAccountVideosQueryOptions(username, accessToken) {
|
|
2828
2854
|
return reactQuery.queryOptions({
|
|
2829
2855
|
queryKey: ["integrations", "3speak", "videos", username],
|
|
2830
|
-
enabled: !!username,
|
|
2856
|
+
enabled: !!username && !!accessToken,
|
|
2831
2857
|
queryFn: async () => {
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
const
|
|
2836
|
-
|
|
2858
|
+
if (!username || !accessToken) {
|
|
2859
|
+
throw new Error("[SDK][Integrations][3Speak] \u2013\xA0anon user");
|
|
2860
|
+
}
|
|
2861
|
+
const tokenQueryOptions = getAccountTokenQueryOptions(
|
|
2862
|
+
username,
|
|
2863
|
+
accessToken
|
|
2837
2864
|
);
|
|
2865
|
+
await getQueryClient().prefetchQuery(tokenQueryOptions);
|
|
2866
|
+
const token = getQueryClient().getQueryData(tokenQueryOptions.queryKey);
|
|
2867
|
+
if (!token) {
|
|
2868
|
+
throw new Error("[SDK][Integrations][3Speak] \u2013 missing account token");
|
|
2869
|
+
}
|
|
2838
2870
|
const fetchApi = getBoundFetch();
|
|
2839
2871
|
const response = await fetchApi(
|
|
2840
2872
|
`https://studio.3speak.tv/mobile/api/my-videos`,
|
|
@@ -2945,13 +2977,13 @@ function getAccountRcQueryOptions(username) {
|
|
|
2945
2977
|
enabled: !!username
|
|
2946
2978
|
});
|
|
2947
2979
|
}
|
|
2948
|
-
function getGameStatusCheckQueryOptions(username, gameType) {
|
|
2980
|
+
function getGameStatusCheckQueryOptions(username, code, gameType) {
|
|
2949
2981
|
return reactQuery.queryOptions({
|
|
2950
2982
|
queryKey: ["games", "status-check", gameType, username],
|
|
2951
|
-
enabled: !!username,
|
|
2983
|
+
enabled: !!username && !!code,
|
|
2952
2984
|
queryFn: async () => {
|
|
2953
|
-
if (!username) {
|
|
2954
|
-
throw new Error("[SDK][Games] \u2013
|
|
2985
|
+
if (!username || !code) {
|
|
2986
|
+
throw new Error("[SDK][Games] \u2013 missing auth");
|
|
2955
2987
|
}
|
|
2956
2988
|
const fetchApi = getBoundFetch();
|
|
2957
2989
|
const response = await fetchApi(
|
|
@@ -2960,7 +2992,7 @@ function getGameStatusCheckQueryOptions(username, gameType) {
|
|
|
2960
2992
|
method: "POST",
|
|
2961
2993
|
body: JSON.stringify({
|
|
2962
2994
|
game_type: gameType,
|
|
2963
|
-
code
|
|
2995
|
+
code
|
|
2964
2996
|
}),
|
|
2965
2997
|
headers: {
|
|
2966
2998
|
"Content-Type": "application/json"
|
|
@@ -2971,7 +3003,7 @@ function getGameStatusCheckQueryOptions(username, gameType) {
|
|
|
2971
3003
|
}
|
|
2972
3004
|
});
|
|
2973
3005
|
}
|
|
2974
|
-
function useGameClaim(username, gameType, key) {
|
|
3006
|
+
function useGameClaim(username, code, gameType, key) {
|
|
2975
3007
|
const { mutateAsync: recordActivity } = useRecordActivity(
|
|
2976
3008
|
username,
|
|
2977
3009
|
"spin-rolled"
|
|
@@ -2979,8 +3011,8 @@ function useGameClaim(username, gameType, key) {
|
|
|
2979
3011
|
return reactQuery.useMutation({
|
|
2980
3012
|
mutationKey: ["games", "post", gameType, username],
|
|
2981
3013
|
mutationFn: async () => {
|
|
2982
|
-
if (!username) {
|
|
2983
|
-
throw new Error("[SDK][Games] \u2013
|
|
3014
|
+
if (!username || !code) {
|
|
3015
|
+
throw new Error("[SDK][Games] \u2013 missing auth");
|
|
2984
3016
|
}
|
|
2985
3017
|
const fetchApi = getBoundFetch();
|
|
2986
3018
|
const response = await fetchApi(
|
|
@@ -2989,7 +3021,7 @@ function useGameClaim(username, gameType, key) {
|
|
|
2989
3021
|
method: "POST",
|
|
2990
3022
|
body: JSON.stringify({
|
|
2991
3023
|
game_type: gameType,
|
|
2992
|
-
code
|
|
3024
|
+
code,
|
|
2993
3025
|
key
|
|
2994
3026
|
}),
|
|
2995
3027
|
headers: {
|
|
@@ -3154,15 +3186,18 @@ function getCommunityPermissions({
|
|
|
3154
3186
|
isModerator
|
|
3155
3187
|
};
|
|
3156
3188
|
}
|
|
3157
|
-
function getNotificationsUnreadCountQueryOptions(activeUsername) {
|
|
3189
|
+
function getNotificationsUnreadCountQueryOptions(activeUsername, code) {
|
|
3158
3190
|
return reactQuery.queryOptions({
|
|
3159
3191
|
queryKey: ["notifications", "unread", activeUsername],
|
|
3160
3192
|
queryFn: async () => {
|
|
3193
|
+
if (!code) {
|
|
3194
|
+
return 0;
|
|
3195
|
+
}
|
|
3161
3196
|
const response = await fetch(
|
|
3162
3197
|
`${CONFIG.privateApiHost}/private-api/notifications/unread`,
|
|
3163
3198
|
{
|
|
3164
3199
|
method: "POST",
|
|
3165
|
-
body: JSON.stringify({ code
|
|
3200
|
+
body: JSON.stringify({ code }),
|
|
3166
3201
|
headers: {
|
|
3167
3202
|
"Content-Type": "application/json"
|
|
3168
3203
|
}
|
|
@@ -3171,17 +3206,20 @@ function getNotificationsUnreadCountQueryOptions(activeUsername) {
|
|
|
3171
3206
|
const data = await response.json();
|
|
3172
3207
|
return data.count;
|
|
3173
3208
|
},
|
|
3174
|
-
enabled: !!activeUsername,
|
|
3209
|
+
enabled: !!activeUsername && !!code,
|
|
3175
3210
|
initialData: 0,
|
|
3176
3211
|
refetchInterval: 6e4
|
|
3177
3212
|
});
|
|
3178
3213
|
}
|
|
3179
|
-
function getNotificationsInfiniteQueryOptions(activeUsername, filter = void 0) {
|
|
3214
|
+
function getNotificationsInfiniteQueryOptions(activeUsername, code, filter = void 0) {
|
|
3180
3215
|
return reactQuery.infiniteQueryOptions({
|
|
3181
3216
|
queryKey: ["notifications", activeUsername, filter],
|
|
3182
3217
|
queryFn: async ({ pageParam }) => {
|
|
3218
|
+
if (!code) {
|
|
3219
|
+
return [];
|
|
3220
|
+
}
|
|
3183
3221
|
const data = {
|
|
3184
|
-
code
|
|
3222
|
+
code,
|
|
3185
3223
|
filter,
|
|
3186
3224
|
since: pageParam,
|
|
3187
3225
|
user: void 0
|
|
@@ -3198,7 +3236,7 @@ function getNotificationsInfiniteQueryOptions(activeUsername, filter = void 0) {
|
|
|
3198
3236
|
);
|
|
3199
3237
|
return response.json();
|
|
3200
3238
|
},
|
|
3201
|
-
enabled: !!activeUsername,
|
|
3239
|
+
enabled: !!activeUsername && !!code,
|
|
3202
3240
|
initialData: { pages: [], pageParams: [] },
|
|
3203
3241
|
initialPageParam: "",
|
|
3204
3242
|
getNextPageParam: (lastPage) => lastPage?.[lastPage.length - 1]?.id ?? "",
|
|
@@ -3251,16 +3289,19 @@ var NotificationViewType = /* @__PURE__ */ ((NotificationViewType2) => {
|
|
|
3251
3289
|
})(NotificationViewType || {});
|
|
3252
3290
|
|
|
3253
3291
|
// src/modules/notifications/queries/get-notifications-settings-query-options.ts
|
|
3254
|
-
function getNotificationsSettingsQueryOptions(activeUsername) {
|
|
3292
|
+
function getNotificationsSettingsQueryOptions(activeUsername, code) {
|
|
3255
3293
|
return reactQuery.queryOptions({
|
|
3256
3294
|
queryKey: ["notifications", "settings", activeUsername],
|
|
3257
3295
|
queryFn: async () => {
|
|
3258
3296
|
let token = activeUsername + "-web";
|
|
3297
|
+
if (!code) {
|
|
3298
|
+
throw new Error("Missing access token");
|
|
3299
|
+
}
|
|
3259
3300
|
const response = await fetch(
|
|
3260
3301
|
CONFIG.privateApiHost + "/private-api/detail-device",
|
|
3261
3302
|
{
|
|
3262
3303
|
body: JSON.stringify({
|
|
3263
|
-
code
|
|
3304
|
+
code,
|
|
3264
3305
|
username: activeUsername,
|
|
3265
3306
|
token
|
|
3266
3307
|
}),
|
|
@@ -3275,7 +3316,7 @@ function getNotificationsSettingsQueryOptions(activeUsername) {
|
|
|
3275
3316
|
}
|
|
3276
3317
|
return response.json();
|
|
3277
3318
|
},
|
|
3278
|
-
enabled: !!activeUsername,
|
|
3319
|
+
enabled: !!activeUsername && !!code,
|
|
3279
3320
|
refetchOnMount: false,
|
|
3280
3321
|
initialData: () => {
|
|
3281
3322
|
const wasMutedPreviously = typeof window !== "undefined" ? localStorage.getItem("notifications") !== "true" : false;
|
|
@@ -3569,8 +3610,9 @@ function getMarketDataQueryOptions(coin, vsCurrency, fromTs, toTs) {
|
|
|
3569
3610
|
return reactQuery.queryOptions({
|
|
3570
3611
|
queryKey: ["market", "data", coin, vsCurrency, fromTs, toTs],
|
|
3571
3612
|
queryFn: async ({ signal }) => {
|
|
3613
|
+
const fetchApi = getBoundFetch();
|
|
3572
3614
|
const url = `https://api.coingecko.com/api/v3/coins/${coin}/market_chart/range?vs_currency=${vsCurrency}&from=${fromTs}&to=${toTs}`;
|
|
3573
|
-
const response = await
|
|
3615
|
+
const response = await fetchApi(url, { signal });
|
|
3574
3616
|
if (!response.ok) {
|
|
3575
3617
|
throw new Error(`Failed to fetch market data: ${response.status}`);
|
|
3576
3618
|
}
|
|
@@ -3578,6 +3620,46 @@ function getMarketDataQueryOptions(coin, vsCurrency, fromTs, toTs) {
|
|
|
3578
3620
|
}
|
|
3579
3621
|
});
|
|
3580
3622
|
}
|
|
3623
|
+
|
|
3624
|
+
// src/modules/market/requests.ts
|
|
3625
|
+
async function parseJsonResponse(response) {
|
|
3626
|
+
const data = await response.json();
|
|
3627
|
+
if (!response.ok) {
|
|
3628
|
+
const error = new Error(`Request failed with status ${response.status}`);
|
|
3629
|
+
error.status = response.status;
|
|
3630
|
+
error.data = data;
|
|
3631
|
+
throw error;
|
|
3632
|
+
}
|
|
3633
|
+
return data;
|
|
3634
|
+
}
|
|
3635
|
+
async function getMarketData(coin, vsCurrency, fromTs, toTs) {
|
|
3636
|
+
const fetchApi = getBoundFetch();
|
|
3637
|
+
const url = `https://api.coingecko.com/api/v3/coins/${coin}/market_chart/range?vs_currency=${vsCurrency}&from=${fromTs}&to=${toTs}`;
|
|
3638
|
+
const response = await fetchApi(url);
|
|
3639
|
+
return parseJsonResponse(response);
|
|
3640
|
+
}
|
|
3641
|
+
async function getCurrencyRate(cur) {
|
|
3642
|
+
if (cur === "hbd") {
|
|
3643
|
+
return 1;
|
|
3644
|
+
}
|
|
3645
|
+
const fetchApi = getBoundFetch();
|
|
3646
|
+
const url = `https://api.coingecko.com/api/v3/simple/price?ids=hive_dollar&vs_currencies=${cur}`;
|
|
3647
|
+
const response = await fetchApi(url);
|
|
3648
|
+
const data = await parseJsonResponse(response);
|
|
3649
|
+
return data.hive_dollar[cur];
|
|
3650
|
+
}
|
|
3651
|
+
async function getCurrencyTokenRate(currency, token) {
|
|
3652
|
+
const fetchApi = getBoundFetch();
|
|
3653
|
+
const response = await fetchApi(
|
|
3654
|
+
CONFIG.privateApiHost + `/private-api/market-data/${currency === "hbd" ? "usd" : currency}/${token}`
|
|
3655
|
+
);
|
|
3656
|
+
return parseJsonResponse(response);
|
|
3657
|
+
}
|
|
3658
|
+
async function getCurrencyRates() {
|
|
3659
|
+
const fetchApi = getBoundFetch();
|
|
3660
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/market-data/latest");
|
|
3661
|
+
return parseJsonResponse(response);
|
|
3662
|
+
}
|
|
3581
3663
|
function getPointsQueryOptions(username, filter = 0) {
|
|
3582
3664
|
return reactQuery.queryOptions({
|
|
3583
3665
|
queryKey: ["points", username, filter],
|
|
@@ -3918,6 +4000,311 @@ function getBoostPlusAccountPricesQueryOptions(account, accessToken) {
|
|
|
3918
4000
|
});
|
|
3919
4001
|
}
|
|
3920
4002
|
|
|
4003
|
+
// src/modules/private-api/requests.ts
|
|
4004
|
+
async function parseJsonResponse2(response) {
|
|
4005
|
+
if (!response.ok) {
|
|
4006
|
+
let errorData = void 0;
|
|
4007
|
+
try {
|
|
4008
|
+
errorData = await response.json();
|
|
4009
|
+
} catch {
|
|
4010
|
+
errorData = void 0;
|
|
4011
|
+
}
|
|
4012
|
+
const error = new Error(`Request failed with status ${response.status}`);
|
|
4013
|
+
error.status = response.status;
|
|
4014
|
+
error.data = errorData;
|
|
4015
|
+
throw error;
|
|
4016
|
+
}
|
|
4017
|
+
return await response.json();
|
|
4018
|
+
}
|
|
4019
|
+
async function signUp(username, email, referral) {
|
|
4020
|
+
const fetchApi = getBoundFetch();
|
|
4021
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/account-create", {
|
|
4022
|
+
method: "POST",
|
|
4023
|
+
headers: {
|
|
4024
|
+
"Content-Type": "application/json"
|
|
4025
|
+
},
|
|
4026
|
+
body: JSON.stringify({ username, email, referral })
|
|
4027
|
+
});
|
|
4028
|
+
const data = await parseJsonResponse2(response);
|
|
4029
|
+
return { status: response.status, data };
|
|
4030
|
+
}
|
|
4031
|
+
async function subscribeEmail(email) {
|
|
4032
|
+
const fetchApi = getBoundFetch();
|
|
4033
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/subscribe", {
|
|
4034
|
+
method: "POST",
|
|
4035
|
+
headers: {
|
|
4036
|
+
"Content-Type": "application/json"
|
|
4037
|
+
},
|
|
4038
|
+
body: JSON.stringify({ email })
|
|
4039
|
+
});
|
|
4040
|
+
const data = await parseJsonResponse2(response);
|
|
4041
|
+
return { status: response.status, data };
|
|
4042
|
+
}
|
|
4043
|
+
async function usrActivity(code, ty, bl = "", tx = "") {
|
|
4044
|
+
const params = { code, ty };
|
|
4045
|
+
if (bl) {
|
|
4046
|
+
params.bl = bl;
|
|
4047
|
+
}
|
|
4048
|
+
if (tx) {
|
|
4049
|
+
params.tx = tx;
|
|
4050
|
+
}
|
|
4051
|
+
const fetchApi = getBoundFetch();
|
|
4052
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/usr-activity", {
|
|
4053
|
+
method: "POST",
|
|
4054
|
+
headers: {
|
|
4055
|
+
"Content-Type": "application/json"
|
|
4056
|
+
},
|
|
4057
|
+
body: JSON.stringify(params)
|
|
4058
|
+
});
|
|
4059
|
+
await parseJsonResponse2(response);
|
|
4060
|
+
}
|
|
4061
|
+
async function getNotifications(code, filter, since = null, user = null) {
|
|
4062
|
+
const data = {
|
|
4063
|
+
code
|
|
4064
|
+
};
|
|
4065
|
+
if (filter) {
|
|
4066
|
+
data.filter = filter;
|
|
4067
|
+
}
|
|
4068
|
+
if (since) {
|
|
4069
|
+
data.since = since;
|
|
4070
|
+
}
|
|
4071
|
+
if (user) {
|
|
4072
|
+
data.user = user;
|
|
4073
|
+
}
|
|
4074
|
+
const fetchApi = getBoundFetch();
|
|
4075
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/notifications", {
|
|
4076
|
+
method: "POST",
|
|
4077
|
+
headers: {
|
|
4078
|
+
"Content-Type": "application/json"
|
|
4079
|
+
},
|
|
4080
|
+
body: JSON.stringify(data)
|
|
4081
|
+
});
|
|
4082
|
+
return parseJsonResponse2(response);
|
|
4083
|
+
}
|
|
4084
|
+
async function saveNotificationSetting(code, username, system, allows_notify, notify_types, token) {
|
|
4085
|
+
const data = {
|
|
4086
|
+
code,
|
|
4087
|
+
username,
|
|
4088
|
+
token,
|
|
4089
|
+
system,
|
|
4090
|
+
allows_notify,
|
|
4091
|
+
notify_types
|
|
4092
|
+
};
|
|
4093
|
+
const fetchApi = getBoundFetch();
|
|
4094
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/register-device", {
|
|
4095
|
+
method: "POST",
|
|
4096
|
+
headers: {
|
|
4097
|
+
"Content-Type": "application/json"
|
|
4098
|
+
},
|
|
4099
|
+
body: JSON.stringify(data)
|
|
4100
|
+
});
|
|
4101
|
+
return parseJsonResponse2(response);
|
|
4102
|
+
}
|
|
4103
|
+
async function getNotificationSetting(code, username, token) {
|
|
4104
|
+
const data = { code, username, token };
|
|
4105
|
+
const fetchApi = getBoundFetch();
|
|
4106
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/detail-device", {
|
|
4107
|
+
method: "POST",
|
|
4108
|
+
headers: {
|
|
4109
|
+
"Content-Type": "application/json"
|
|
4110
|
+
},
|
|
4111
|
+
body: JSON.stringify(data)
|
|
4112
|
+
});
|
|
4113
|
+
return parseJsonResponse2(response);
|
|
4114
|
+
}
|
|
4115
|
+
async function markNotifications(code, id) {
|
|
4116
|
+
const data = {
|
|
4117
|
+
code
|
|
4118
|
+
};
|
|
4119
|
+
if (id) {
|
|
4120
|
+
data.id = id;
|
|
4121
|
+
}
|
|
4122
|
+
const fetchApi = getBoundFetch();
|
|
4123
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/notifications/mark", {
|
|
4124
|
+
method: "POST",
|
|
4125
|
+
headers: {
|
|
4126
|
+
"Content-Type": "application/json"
|
|
4127
|
+
},
|
|
4128
|
+
body: JSON.stringify(data)
|
|
4129
|
+
});
|
|
4130
|
+
return parseJsonResponse2(response);
|
|
4131
|
+
}
|
|
4132
|
+
async function addImage(code, url) {
|
|
4133
|
+
const data = { code, url };
|
|
4134
|
+
const fetchApi = getBoundFetch();
|
|
4135
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/images-add", {
|
|
4136
|
+
method: "POST",
|
|
4137
|
+
headers: {
|
|
4138
|
+
"Content-Type": "application/json"
|
|
4139
|
+
},
|
|
4140
|
+
body: JSON.stringify(data)
|
|
4141
|
+
});
|
|
4142
|
+
return parseJsonResponse2(response);
|
|
4143
|
+
}
|
|
4144
|
+
async function uploadImage(file, token, signal) {
|
|
4145
|
+
const fetchApi = getBoundFetch();
|
|
4146
|
+
const formData = new FormData();
|
|
4147
|
+
formData.append("file", file);
|
|
4148
|
+
const response = await fetchApi(`${CONFIG.imageHost}/hs/${token}`, {
|
|
4149
|
+
method: "POST",
|
|
4150
|
+
body: formData,
|
|
4151
|
+
signal
|
|
4152
|
+
});
|
|
4153
|
+
return parseJsonResponse2(response);
|
|
4154
|
+
}
|
|
4155
|
+
async function deleteImage(code, imageId) {
|
|
4156
|
+
const data = { code, id: imageId };
|
|
4157
|
+
const fetchApi = getBoundFetch();
|
|
4158
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/images-delete", {
|
|
4159
|
+
method: "POST",
|
|
4160
|
+
headers: {
|
|
4161
|
+
"Content-Type": "application/json"
|
|
4162
|
+
},
|
|
4163
|
+
body: JSON.stringify(data)
|
|
4164
|
+
});
|
|
4165
|
+
return parseJsonResponse2(response);
|
|
4166
|
+
}
|
|
4167
|
+
async function addDraft(code, title, body, tags, meta) {
|
|
4168
|
+
const data = { code, title, body, tags, meta };
|
|
4169
|
+
const fetchApi = getBoundFetch();
|
|
4170
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/drafts-add", {
|
|
4171
|
+
method: "POST",
|
|
4172
|
+
headers: {
|
|
4173
|
+
"Content-Type": "application/json"
|
|
4174
|
+
},
|
|
4175
|
+
body: JSON.stringify(data)
|
|
4176
|
+
});
|
|
4177
|
+
return parseJsonResponse2(response);
|
|
4178
|
+
}
|
|
4179
|
+
async function updateDraft(code, draftId, title, body, tags, meta) {
|
|
4180
|
+
const data = { code, id: draftId, title, body, tags, meta };
|
|
4181
|
+
const fetchApi = getBoundFetch();
|
|
4182
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/drafts-update", {
|
|
4183
|
+
method: "POST",
|
|
4184
|
+
headers: {
|
|
4185
|
+
"Content-Type": "application/json"
|
|
4186
|
+
},
|
|
4187
|
+
body: JSON.stringify(data)
|
|
4188
|
+
});
|
|
4189
|
+
return parseJsonResponse2(response);
|
|
4190
|
+
}
|
|
4191
|
+
async function deleteDraft(code, draftId) {
|
|
4192
|
+
const data = { code, id: draftId };
|
|
4193
|
+
const fetchApi = getBoundFetch();
|
|
4194
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/drafts-delete", {
|
|
4195
|
+
method: "POST",
|
|
4196
|
+
headers: {
|
|
4197
|
+
"Content-Type": "application/json"
|
|
4198
|
+
},
|
|
4199
|
+
body: JSON.stringify(data)
|
|
4200
|
+
});
|
|
4201
|
+
return parseJsonResponse2(response);
|
|
4202
|
+
}
|
|
4203
|
+
async function addSchedule(code, permlink, title, body, meta, options, schedule, reblog) {
|
|
4204
|
+
const data = {
|
|
4205
|
+
code,
|
|
4206
|
+
permlink,
|
|
4207
|
+
title,
|
|
4208
|
+
body,
|
|
4209
|
+
meta,
|
|
4210
|
+
schedule,
|
|
4211
|
+
reblog
|
|
4212
|
+
};
|
|
4213
|
+
if (options) {
|
|
4214
|
+
data.options = options;
|
|
4215
|
+
}
|
|
4216
|
+
const fetchApi = getBoundFetch();
|
|
4217
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/schedules-add", {
|
|
4218
|
+
method: "POST",
|
|
4219
|
+
headers: {
|
|
4220
|
+
"Content-Type": "application/json"
|
|
4221
|
+
},
|
|
4222
|
+
body: JSON.stringify(data)
|
|
4223
|
+
});
|
|
4224
|
+
return parseJsonResponse2(response);
|
|
4225
|
+
}
|
|
4226
|
+
async function deleteSchedule(code, id) {
|
|
4227
|
+
const data = { code, id };
|
|
4228
|
+
const fetchApi = getBoundFetch();
|
|
4229
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/schedules-delete", {
|
|
4230
|
+
method: "POST",
|
|
4231
|
+
headers: {
|
|
4232
|
+
"Content-Type": "application/json"
|
|
4233
|
+
},
|
|
4234
|
+
body: JSON.stringify(data)
|
|
4235
|
+
});
|
|
4236
|
+
return parseJsonResponse2(response);
|
|
4237
|
+
}
|
|
4238
|
+
async function moveSchedule(code, id) {
|
|
4239
|
+
const data = { code, id };
|
|
4240
|
+
const fetchApi = getBoundFetch();
|
|
4241
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/schedules-move", {
|
|
4242
|
+
method: "POST",
|
|
4243
|
+
headers: {
|
|
4244
|
+
"Content-Type": "application/json"
|
|
4245
|
+
},
|
|
4246
|
+
body: JSON.stringify(data)
|
|
4247
|
+
});
|
|
4248
|
+
return parseJsonResponse2(response);
|
|
4249
|
+
}
|
|
4250
|
+
async function getPromotedPost(code, author, permlink) {
|
|
4251
|
+
const data = { code, author, permlink };
|
|
4252
|
+
const fetchApi = getBoundFetch();
|
|
4253
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/promoted-post", {
|
|
4254
|
+
method: "POST",
|
|
4255
|
+
headers: {
|
|
4256
|
+
"Content-Type": "application/json"
|
|
4257
|
+
},
|
|
4258
|
+
body: JSON.stringify(data)
|
|
4259
|
+
});
|
|
4260
|
+
return parseJsonResponse2(response);
|
|
4261
|
+
}
|
|
4262
|
+
async function onboardEmail(username, email, friend) {
|
|
4263
|
+
const dataBody = {
|
|
4264
|
+
username,
|
|
4265
|
+
email,
|
|
4266
|
+
friend
|
|
4267
|
+
};
|
|
4268
|
+
const fetchApi = getBoundFetch();
|
|
4269
|
+
const response = await fetchApi(
|
|
4270
|
+
CONFIG.privateApiHost + "/private-api/account-create-friend",
|
|
4271
|
+
{
|
|
4272
|
+
method: "POST",
|
|
4273
|
+
headers: {
|
|
4274
|
+
"Content-Type": "application/json"
|
|
4275
|
+
},
|
|
4276
|
+
body: JSON.stringify(dataBody)
|
|
4277
|
+
}
|
|
4278
|
+
);
|
|
4279
|
+
return parseJsonResponse2(response);
|
|
4280
|
+
}
|
|
4281
|
+
|
|
4282
|
+
// src/modules/auth/requests.ts
|
|
4283
|
+
async function hsTokenRenew(code) {
|
|
4284
|
+
const fetchApi = getBoundFetch();
|
|
4285
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/auth-api/hs-token-refresh", {
|
|
4286
|
+
method: "POST",
|
|
4287
|
+
headers: {
|
|
4288
|
+
"Content-Type": "application/json"
|
|
4289
|
+
},
|
|
4290
|
+
body: JSON.stringify({ code })
|
|
4291
|
+
});
|
|
4292
|
+
if (!response.ok) {
|
|
4293
|
+
let data2 = void 0;
|
|
4294
|
+
try {
|
|
4295
|
+
data2 = await response.json();
|
|
4296
|
+
} catch {
|
|
4297
|
+
data2 = void 0;
|
|
4298
|
+
}
|
|
4299
|
+
const error = new Error(`Failed to refresh token: ${response.status}`);
|
|
4300
|
+
error.status = response.status;
|
|
4301
|
+
error.data = data2;
|
|
4302
|
+
throw error;
|
|
4303
|
+
}
|
|
4304
|
+
const data = await response.json();
|
|
4305
|
+
return data;
|
|
4306
|
+
}
|
|
4307
|
+
|
|
3921
4308
|
exports.ACCOUNT_OPERATION_GROUPS = ACCOUNT_OPERATION_GROUPS;
|
|
3922
4309
|
exports.ALL_ACCOUNT_OPERATIONS = ALL_ACCOUNT_OPERATIONS;
|
|
3923
4310
|
exports.ALL_NOTIFY_TYPES = ALL_NOTIFY_TYPES;
|
|
@@ -3933,11 +4320,17 @@ exports.ROLES = ROLES;
|
|
|
3933
4320
|
exports.SortOrder = SortOrder;
|
|
3934
4321
|
exports.Symbol = Symbol2;
|
|
3935
4322
|
exports.ThreeSpeakIntegration = ThreeSpeakIntegration;
|
|
4323
|
+
exports.addDraft = addDraft;
|
|
4324
|
+
exports.addImage = addImage;
|
|
4325
|
+
exports.addSchedule = addSchedule;
|
|
3936
4326
|
exports.broadcastJson = broadcastJson;
|
|
3937
4327
|
exports.buildProfileMetadata = buildProfileMetadata;
|
|
3938
4328
|
exports.checkUsernameWalletsPendingQueryOptions = checkUsernameWalletsPendingQueryOptions;
|
|
3939
4329
|
exports.decodeObj = decodeObj;
|
|
3940
4330
|
exports.dedupeAndSortKeyAuths = dedupeAndSortKeyAuths;
|
|
4331
|
+
exports.deleteDraft = deleteDraft;
|
|
4332
|
+
exports.deleteImage = deleteImage;
|
|
4333
|
+
exports.deleteSchedule = deleteSchedule;
|
|
3941
4334
|
exports.encodeObj = encodeObj;
|
|
3942
4335
|
exports.extractAccountProfile = extractAccountProfile;
|
|
3943
4336
|
exports.getAccessToken = getAccessToken;
|
|
@@ -3967,6 +4360,9 @@ exports.getCommunitySubscribersQueryOptions = getCommunitySubscribersQueryOption
|
|
|
3967
4360
|
exports.getCommunityType = getCommunityType;
|
|
3968
4361
|
exports.getControversialRisingInfiniteQueryOptions = getControversialRisingInfiniteQueryOptions;
|
|
3969
4362
|
exports.getConversionRequestsQueryOptions = getConversionRequestsQueryOptions;
|
|
4363
|
+
exports.getCurrencyRate = getCurrencyRate;
|
|
4364
|
+
exports.getCurrencyRates = getCurrencyRates;
|
|
4365
|
+
exports.getCurrencyTokenRate = getCurrencyTokenRate;
|
|
3970
4366
|
exports.getDeletedEntryQueryOptions = getDeletedEntryQueryOptions;
|
|
3971
4367
|
exports.getDiscoverCurationQueryOptions = getDiscoverCurationQueryOptions;
|
|
3972
4368
|
exports.getDiscoverLeaderboardQueryOptions = getDiscoverLeaderboardQueryOptions;
|
|
@@ -3984,10 +4380,13 @@ exports.getHiveHbdStatsQueryOptions = getHiveHbdStatsQueryOptions;
|
|
|
3984
4380
|
exports.getHivePoshLinksQueryOptions = getHivePoshLinksQueryOptions;
|
|
3985
4381
|
exports.getImagesQueryOptions = getImagesQueryOptions;
|
|
3986
4382
|
exports.getLoginType = getLoginType;
|
|
4383
|
+
exports.getMarketData = getMarketData;
|
|
3987
4384
|
exports.getMarketDataQueryOptions = getMarketDataQueryOptions;
|
|
3988
4385
|
exports.getMarketHistoryQueryOptions = getMarketHistoryQueryOptions;
|
|
3989
4386
|
exports.getMarketStatisticsQueryOptions = getMarketStatisticsQueryOptions;
|
|
3990
4387
|
exports.getMutedUsersQueryOptions = getMutedUsersQueryOptions;
|
|
4388
|
+
exports.getNotificationSetting = getNotificationSetting;
|
|
4389
|
+
exports.getNotifications = getNotifications;
|
|
3991
4390
|
exports.getNotificationsInfiniteQueryOptions = getNotificationsInfiniteQueryOptions;
|
|
3992
4391
|
exports.getNotificationsSettingsQueryOptions = getNotificationsSettingsQueryOptions;
|
|
3993
4392
|
exports.getNotificationsUnreadCountQueryOptions = getNotificationsUnreadCountQueryOptions;
|
|
@@ -4002,6 +4401,7 @@ exports.getPostTipsQueryOptions = getPostTipsQueryOptions;
|
|
|
4002
4401
|
exports.getPostingKey = getPostingKey;
|
|
4003
4402
|
exports.getPostsRankedInfiniteQueryOptions = getPostsRankedInfiniteQueryOptions;
|
|
4004
4403
|
exports.getPromotePriceQueryOptions = getPromotePriceQueryOptions;
|
|
4404
|
+
exports.getPromotedPost = getPromotedPost;
|
|
4005
4405
|
exports.getPromotedPostsQuery = getPromotedPostsQuery;
|
|
4006
4406
|
exports.getProposalQueryOptions = getProposalQueryOptions;
|
|
4007
4407
|
exports.getProposalVotesInfiniteQueryOptions = getProposalVotesInfiniteQueryOptions;
|
|
@@ -4038,18 +4438,27 @@ exports.getWavesFollowingQueryOptions = getWavesFollowingQueryOptions;
|
|
|
4038
4438
|
exports.getWavesTrendingTagsQueryOptions = getWavesTrendingTagsQueryOptions;
|
|
4039
4439
|
exports.getWithdrawRoutesQueryOptions = getWithdrawRoutesQueryOptions;
|
|
4040
4440
|
exports.getWitnessesInfiniteQueryOptions = getWitnessesInfiniteQueryOptions;
|
|
4441
|
+
exports.hsTokenRenew = hsTokenRenew;
|
|
4041
4442
|
exports.isCommunity = isCommunity;
|
|
4042
4443
|
exports.lookupAccountsQueryOptions = lookupAccountsQueryOptions;
|
|
4043
4444
|
exports.makeQueryClient = makeQueryClient;
|
|
4044
4445
|
exports.mapThreadItemsToWaveEntries = mapThreadItemsToWaveEntries;
|
|
4446
|
+
exports.markNotifications = markNotifications;
|
|
4447
|
+
exports.moveSchedule = moveSchedule;
|
|
4045
4448
|
exports.normalizeWaveEntryFromApi = normalizeWaveEntryFromApi;
|
|
4449
|
+
exports.onboardEmail = onboardEmail;
|
|
4046
4450
|
exports.parseAccounts = parseAccounts;
|
|
4047
4451
|
exports.parseAsset = parseAsset;
|
|
4048
4452
|
exports.parseProfileMetadata = parseProfileMetadata;
|
|
4049
4453
|
exports.roleMap = roleMap;
|
|
4454
|
+
exports.saveNotificationSetting = saveNotificationSetting;
|
|
4050
4455
|
exports.searchQueryOptions = searchQueryOptions;
|
|
4456
|
+
exports.signUp = signUp;
|
|
4051
4457
|
exports.sortDiscussions = sortDiscussions;
|
|
4458
|
+
exports.subscribeEmail = subscribeEmail;
|
|
4052
4459
|
exports.toEntryArray = toEntryArray;
|
|
4460
|
+
exports.updateDraft = updateDraft;
|
|
4461
|
+
exports.uploadImage = uploadImage;
|
|
4053
4462
|
exports.useAccountFavouriteAdd = useAccountFavouriteAdd;
|
|
4054
4463
|
exports.useAccountFavouriteDelete = useAccountFavouriteDelete;
|
|
4055
4464
|
exports.useAccountRelationsUpdate = useAccountRelationsUpdate;
|
|
@@ -4070,5 +4479,6 @@ exports.useRemoveFragment = useRemoveFragment;
|
|
|
4070
4479
|
exports.useSignOperationByHivesigner = useSignOperationByHivesigner;
|
|
4071
4480
|
exports.useSignOperationByKey = useSignOperationByKey;
|
|
4072
4481
|
exports.useSignOperationByKeychain = useSignOperationByKeychain;
|
|
4482
|
+
exports.usrActivity = usrActivity;
|
|
4073
4483
|
//# sourceMappingURL=index.cjs.map
|
|
4074
4484
|
//# sourceMappingURL=index.cjs.map
|