@ecency/sdk 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.d.ts +161 -73
- package/dist/browser/index.js +641 -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 +665 -236
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +641 -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) {
|
|
@@ -263,6 +403,11 @@ function getBoundFetch() {
|
|
|
263
403
|
return cachedFetch;
|
|
264
404
|
}
|
|
265
405
|
|
|
406
|
+
// src/modules/core/utils/is-community.ts
|
|
407
|
+
function isCommunity(value) {
|
|
408
|
+
return typeof value === "string" ? /^hive-\d+$/.test(value) : false;
|
|
409
|
+
}
|
|
410
|
+
|
|
266
411
|
// src/modules/core/storage.ts
|
|
267
412
|
var getUser = (username) => {
|
|
268
413
|
try {
|
|
@@ -279,143 +424,6 @@ var getAccessToken = (username) => getUser(username) && getUser(username).access
|
|
|
279
424
|
var getPostingKey = (username) => getUser(username) && getUser(username).postingKey;
|
|
280
425
|
var getLoginType = (username) => getUser(username) && getUser(username).loginType;
|
|
281
426
|
var getRefreshToken = (username) => getUser(username) && getUser(username).refreshToken;
|
|
282
|
-
|
|
283
|
-
// src/modules/keychain/keychain.ts
|
|
284
|
-
var keychain_exports = {};
|
|
285
|
-
__export(keychain_exports, {
|
|
286
|
-
broadcast: () => broadcast,
|
|
287
|
-
customJson: () => customJson,
|
|
288
|
-
handshake: () => handshake
|
|
289
|
-
});
|
|
290
|
-
function handshake() {
|
|
291
|
-
return new Promise((resolve) => {
|
|
292
|
-
window.hive_keychain?.requestHandshake(() => {
|
|
293
|
-
resolve();
|
|
294
|
-
});
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
var broadcast = (account, operations, key, rpc = null) => new Promise((resolve, reject) => {
|
|
298
|
-
window.hive_keychain?.requestBroadcast(
|
|
299
|
-
account,
|
|
300
|
-
operations,
|
|
301
|
-
key,
|
|
302
|
-
(resp) => {
|
|
303
|
-
if (!resp.success) {
|
|
304
|
-
reject({ message: "Operation cancelled" });
|
|
305
|
-
}
|
|
306
|
-
resolve(resp);
|
|
307
|
-
},
|
|
308
|
-
rpc
|
|
309
|
-
);
|
|
310
|
-
});
|
|
311
|
-
var customJson = (account, id, key, json, display_msg, rpc = null) => new Promise((resolve, reject) => {
|
|
312
|
-
window.hive_keychain?.requestCustomJson(
|
|
313
|
-
account,
|
|
314
|
-
id,
|
|
315
|
-
key,
|
|
316
|
-
json,
|
|
317
|
-
display_msg,
|
|
318
|
-
(resp) => {
|
|
319
|
-
if (!resp.success) {
|
|
320
|
-
reject({ message: "Operation cancelled" });
|
|
321
|
-
}
|
|
322
|
-
resolve(resp);
|
|
323
|
-
},
|
|
324
|
-
rpc
|
|
325
|
-
);
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
// src/modules/core/mutations/use-broadcast-mutation.ts
|
|
329
|
-
function useBroadcastMutation(mutationKey = [], username, operations, onSuccess = () => {
|
|
330
|
-
}) {
|
|
331
|
-
return reactQuery.useMutation({
|
|
332
|
-
onSuccess,
|
|
333
|
-
mutationKey: [...mutationKey, username],
|
|
334
|
-
mutationFn: async (payload) => {
|
|
335
|
-
if (!username) {
|
|
336
|
-
throw new Error(
|
|
337
|
-
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
|
338
|
-
);
|
|
339
|
-
}
|
|
340
|
-
const postingKey = getPostingKey(username);
|
|
341
|
-
if (postingKey) {
|
|
342
|
-
const privateKey = dhive.PrivateKey.fromString(postingKey);
|
|
343
|
-
return CONFIG.hiveClient.broadcast.sendOperations(
|
|
344
|
-
operations(payload),
|
|
345
|
-
privateKey
|
|
346
|
-
);
|
|
347
|
-
}
|
|
348
|
-
const loginType = getLoginType(username);
|
|
349
|
-
if (loginType && loginType == "keychain") {
|
|
350
|
-
return keychain_exports.broadcast(
|
|
351
|
-
username,
|
|
352
|
-
operations(payload),
|
|
353
|
-
"Posting"
|
|
354
|
-
).then((r) => r.result);
|
|
355
|
-
}
|
|
356
|
-
let token = getAccessToken(username);
|
|
357
|
-
if (token) {
|
|
358
|
-
const f = getBoundFetch();
|
|
359
|
-
const res = await f("https://hivesigner.com/api/broadcast", {
|
|
360
|
-
method: "POST",
|
|
361
|
-
headers: {
|
|
362
|
-
Authorization: token,
|
|
363
|
-
"Content-Type": "application/json",
|
|
364
|
-
Accept: "application/json"
|
|
365
|
-
},
|
|
366
|
-
body: JSON.stringify({ operations: operations(payload) })
|
|
367
|
-
});
|
|
368
|
-
if (!res.ok) {
|
|
369
|
-
const txt = await res.text().catch(() => "");
|
|
370
|
-
throw new Error(`[Hivesigner] ${res.status} ${res.statusText} ${txt}`);
|
|
371
|
-
}
|
|
372
|
-
const json = await res.json();
|
|
373
|
-
if (json?.errors) {
|
|
374
|
-
throw new Error(`[Hivesigner] ${JSON.stringify(json.errors)}`);
|
|
375
|
-
}
|
|
376
|
-
return json.result;
|
|
377
|
-
}
|
|
378
|
-
throw new Error(
|
|
379
|
-
"[SDK][Broadcast] \u2013 cannot broadcast w/o posting key or token"
|
|
380
|
-
);
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
async function broadcastJson(username, id, payload) {
|
|
385
|
-
if (!username) {
|
|
386
|
-
throw new Error(
|
|
387
|
-
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
|
388
|
-
);
|
|
389
|
-
}
|
|
390
|
-
const jjson = {
|
|
391
|
-
id,
|
|
392
|
-
required_auths: [],
|
|
393
|
-
required_posting_auths: [username],
|
|
394
|
-
json: JSON.stringify(payload)
|
|
395
|
-
};
|
|
396
|
-
const postingKey = getPostingKey(username);
|
|
397
|
-
if (postingKey) {
|
|
398
|
-
const privateKey = dhive.PrivateKey.fromString(postingKey);
|
|
399
|
-
return CONFIG.hiveClient.broadcast.json(
|
|
400
|
-
jjson,
|
|
401
|
-
privateKey
|
|
402
|
-
);
|
|
403
|
-
}
|
|
404
|
-
const loginType = getLoginType(username);
|
|
405
|
-
if (loginType && loginType == "keychain") {
|
|
406
|
-
return keychain_exports.broadcast(username, [["custom_json", jjson]], "Posting").then((r) => r.result);
|
|
407
|
-
}
|
|
408
|
-
let token = getAccessToken(username);
|
|
409
|
-
if (token) {
|
|
410
|
-
const response = await new hs__default.default.Client({
|
|
411
|
-
accessToken: token
|
|
412
|
-
}).customJson([], [username], id, JSON.stringify(payload));
|
|
413
|
-
return response.result;
|
|
414
|
-
}
|
|
415
|
-
throw new Error(
|
|
416
|
-
"[SDK][Broadcast] \u2013 cannot broadcast w/o posting key or token"
|
|
417
|
-
);
|
|
418
|
-
}
|
|
419
427
|
function makeQueryClient() {
|
|
420
428
|
return new reactQuery.QueryClient({
|
|
421
429
|
defaultOptions: {
|
|
@@ -923,13 +931,13 @@ function getAccountSubscriptionsQueryOptions(username) {
|
|
|
923
931
|
}
|
|
924
932
|
});
|
|
925
933
|
}
|
|
926
|
-
function getActiveAccountBookmarksQueryOptions(activeUsername) {
|
|
934
|
+
function getActiveAccountBookmarksQueryOptions(activeUsername, code) {
|
|
927
935
|
return reactQuery.queryOptions({
|
|
928
936
|
queryKey: ["accounts", "bookmarks", activeUsername],
|
|
929
|
-
enabled: !!activeUsername,
|
|
937
|
+
enabled: !!activeUsername && !!code,
|
|
930
938
|
queryFn: async () => {
|
|
931
|
-
if (!activeUsername) {
|
|
932
|
-
throw new Error("[SDK][Accounts][Bookmarks] \u2013
|
|
939
|
+
if (!activeUsername || !code) {
|
|
940
|
+
throw new Error("[SDK][Accounts][Bookmarks] \u2013 missing auth");
|
|
933
941
|
}
|
|
934
942
|
const fetchApi = getBoundFetch();
|
|
935
943
|
const response = await fetchApi(
|
|
@@ -939,20 +947,20 @@ function getActiveAccountBookmarksQueryOptions(activeUsername) {
|
|
|
939
947
|
headers: {
|
|
940
948
|
"Content-Type": "application/json"
|
|
941
949
|
},
|
|
942
|
-
body: JSON.stringify({ code
|
|
950
|
+
body: JSON.stringify({ code })
|
|
943
951
|
}
|
|
944
952
|
);
|
|
945
953
|
return await response.json();
|
|
946
954
|
}
|
|
947
955
|
});
|
|
948
956
|
}
|
|
949
|
-
function getActiveAccountFavouritesQueryOptions(activeUsername) {
|
|
957
|
+
function getActiveAccountFavouritesQueryOptions(activeUsername, code) {
|
|
950
958
|
return reactQuery.queryOptions({
|
|
951
959
|
queryKey: ["accounts", "favourites", activeUsername],
|
|
952
|
-
enabled: !!activeUsername,
|
|
960
|
+
enabled: !!activeUsername && !!code,
|
|
953
961
|
queryFn: async () => {
|
|
954
|
-
if (!activeUsername) {
|
|
955
|
-
throw new Error("[SDK][Accounts][Favourites] \u2013
|
|
962
|
+
if (!activeUsername || !code) {
|
|
963
|
+
throw new Error("[SDK][Accounts][Favourites] \u2013 missing auth");
|
|
956
964
|
}
|
|
957
965
|
const fetchApi = getBoundFetch();
|
|
958
966
|
const response = await fetchApi(
|
|
@@ -962,18 +970,21 @@ function getActiveAccountFavouritesQueryOptions(activeUsername) {
|
|
|
962
970
|
headers: {
|
|
963
971
|
"Content-Type": "application/json"
|
|
964
972
|
},
|
|
965
|
-
body: JSON.stringify({ code
|
|
973
|
+
body: JSON.stringify({ code })
|
|
966
974
|
}
|
|
967
975
|
);
|
|
968
976
|
return await response.json();
|
|
969
977
|
}
|
|
970
978
|
});
|
|
971
979
|
}
|
|
972
|
-
function getAccountRecoveriesQueryOptions(username) {
|
|
980
|
+
function getAccountRecoveriesQueryOptions(username, code) {
|
|
973
981
|
return reactQuery.queryOptions({
|
|
974
|
-
enabled: !!username,
|
|
982
|
+
enabled: !!username && !!code,
|
|
975
983
|
queryKey: ["accounts", "recoveries", username],
|
|
976
984
|
queryFn: async () => {
|
|
985
|
+
if (!username || !code) {
|
|
986
|
+
throw new Error("[SDK][Accounts] Missing username or access token");
|
|
987
|
+
}
|
|
977
988
|
const fetchApi = getBoundFetch();
|
|
978
989
|
const response = await fetchApi(
|
|
979
990
|
CONFIG.privateApiHost + "/private-api/recoveries",
|
|
@@ -982,7 +993,7 @@ function getAccountRecoveriesQueryOptions(username) {
|
|
|
982
993
|
headers: {
|
|
983
994
|
"Content-Type": "application/json"
|
|
984
995
|
},
|
|
985
|
-
body: JSON.stringify({ code
|
|
996
|
+
body: JSON.stringify({ code })
|
|
986
997
|
}
|
|
987
998
|
);
|
|
988
999
|
return response.json();
|
|
@@ -1245,17 +1256,32 @@ function getTrendingTagsQueryOptions(limit = 20) {
|
|
|
1245
1256
|
refetchOnMount: true
|
|
1246
1257
|
});
|
|
1247
1258
|
}
|
|
1248
|
-
function
|
|
1259
|
+
function getTrendingTagsWithStatsQueryOptions(limit = 250) {
|
|
1260
|
+
return reactQuery.infiniteQueryOptions({
|
|
1261
|
+
queryKey: ["posts", "trending-tags", "stats", limit],
|
|
1262
|
+
queryFn: async ({ pageParam: { afterTag } }) => CONFIG.hiveClient.database.call("get_trending_tags", [afterTag, limit]).then(
|
|
1263
|
+
(tags) => tags.filter((tag) => tag.name !== "").filter((tag) => !isCommunity(tag.name))
|
|
1264
|
+
),
|
|
1265
|
+
initialPageParam: { afterTag: "" },
|
|
1266
|
+
getNextPageParam: (lastPage) => lastPage?.length ? { afterTag: lastPage[lastPage.length - 1].name } : void 0,
|
|
1267
|
+
staleTime: Infinity,
|
|
1268
|
+
refetchOnMount: true
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
function getFragmentsQueryOptions(username, code) {
|
|
1249
1272
|
return reactQuery.queryOptions({
|
|
1250
1273
|
queryKey: ["posts", "fragments", username],
|
|
1251
1274
|
queryFn: async () => {
|
|
1275
|
+
if (!code) {
|
|
1276
|
+
return [];
|
|
1277
|
+
}
|
|
1252
1278
|
const fetchApi = getBoundFetch();
|
|
1253
1279
|
const response = await fetchApi(
|
|
1254
1280
|
CONFIG.privateApiHost + "/private-api/fragments",
|
|
1255
1281
|
{
|
|
1256
1282
|
method: "POST",
|
|
1257
1283
|
body: JSON.stringify({
|
|
1258
|
-
code
|
|
1284
|
+
code
|
|
1259
1285
|
}),
|
|
1260
1286
|
headers: {
|
|
1261
1287
|
"Content-Type": "application/json"
|
|
@@ -1264,7 +1290,7 @@ function getFragmentsQueryOptions(username) {
|
|
|
1264
1290
|
);
|
|
1265
1291
|
return response.json();
|
|
1266
1292
|
},
|
|
1267
|
-
enabled: !!username
|
|
1293
|
+
enabled: !!username && !!code
|
|
1268
1294
|
});
|
|
1269
1295
|
}
|
|
1270
1296
|
function getPromotedPostsQuery(type = "feed") {
|
|
@@ -1571,20 +1597,21 @@ function getReblogsQueryOptions(username, activeUsername, limit = 200) {
|
|
|
1571
1597
|
enabled: !!username
|
|
1572
1598
|
});
|
|
1573
1599
|
}
|
|
1574
|
-
function getSchedulesQueryOptions(activeUsername) {
|
|
1600
|
+
function getSchedulesQueryOptions(activeUsername, code) {
|
|
1575
1601
|
return reactQuery.queryOptions({
|
|
1576
1602
|
queryKey: ["posts", "schedules", activeUsername],
|
|
1577
1603
|
queryFn: async () => {
|
|
1578
|
-
if (!activeUsername) {
|
|
1604
|
+
if (!activeUsername || !code) {
|
|
1579
1605
|
return [];
|
|
1580
1606
|
}
|
|
1581
|
-
const
|
|
1607
|
+
const fetchApi = getBoundFetch();
|
|
1608
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/schedules", {
|
|
1582
1609
|
method: "POST",
|
|
1583
1610
|
headers: {
|
|
1584
1611
|
"Content-Type": "application/json"
|
|
1585
1612
|
},
|
|
1586
1613
|
body: JSON.stringify({
|
|
1587
|
-
code
|
|
1614
|
+
code
|
|
1588
1615
|
})
|
|
1589
1616
|
});
|
|
1590
1617
|
if (!response.ok) {
|
|
@@ -1592,23 +1619,24 @@ function getSchedulesQueryOptions(activeUsername) {
|
|
|
1592
1619
|
}
|
|
1593
1620
|
return response.json();
|
|
1594
1621
|
},
|
|
1595
|
-
enabled: !!activeUsername
|
|
1622
|
+
enabled: !!activeUsername && !!code
|
|
1596
1623
|
});
|
|
1597
1624
|
}
|
|
1598
|
-
function getDraftsQueryOptions(activeUsername) {
|
|
1625
|
+
function getDraftsQueryOptions(activeUsername, code) {
|
|
1599
1626
|
return reactQuery.queryOptions({
|
|
1600
1627
|
queryKey: ["posts", "drafts", activeUsername],
|
|
1601
1628
|
queryFn: async () => {
|
|
1602
|
-
if (!activeUsername) {
|
|
1629
|
+
if (!activeUsername || !code) {
|
|
1603
1630
|
return [];
|
|
1604
1631
|
}
|
|
1605
|
-
const
|
|
1632
|
+
const fetchApi = getBoundFetch();
|
|
1633
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/drafts", {
|
|
1606
1634
|
method: "POST",
|
|
1607
1635
|
headers: {
|
|
1608
1636
|
"Content-Type": "application/json"
|
|
1609
1637
|
},
|
|
1610
1638
|
body: JSON.stringify({
|
|
1611
|
-
code
|
|
1639
|
+
code
|
|
1612
1640
|
})
|
|
1613
1641
|
});
|
|
1614
1642
|
if (!response.ok) {
|
|
@@ -1616,17 +1644,18 @@ function getDraftsQueryOptions(activeUsername) {
|
|
|
1616
1644
|
}
|
|
1617
1645
|
return response.json();
|
|
1618
1646
|
},
|
|
1619
|
-
enabled: !!activeUsername
|
|
1647
|
+
enabled: !!activeUsername && !!code
|
|
1620
1648
|
});
|
|
1621
1649
|
}
|
|
1622
|
-
async function fetchUserImages(
|
|
1623
|
-
const
|
|
1650
|
+
async function fetchUserImages(code) {
|
|
1651
|
+
const fetchApi = getBoundFetch();
|
|
1652
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/images", {
|
|
1624
1653
|
method: "POST",
|
|
1625
1654
|
headers: {
|
|
1626
1655
|
"Content-Type": "application/json"
|
|
1627
1656
|
},
|
|
1628
1657
|
body: JSON.stringify({
|
|
1629
|
-
code
|
|
1658
|
+
code
|
|
1630
1659
|
})
|
|
1631
1660
|
});
|
|
1632
1661
|
if (!response.ok) {
|
|
@@ -1634,28 +1663,28 @@ async function fetchUserImages(username) {
|
|
|
1634
1663
|
}
|
|
1635
1664
|
return response.json();
|
|
1636
1665
|
}
|
|
1637
|
-
function getImagesQueryOptions(username) {
|
|
1666
|
+
function getImagesQueryOptions(username, code) {
|
|
1638
1667
|
return reactQuery.queryOptions({
|
|
1639
1668
|
queryKey: ["posts", "images", username],
|
|
1640
1669
|
queryFn: async () => {
|
|
1641
|
-
if (!username) {
|
|
1670
|
+
if (!username || !code) {
|
|
1642
1671
|
return [];
|
|
1643
1672
|
}
|
|
1644
|
-
return fetchUserImages(
|
|
1673
|
+
return fetchUserImages(code);
|
|
1645
1674
|
},
|
|
1646
|
-
enabled: !!username
|
|
1675
|
+
enabled: !!username && !!code
|
|
1647
1676
|
});
|
|
1648
1677
|
}
|
|
1649
|
-
function getGalleryImagesQueryOptions(activeUsername) {
|
|
1678
|
+
function getGalleryImagesQueryOptions(activeUsername, code) {
|
|
1650
1679
|
return reactQuery.queryOptions({
|
|
1651
1680
|
queryKey: ["posts", "gallery-images", activeUsername],
|
|
1652
1681
|
queryFn: async () => {
|
|
1653
|
-
if (!activeUsername) {
|
|
1682
|
+
if (!activeUsername || !code) {
|
|
1654
1683
|
return [];
|
|
1655
1684
|
}
|
|
1656
|
-
return fetchUserImages(
|
|
1685
|
+
return fetchUserImages(code);
|
|
1657
1686
|
},
|
|
1658
|
-
enabled: !!activeUsername
|
|
1687
|
+
enabled: !!activeUsername && !!code
|
|
1659
1688
|
});
|
|
1660
1689
|
}
|
|
1661
1690
|
function getCommentHistoryQueryOptions(author, permlink, onlyMeta = false) {
|
|
@@ -2051,12 +2080,13 @@ function getAccountVoteHistoryInfiniteQueryOptions(username, options) {
|
|
|
2051
2080
|
}
|
|
2052
2081
|
|
|
2053
2082
|
// src/modules/accounts/mutations/use-account-update.ts
|
|
2054
|
-
function useAccountUpdate(username) {
|
|
2083
|
+
function useAccountUpdate(username, accessToken, auth) {
|
|
2055
2084
|
const queryClient = reactQuery.useQueryClient();
|
|
2056
2085
|
const { data } = reactQuery.useQuery(getAccountFullQueryOptions(username));
|
|
2057
2086
|
return useBroadcastMutation(
|
|
2058
2087
|
["accounts", "update"],
|
|
2059
2088
|
username,
|
|
2089
|
+
accessToken,
|
|
2060
2090
|
(payload) => {
|
|
2061
2091
|
if (!data) {
|
|
2062
2092
|
throw new Error("[SDK][Accounts] \u2013 cannot update not existing account");
|
|
@@ -2080,7 +2110,7 @@ function useAccountUpdate(username) {
|
|
|
2080
2110
|
]
|
|
2081
2111
|
];
|
|
2082
2112
|
},
|
|
2083
|
-
(
|
|
2113
|
+
(_data, variables) => queryClient.setQueryData(
|
|
2084
2114
|
getAccountFullQueryOptions(username).queryKey,
|
|
2085
2115
|
(data2) => {
|
|
2086
2116
|
if (!data2) {
|
|
@@ -2094,7 +2124,8 @@ function useAccountUpdate(username) {
|
|
|
2094
2124
|
});
|
|
2095
2125
|
return obj;
|
|
2096
2126
|
}
|
|
2097
|
-
)
|
|
2127
|
+
),
|
|
2128
|
+
auth
|
|
2098
2129
|
);
|
|
2099
2130
|
}
|
|
2100
2131
|
function useAccountRelationsUpdate(reference, target, onSuccess, onError) {
|
|
@@ -2136,12 +2167,12 @@ function useAccountRelationsUpdate(reference, target, onSuccess, onError) {
|
|
|
2136
2167
|
}
|
|
2137
2168
|
});
|
|
2138
2169
|
}
|
|
2139
|
-
function useBookmarkAdd(username, onSuccess, onError) {
|
|
2170
|
+
function useBookmarkAdd(username, code, onSuccess, onError) {
|
|
2140
2171
|
return reactQuery.useMutation({
|
|
2141
2172
|
mutationKey: ["accounts", "bookmarks", "add", username],
|
|
2142
2173
|
mutationFn: async ({ author, permlink }) => {
|
|
2143
|
-
if (!username) {
|
|
2144
|
-
throw new Error("[SDK][Account][Bookmarks] \u2013
|
|
2174
|
+
if (!username || !code) {
|
|
2175
|
+
throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
|
|
2145
2176
|
}
|
|
2146
2177
|
const fetchApi = getBoundFetch();
|
|
2147
2178
|
const response = await fetchApi(
|
|
@@ -2154,7 +2185,7 @@ function useBookmarkAdd(username, onSuccess, onError) {
|
|
|
2154
2185
|
body: JSON.stringify({
|
|
2155
2186
|
author,
|
|
2156
2187
|
permlink,
|
|
2157
|
-
code
|
|
2188
|
+
code
|
|
2158
2189
|
})
|
|
2159
2190
|
}
|
|
2160
2191
|
);
|
|
@@ -2169,12 +2200,12 @@ function useBookmarkAdd(username, onSuccess, onError) {
|
|
|
2169
2200
|
onError
|
|
2170
2201
|
});
|
|
2171
2202
|
}
|
|
2172
|
-
function useBookmarkDelete(username, onSuccess, onError) {
|
|
2203
|
+
function useBookmarkDelete(username, code, onSuccess, onError) {
|
|
2173
2204
|
return reactQuery.useMutation({
|
|
2174
2205
|
mutationKey: ["accounts", "bookmarks", "delete", username],
|
|
2175
2206
|
mutationFn: async (bookmarkId) => {
|
|
2176
|
-
if (!username) {
|
|
2177
|
-
throw new Error("[SDK][Account][Bookmarks] \u2013
|
|
2207
|
+
if (!username || !code) {
|
|
2208
|
+
throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
|
|
2178
2209
|
}
|
|
2179
2210
|
const fetchApi = getBoundFetch();
|
|
2180
2211
|
const response = await fetchApi(
|
|
@@ -2186,7 +2217,7 @@ function useBookmarkDelete(username, onSuccess, onError) {
|
|
|
2186
2217
|
},
|
|
2187
2218
|
body: JSON.stringify({
|
|
2188
2219
|
id: bookmarkId,
|
|
2189
|
-
code
|
|
2220
|
+
code
|
|
2190
2221
|
})
|
|
2191
2222
|
}
|
|
2192
2223
|
);
|
|
@@ -2201,12 +2232,12 @@ function useBookmarkDelete(username, onSuccess, onError) {
|
|
|
2201
2232
|
onError
|
|
2202
2233
|
});
|
|
2203
2234
|
}
|
|
2204
|
-
function useAccountFavouriteAdd(username, onSuccess, onError) {
|
|
2235
|
+
function useAccountFavouriteAdd(username, code, onSuccess, onError) {
|
|
2205
2236
|
return reactQuery.useMutation({
|
|
2206
2237
|
mutationKey: ["accounts", "favourites", "add", username],
|
|
2207
2238
|
mutationFn: async (account) => {
|
|
2208
|
-
if (!username) {
|
|
2209
|
-
throw new Error("[SDK][Account][Bookmarks] \u2013
|
|
2239
|
+
if (!username || !code) {
|
|
2240
|
+
throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
|
|
2210
2241
|
}
|
|
2211
2242
|
const fetchApi = getBoundFetch();
|
|
2212
2243
|
const response = await fetchApi(
|
|
@@ -2218,7 +2249,7 @@ function useAccountFavouriteAdd(username, onSuccess, onError) {
|
|
|
2218
2249
|
},
|
|
2219
2250
|
body: JSON.stringify({
|
|
2220
2251
|
account,
|
|
2221
|
-
code
|
|
2252
|
+
code
|
|
2222
2253
|
})
|
|
2223
2254
|
}
|
|
2224
2255
|
);
|
|
@@ -2233,12 +2264,12 @@ function useAccountFavouriteAdd(username, onSuccess, onError) {
|
|
|
2233
2264
|
onError
|
|
2234
2265
|
});
|
|
2235
2266
|
}
|
|
2236
|
-
function useAccountFavouriteDelete(username, onSuccess, onError) {
|
|
2267
|
+
function useAccountFavouriteDelete(username, code, onSuccess, onError) {
|
|
2237
2268
|
return reactQuery.useMutation({
|
|
2238
2269
|
mutationKey: ["accounts", "favourites", "add", username],
|
|
2239
2270
|
mutationFn: async (account) => {
|
|
2240
|
-
if (!username) {
|
|
2241
|
-
throw new Error("[SDK][Account][Bookmarks] \u2013
|
|
2271
|
+
if (!username || !code) {
|
|
2272
|
+
throw new Error("[SDK][Account][Bookmarks] \u2013 missing auth");
|
|
2242
2273
|
}
|
|
2243
2274
|
const fetchApi = getBoundFetch();
|
|
2244
2275
|
const response = await fetchApi(
|
|
@@ -2250,7 +2281,7 @@ function useAccountFavouriteDelete(username, onSuccess, onError) {
|
|
|
2250
2281
|
},
|
|
2251
2282
|
body: JSON.stringify({
|
|
2252
2283
|
account,
|
|
2253
|
-
code
|
|
2284
|
+
code
|
|
2254
2285
|
})
|
|
2255
2286
|
}
|
|
2256
2287
|
);
|
|
@@ -2408,7 +2439,7 @@ function useAccountRevokePosting(username, options) {
|
|
|
2408
2439
|
}
|
|
2409
2440
|
});
|
|
2410
2441
|
}
|
|
2411
|
-
function useAccountUpdateRecovery(username, options) {
|
|
2442
|
+
function useAccountUpdateRecovery(username, code, options) {
|
|
2412
2443
|
const { data } = reactQuery.useQuery(getAccountFullQueryOptions(username));
|
|
2413
2444
|
return reactQuery.useMutation({
|
|
2414
2445
|
mutationKey: ["accounts", "recovery", data?.name],
|
|
@@ -2424,11 +2455,14 @@ function useAccountUpdateRecovery(username, options) {
|
|
|
2424
2455
|
extensions: []
|
|
2425
2456
|
};
|
|
2426
2457
|
if (type === "ecency") {
|
|
2458
|
+
if (!code) {
|
|
2459
|
+
throw new Error("[SDK][Accounts] \u2013 missing access token");
|
|
2460
|
+
}
|
|
2427
2461
|
const fetchApi = getBoundFetch();
|
|
2428
2462
|
return fetchApi(CONFIG.privateApiHost + "/private-api/recoveries-add", {
|
|
2429
2463
|
method: "POST",
|
|
2430
2464
|
body: JSON.stringify({
|
|
2431
|
-
code
|
|
2465
|
+
code,
|
|
2432
2466
|
email,
|
|
2433
2467
|
publicKeys: [
|
|
2434
2468
|
...data.owner.key_auths,
|
|
@@ -2552,17 +2586,20 @@ function getChainPropertiesQueryOptions() {
|
|
|
2552
2586
|
}
|
|
2553
2587
|
});
|
|
2554
2588
|
}
|
|
2555
|
-
function useAddFragment(username) {
|
|
2589
|
+
function useAddFragment(username, code) {
|
|
2556
2590
|
return reactQuery.useMutation({
|
|
2557
2591
|
mutationKey: ["posts", "add-fragment", username],
|
|
2558
2592
|
mutationFn: async ({ title, body }) => {
|
|
2593
|
+
if (!code) {
|
|
2594
|
+
throw new Error("[SDK][Posts] Missing access token");
|
|
2595
|
+
}
|
|
2559
2596
|
const fetchApi = getBoundFetch();
|
|
2560
2597
|
const response = await fetchApi(
|
|
2561
2598
|
CONFIG.privateApiHost + "/private-api/fragments-add",
|
|
2562
2599
|
{
|
|
2563
2600
|
method: "POST",
|
|
2564
2601
|
body: JSON.stringify({
|
|
2565
|
-
code
|
|
2602
|
+
code,
|
|
2566
2603
|
title,
|
|
2567
2604
|
body
|
|
2568
2605
|
}),
|
|
@@ -2575,23 +2612,26 @@ function useAddFragment(username) {
|
|
|
2575
2612
|
},
|
|
2576
2613
|
onSuccess(response) {
|
|
2577
2614
|
getQueryClient().setQueryData(
|
|
2578
|
-
getFragmentsQueryOptions(username).queryKey,
|
|
2615
|
+
getFragmentsQueryOptions(username, code).queryKey,
|
|
2579
2616
|
(data) => [response, ...data ?? []]
|
|
2580
2617
|
);
|
|
2581
2618
|
}
|
|
2582
2619
|
});
|
|
2583
2620
|
}
|
|
2584
|
-
function useEditFragment(username, fragmentId) {
|
|
2621
|
+
function useEditFragment(username, fragmentId, code) {
|
|
2585
2622
|
return reactQuery.useMutation({
|
|
2586
2623
|
mutationKey: ["posts", "edit-fragment", username, fragmentId],
|
|
2587
2624
|
mutationFn: async ({ title, body }) => {
|
|
2625
|
+
if (!code) {
|
|
2626
|
+
throw new Error("[SDK][Posts] Missing access token");
|
|
2627
|
+
}
|
|
2588
2628
|
const fetchApi = getBoundFetch();
|
|
2589
2629
|
const response = await fetchApi(
|
|
2590
2630
|
CONFIG.privateApiHost + "/private-api/fragments-update",
|
|
2591
2631
|
{
|
|
2592
2632
|
method: "POST",
|
|
2593
2633
|
body: JSON.stringify({
|
|
2594
|
-
code
|
|
2634
|
+
code,
|
|
2595
2635
|
id: fragmentId,
|
|
2596
2636
|
title,
|
|
2597
2637
|
body
|
|
@@ -2605,7 +2645,7 @@ function useEditFragment(username, fragmentId) {
|
|
|
2605
2645
|
},
|
|
2606
2646
|
onSuccess(response) {
|
|
2607
2647
|
getQueryClient().setQueryData(
|
|
2608
|
-
getFragmentsQueryOptions(username).queryKey,
|
|
2648
|
+
getFragmentsQueryOptions(username, code).queryKey,
|
|
2609
2649
|
(data) => {
|
|
2610
2650
|
if (!data) {
|
|
2611
2651
|
return [];
|
|
@@ -2620,15 +2660,18 @@ function useEditFragment(username, fragmentId) {
|
|
|
2620
2660
|
}
|
|
2621
2661
|
});
|
|
2622
2662
|
}
|
|
2623
|
-
function useRemoveFragment(username, fragmentId) {
|
|
2663
|
+
function useRemoveFragment(username, fragmentId, code) {
|
|
2624
2664
|
return reactQuery.useMutation({
|
|
2625
2665
|
mutationKey: ["posts", "remove-fragment", username],
|
|
2626
2666
|
mutationFn: async () => {
|
|
2667
|
+
if (!code) {
|
|
2668
|
+
throw new Error("[SDK][Posts] Missing access token");
|
|
2669
|
+
}
|
|
2627
2670
|
const fetchApi = getBoundFetch();
|
|
2628
2671
|
return fetchApi(CONFIG.privateApiHost + "/private-api/fragments-delete", {
|
|
2629
2672
|
method: "POST",
|
|
2630
2673
|
body: JSON.stringify({
|
|
2631
|
-
code
|
|
2674
|
+
code,
|
|
2632
2675
|
id: fragmentId
|
|
2633
2676
|
}),
|
|
2634
2677
|
headers: {
|
|
@@ -2638,7 +2681,7 @@ function useRemoveFragment(username, fragmentId) {
|
|
|
2638
2681
|
},
|
|
2639
2682
|
onSuccess() {
|
|
2640
2683
|
getQueryClient().setQueryData(
|
|
2641
|
-
getFragmentsQueryOptions(username).queryKey,
|
|
2684
|
+
getFragmentsQueryOptions(username, code).queryKey,
|
|
2642
2685
|
(data) => [...data ?? []].filter(({ id }) => id !== fragmentId)
|
|
2643
2686
|
);
|
|
2644
2687
|
}
|
|
@@ -2757,11 +2800,10 @@ var queries_exports = {};
|
|
|
2757
2800
|
__export(queries_exports, {
|
|
2758
2801
|
getDecodeMemoQueryOptions: () => getDecodeMemoQueryOptions
|
|
2759
2802
|
});
|
|
2760
|
-
function getDecodeMemoQueryOptions(username, memo) {
|
|
2803
|
+
function getDecodeMemoQueryOptions(username, memo, accessToken) {
|
|
2761
2804
|
return reactQuery.queryOptions({
|
|
2762
2805
|
queryKey: ["integrations", "hivesigner", "decode-memo", username],
|
|
2763
2806
|
queryFn: async () => {
|
|
2764
|
-
const accessToken = getAccessToken(username);
|
|
2765
2807
|
if (accessToken) {
|
|
2766
2808
|
const hsClient = new hs__default.default.Client({
|
|
2767
2809
|
accessToken
|
|
@@ -2778,12 +2820,12 @@ var HiveSignerIntegration = {
|
|
|
2778
2820
|
};
|
|
2779
2821
|
|
|
2780
2822
|
// src/modules/integrations/3speak/queries/get-account-token-query-options.ts
|
|
2781
|
-
function getAccountTokenQueryOptions(username) {
|
|
2823
|
+
function getAccountTokenQueryOptions(username, accessToken) {
|
|
2782
2824
|
return reactQuery.queryOptions({
|
|
2783
2825
|
queryKey: ["integrations", "3speak", "authenticate", username],
|
|
2784
|
-
enabled: !!username,
|
|
2826
|
+
enabled: !!username && !!accessToken,
|
|
2785
2827
|
queryFn: async () => {
|
|
2786
|
-
if (!username) {
|
|
2828
|
+
if (!username || !accessToken) {
|
|
2787
2829
|
throw new Error("[SDK][Integrations][3Speak] \u2013\xA0anon user");
|
|
2788
2830
|
}
|
|
2789
2831
|
const fetchApi = getBoundFetch();
|
|
@@ -2797,7 +2839,8 @@ function getAccountTokenQueryOptions(username) {
|
|
|
2797
2839
|
);
|
|
2798
2840
|
const memoQueryOptions = HiveSignerIntegration.queries.getDecodeMemoQueryOptions(
|
|
2799
2841
|
username,
|
|
2800
|
-
(await response.json()).memo
|
|
2842
|
+
(await response.json()).memo,
|
|
2843
|
+
accessToken
|
|
2801
2844
|
);
|
|
2802
2845
|
await getQueryClient().prefetchQuery(memoQueryOptions);
|
|
2803
2846
|
const { memoDecoded } = getQueryClient().getQueryData(
|
|
@@ -2807,17 +2850,23 @@ function getAccountTokenQueryOptions(username) {
|
|
|
2807
2850
|
}
|
|
2808
2851
|
});
|
|
2809
2852
|
}
|
|
2810
|
-
function getAccountVideosQueryOptions(username) {
|
|
2853
|
+
function getAccountVideosQueryOptions(username, accessToken) {
|
|
2811
2854
|
return reactQuery.queryOptions({
|
|
2812
2855
|
queryKey: ["integrations", "3speak", "videos", username],
|
|
2813
|
-
enabled: !!username,
|
|
2856
|
+
enabled: !!username && !!accessToken,
|
|
2814
2857
|
queryFn: async () => {
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
const
|
|
2819
|
-
|
|
2858
|
+
if (!username || !accessToken) {
|
|
2859
|
+
throw new Error("[SDK][Integrations][3Speak] \u2013\xA0anon user");
|
|
2860
|
+
}
|
|
2861
|
+
const tokenQueryOptions = getAccountTokenQueryOptions(
|
|
2862
|
+
username,
|
|
2863
|
+
accessToken
|
|
2820
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
|
+
}
|
|
2821
2870
|
const fetchApi = getBoundFetch();
|
|
2822
2871
|
const response = await fetchApi(
|
|
2823
2872
|
`https://studio.3speak.tv/mobile/api/my-videos`,
|
|
@@ -2928,13 +2977,13 @@ function getAccountRcQueryOptions(username) {
|
|
|
2928
2977
|
enabled: !!username
|
|
2929
2978
|
});
|
|
2930
2979
|
}
|
|
2931
|
-
function getGameStatusCheckQueryOptions(username, gameType) {
|
|
2980
|
+
function getGameStatusCheckQueryOptions(username, code, gameType) {
|
|
2932
2981
|
return reactQuery.queryOptions({
|
|
2933
2982
|
queryKey: ["games", "status-check", gameType, username],
|
|
2934
|
-
enabled: !!username,
|
|
2983
|
+
enabled: !!username && !!code,
|
|
2935
2984
|
queryFn: async () => {
|
|
2936
|
-
if (!username) {
|
|
2937
|
-
throw new Error("[SDK][Games] \u2013
|
|
2985
|
+
if (!username || !code) {
|
|
2986
|
+
throw new Error("[SDK][Games] \u2013 missing auth");
|
|
2938
2987
|
}
|
|
2939
2988
|
const fetchApi = getBoundFetch();
|
|
2940
2989
|
const response = await fetchApi(
|
|
@@ -2943,7 +2992,7 @@ function getGameStatusCheckQueryOptions(username, gameType) {
|
|
|
2943
2992
|
method: "POST",
|
|
2944
2993
|
body: JSON.stringify({
|
|
2945
2994
|
game_type: gameType,
|
|
2946
|
-
code
|
|
2995
|
+
code
|
|
2947
2996
|
}),
|
|
2948
2997
|
headers: {
|
|
2949
2998
|
"Content-Type": "application/json"
|
|
@@ -2954,7 +3003,7 @@ function getGameStatusCheckQueryOptions(username, gameType) {
|
|
|
2954
3003
|
}
|
|
2955
3004
|
});
|
|
2956
3005
|
}
|
|
2957
|
-
function useGameClaim(username, gameType, key) {
|
|
3006
|
+
function useGameClaim(username, code, gameType, key) {
|
|
2958
3007
|
const { mutateAsync: recordActivity } = useRecordActivity(
|
|
2959
3008
|
username,
|
|
2960
3009
|
"spin-rolled"
|
|
@@ -2962,8 +3011,8 @@ function useGameClaim(username, gameType, key) {
|
|
|
2962
3011
|
return reactQuery.useMutation({
|
|
2963
3012
|
mutationKey: ["games", "post", gameType, username],
|
|
2964
3013
|
mutationFn: async () => {
|
|
2965
|
-
if (!username) {
|
|
2966
|
-
throw new Error("[SDK][Games] \u2013
|
|
3014
|
+
if (!username || !code) {
|
|
3015
|
+
throw new Error("[SDK][Games] \u2013 missing auth");
|
|
2967
3016
|
}
|
|
2968
3017
|
const fetchApi = getBoundFetch();
|
|
2969
3018
|
const response = await fetchApi(
|
|
@@ -2972,7 +3021,7 @@ function useGameClaim(username, gameType, key) {
|
|
|
2972
3021
|
method: "POST",
|
|
2973
3022
|
body: JSON.stringify({
|
|
2974
3023
|
game_type: gameType,
|
|
2975
|
-
code
|
|
3024
|
+
code,
|
|
2976
3025
|
key
|
|
2977
3026
|
}),
|
|
2978
3027
|
headers: {
|
|
@@ -3137,15 +3186,18 @@ function getCommunityPermissions({
|
|
|
3137
3186
|
isModerator
|
|
3138
3187
|
};
|
|
3139
3188
|
}
|
|
3140
|
-
function getNotificationsUnreadCountQueryOptions(activeUsername) {
|
|
3189
|
+
function getNotificationsUnreadCountQueryOptions(activeUsername, code) {
|
|
3141
3190
|
return reactQuery.queryOptions({
|
|
3142
3191
|
queryKey: ["notifications", "unread", activeUsername],
|
|
3143
3192
|
queryFn: async () => {
|
|
3193
|
+
if (!code) {
|
|
3194
|
+
return 0;
|
|
3195
|
+
}
|
|
3144
3196
|
const response = await fetch(
|
|
3145
3197
|
`${CONFIG.privateApiHost}/private-api/notifications/unread`,
|
|
3146
3198
|
{
|
|
3147
3199
|
method: "POST",
|
|
3148
|
-
body: JSON.stringify({ code
|
|
3200
|
+
body: JSON.stringify({ code }),
|
|
3149
3201
|
headers: {
|
|
3150
3202
|
"Content-Type": "application/json"
|
|
3151
3203
|
}
|
|
@@ -3154,17 +3206,20 @@ function getNotificationsUnreadCountQueryOptions(activeUsername) {
|
|
|
3154
3206
|
const data = await response.json();
|
|
3155
3207
|
return data.count;
|
|
3156
3208
|
},
|
|
3157
|
-
enabled: !!activeUsername,
|
|
3209
|
+
enabled: !!activeUsername && !!code,
|
|
3158
3210
|
initialData: 0,
|
|
3159
3211
|
refetchInterval: 6e4
|
|
3160
3212
|
});
|
|
3161
3213
|
}
|
|
3162
|
-
function getNotificationsInfiniteQueryOptions(activeUsername, filter = void 0) {
|
|
3214
|
+
function getNotificationsInfiniteQueryOptions(activeUsername, code, filter = void 0) {
|
|
3163
3215
|
return reactQuery.infiniteQueryOptions({
|
|
3164
3216
|
queryKey: ["notifications", activeUsername, filter],
|
|
3165
3217
|
queryFn: async ({ pageParam }) => {
|
|
3218
|
+
if (!code) {
|
|
3219
|
+
return [];
|
|
3220
|
+
}
|
|
3166
3221
|
const data = {
|
|
3167
|
-
code
|
|
3222
|
+
code,
|
|
3168
3223
|
filter,
|
|
3169
3224
|
since: pageParam,
|
|
3170
3225
|
user: void 0
|
|
@@ -3181,7 +3236,7 @@ function getNotificationsInfiniteQueryOptions(activeUsername, filter = void 0) {
|
|
|
3181
3236
|
);
|
|
3182
3237
|
return response.json();
|
|
3183
3238
|
},
|
|
3184
|
-
enabled: !!activeUsername,
|
|
3239
|
+
enabled: !!activeUsername && !!code,
|
|
3185
3240
|
initialData: { pages: [], pageParams: [] },
|
|
3186
3241
|
initialPageParam: "",
|
|
3187
3242
|
getNextPageParam: (lastPage) => lastPage?.[lastPage.length - 1]?.id ?? "",
|
|
@@ -3234,16 +3289,19 @@ var NotificationViewType = /* @__PURE__ */ ((NotificationViewType2) => {
|
|
|
3234
3289
|
})(NotificationViewType || {});
|
|
3235
3290
|
|
|
3236
3291
|
// src/modules/notifications/queries/get-notifications-settings-query-options.ts
|
|
3237
|
-
function getNotificationsSettingsQueryOptions(activeUsername) {
|
|
3292
|
+
function getNotificationsSettingsQueryOptions(activeUsername, code) {
|
|
3238
3293
|
return reactQuery.queryOptions({
|
|
3239
3294
|
queryKey: ["notifications", "settings", activeUsername],
|
|
3240
3295
|
queryFn: async () => {
|
|
3241
3296
|
let token = activeUsername + "-web";
|
|
3297
|
+
if (!code) {
|
|
3298
|
+
throw new Error("Missing access token");
|
|
3299
|
+
}
|
|
3242
3300
|
const response = await fetch(
|
|
3243
3301
|
CONFIG.privateApiHost + "/private-api/detail-device",
|
|
3244
3302
|
{
|
|
3245
3303
|
body: JSON.stringify({
|
|
3246
|
-
code
|
|
3304
|
+
code,
|
|
3247
3305
|
username: activeUsername,
|
|
3248
3306
|
token
|
|
3249
3307
|
}),
|
|
@@ -3258,7 +3316,7 @@ function getNotificationsSettingsQueryOptions(activeUsername) {
|
|
|
3258
3316
|
}
|
|
3259
3317
|
return response.json();
|
|
3260
3318
|
},
|
|
3261
|
-
enabled: !!activeUsername,
|
|
3319
|
+
enabled: !!activeUsername && !!code,
|
|
3262
3320
|
refetchOnMount: false,
|
|
3263
3321
|
initialData: () => {
|
|
3264
3322
|
const wasMutedPreviously = typeof window !== "undefined" ? localStorage.getItem("notifications") !== "true" : false;
|
|
@@ -3552,8 +3610,9 @@ function getMarketDataQueryOptions(coin, vsCurrency, fromTs, toTs) {
|
|
|
3552
3610
|
return reactQuery.queryOptions({
|
|
3553
3611
|
queryKey: ["market", "data", coin, vsCurrency, fromTs, toTs],
|
|
3554
3612
|
queryFn: async ({ signal }) => {
|
|
3613
|
+
const fetchApi = getBoundFetch();
|
|
3555
3614
|
const url = `https://api.coingecko.com/api/v3/coins/${coin}/market_chart/range?vs_currency=${vsCurrency}&from=${fromTs}&to=${toTs}`;
|
|
3556
|
-
const response = await
|
|
3615
|
+
const response = await fetchApi(url, { signal });
|
|
3557
3616
|
if (!response.ok) {
|
|
3558
3617
|
throw new Error(`Failed to fetch market data: ${response.status}`);
|
|
3559
3618
|
}
|
|
@@ -3561,6 +3620,46 @@ function getMarketDataQueryOptions(coin, vsCurrency, fromTs, toTs) {
|
|
|
3561
3620
|
}
|
|
3562
3621
|
});
|
|
3563
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
|
+
}
|
|
3564
3663
|
function getPointsQueryOptions(username, filter = 0) {
|
|
3565
3664
|
return reactQuery.queryOptions({
|
|
3566
3665
|
queryKey: ["points", username, filter],
|
|
@@ -3901,6 +4000,311 @@ function getBoostPlusAccountPricesQueryOptions(account, accessToken) {
|
|
|
3901
4000
|
});
|
|
3902
4001
|
}
|
|
3903
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
|
+
|
|
3904
4308
|
exports.ACCOUNT_OPERATION_GROUPS = ACCOUNT_OPERATION_GROUPS;
|
|
3905
4309
|
exports.ALL_ACCOUNT_OPERATIONS = ALL_ACCOUNT_OPERATIONS;
|
|
3906
4310
|
exports.ALL_NOTIFY_TYPES = ALL_NOTIFY_TYPES;
|
|
@@ -3916,11 +4320,17 @@ exports.ROLES = ROLES;
|
|
|
3916
4320
|
exports.SortOrder = SortOrder;
|
|
3917
4321
|
exports.Symbol = Symbol2;
|
|
3918
4322
|
exports.ThreeSpeakIntegration = ThreeSpeakIntegration;
|
|
4323
|
+
exports.addDraft = addDraft;
|
|
4324
|
+
exports.addImage = addImage;
|
|
4325
|
+
exports.addSchedule = addSchedule;
|
|
3919
4326
|
exports.broadcastJson = broadcastJson;
|
|
3920
4327
|
exports.buildProfileMetadata = buildProfileMetadata;
|
|
3921
4328
|
exports.checkUsernameWalletsPendingQueryOptions = checkUsernameWalletsPendingQueryOptions;
|
|
3922
4329
|
exports.decodeObj = decodeObj;
|
|
3923
4330
|
exports.dedupeAndSortKeyAuths = dedupeAndSortKeyAuths;
|
|
4331
|
+
exports.deleteDraft = deleteDraft;
|
|
4332
|
+
exports.deleteImage = deleteImage;
|
|
4333
|
+
exports.deleteSchedule = deleteSchedule;
|
|
3924
4334
|
exports.encodeObj = encodeObj;
|
|
3925
4335
|
exports.extractAccountProfile = extractAccountProfile;
|
|
3926
4336
|
exports.getAccessToken = getAccessToken;
|
|
@@ -3950,6 +4360,9 @@ exports.getCommunitySubscribersQueryOptions = getCommunitySubscribersQueryOption
|
|
|
3950
4360
|
exports.getCommunityType = getCommunityType;
|
|
3951
4361
|
exports.getControversialRisingInfiniteQueryOptions = getControversialRisingInfiniteQueryOptions;
|
|
3952
4362
|
exports.getConversionRequestsQueryOptions = getConversionRequestsQueryOptions;
|
|
4363
|
+
exports.getCurrencyRate = getCurrencyRate;
|
|
4364
|
+
exports.getCurrencyRates = getCurrencyRates;
|
|
4365
|
+
exports.getCurrencyTokenRate = getCurrencyTokenRate;
|
|
3953
4366
|
exports.getDeletedEntryQueryOptions = getDeletedEntryQueryOptions;
|
|
3954
4367
|
exports.getDiscoverCurationQueryOptions = getDiscoverCurationQueryOptions;
|
|
3955
4368
|
exports.getDiscoverLeaderboardQueryOptions = getDiscoverLeaderboardQueryOptions;
|
|
@@ -3967,10 +4380,13 @@ exports.getHiveHbdStatsQueryOptions = getHiveHbdStatsQueryOptions;
|
|
|
3967
4380
|
exports.getHivePoshLinksQueryOptions = getHivePoshLinksQueryOptions;
|
|
3968
4381
|
exports.getImagesQueryOptions = getImagesQueryOptions;
|
|
3969
4382
|
exports.getLoginType = getLoginType;
|
|
4383
|
+
exports.getMarketData = getMarketData;
|
|
3970
4384
|
exports.getMarketDataQueryOptions = getMarketDataQueryOptions;
|
|
3971
4385
|
exports.getMarketHistoryQueryOptions = getMarketHistoryQueryOptions;
|
|
3972
4386
|
exports.getMarketStatisticsQueryOptions = getMarketStatisticsQueryOptions;
|
|
3973
4387
|
exports.getMutedUsersQueryOptions = getMutedUsersQueryOptions;
|
|
4388
|
+
exports.getNotificationSetting = getNotificationSetting;
|
|
4389
|
+
exports.getNotifications = getNotifications;
|
|
3974
4390
|
exports.getNotificationsInfiniteQueryOptions = getNotificationsInfiniteQueryOptions;
|
|
3975
4391
|
exports.getNotificationsSettingsQueryOptions = getNotificationsSettingsQueryOptions;
|
|
3976
4392
|
exports.getNotificationsUnreadCountQueryOptions = getNotificationsUnreadCountQueryOptions;
|
|
@@ -3985,6 +4401,7 @@ exports.getPostTipsQueryOptions = getPostTipsQueryOptions;
|
|
|
3985
4401
|
exports.getPostingKey = getPostingKey;
|
|
3986
4402
|
exports.getPostsRankedInfiniteQueryOptions = getPostsRankedInfiniteQueryOptions;
|
|
3987
4403
|
exports.getPromotePriceQueryOptions = getPromotePriceQueryOptions;
|
|
4404
|
+
exports.getPromotedPost = getPromotedPost;
|
|
3988
4405
|
exports.getPromotedPostsQuery = getPromotedPostsQuery;
|
|
3989
4406
|
exports.getProposalQueryOptions = getProposalQueryOptions;
|
|
3990
4407
|
exports.getProposalVotesInfiniteQueryOptions = getProposalVotesInfiniteQueryOptions;
|
|
@@ -4010,6 +4427,7 @@ exports.getSimilarEntriesQueryOptions = getSimilarEntriesQueryOptions;
|
|
|
4010
4427
|
exports.getStatsQueryOptions = getStatsQueryOptions;
|
|
4011
4428
|
exports.getTransactionsInfiniteQueryOptions = getTransactionsInfiniteQueryOptions;
|
|
4012
4429
|
exports.getTrendingTagsQueryOptions = getTrendingTagsQueryOptions;
|
|
4430
|
+
exports.getTrendingTagsWithStatsQueryOptions = getTrendingTagsWithStatsQueryOptions;
|
|
4013
4431
|
exports.getUser = getUser;
|
|
4014
4432
|
exports.getUserProposalVotesQueryOptions = getUserProposalVotesQueryOptions;
|
|
4015
4433
|
exports.getVestingDelegationsQueryOptions = getVestingDelegationsQueryOptions;
|
|
@@ -4020,17 +4438,27 @@ exports.getWavesFollowingQueryOptions = getWavesFollowingQueryOptions;
|
|
|
4020
4438
|
exports.getWavesTrendingTagsQueryOptions = getWavesTrendingTagsQueryOptions;
|
|
4021
4439
|
exports.getWithdrawRoutesQueryOptions = getWithdrawRoutesQueryOptions;
|
|
4022
4440
|
exports.getWitnessesInfiniteQueryOptions = getWitnessesInfiniteQueryOptions;
|
|
4441
|
+
exports.hsTokenRenew = hsTokenRenew;
|
|
4442
|
+
exports.isCommunity = isCommunity;
|
|
4023
4443
|
exports.lookupAccountsQueryOptions = lookupAccountsQueryOptions;
|
|
4024
4444
|
exports.makeQueryClient = makeQueryClient;
|
|
4025
4445
|
exports.mapThreadItemsToWaveEntries = mapThreadItemsToWaveEntries;
|
|
4446
|
+
exports.markNotifications = markNotifications;
|
|
4447
|
+
exports.moveSchedule = moveSchedule;
|
|
4026
4448
|
exports.normalizeWaveEntryFromApi = normalizeWaveEntryFromApi;
|
|
4449
|
+
exports.onboardEmail = onboardEmail;
|
|
4027
4450
|
exports.parseAccounts = parseAccounts;
|
|
4028
4451
|
exports.parseAsset = parseAsset;
|
|
4029
4452
|
exports.parseProfileMetadata = parseProfileMetadata;
|
|
4030
4453
|
exports.roleMap = roleMap;
|
|
4454
|
+
exports.saveNotificationSetting = saveNotificationSetting;
|
|
4031
4455
|
exports.searchQueryOptions = searchQueryOptions;
|
|
4456
|
+
exports.signUp = signUp;
|
|
4032
4457
|
exports.sortDiscussions = sortDiscussions;
|
|
4458
|
+
exports.subscribeEmail = subscribeEmail;
|
|
4033
4459
|
exports.toEntryArray = toEntryArray;
|
|
4460
|
+
exports.updateDraft = updateDraft;
|
|
4461
|
+
exports.uploadImage = uploadImage;
|
|
4034
4462
|
exports.useAccountFavouriteAdd = useAccountFavouriteAdd;
|
|
4035
4463
|
exports.useAccountFavouriteDelete = useAccountFavouriteDelete;
|
|
4036
4464
|
exports.useAccountRelationsUpdate = useAccountRelationsUpdate;
|
|
@@ -4051,5 +4479,6 @@ exports.useRemoveFragment = useRemoveFragment;
|
|
|
4051
4479
|
exports.useSignOperationByHivesigner = useSignOperationByHivesigner;
|
|
4052
4480
|
exports.useSignOperationByKey = useSignOperationByKey;
|
|
4053
4481
|
exports.useSignOperationByKeychain = useSignOperationByKeychain;
|
|
4482
|
+
exports.usrActivity = usrActivity;
|
|
4054
4483
|
//# sourceMappingURL=index.cjs.map
|
|
4055
4484
|
//# sourceMappingURL=index.cjs.map
|