@ecency/sdk 1.0.45 → 1.0.47

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.
@@ -1,12 +1,12 @@
1
- var Q = Object.defineProperty;
2
- var _ = (e, t, n) => t in e ? Q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var m = (e, t, n) => _(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { QueryClient as S, useMutation as y, useQuery as T, useInfiniteQuery as j, queryOptions as p, infiniteQueryOptions as k } from "@tanstack/react-query";
5
- import { Client as A, PrivateKey as h, cryptoUtils as F, RCAPI as D } from "@hiveio/dhive";
1
+ var _ = Object.defineProperty;
2
+ var T = (e, t, n) => t in e ? _(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var C = (e, t, n) => T(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { QueryClient as O, useMutation as y, useQuery as j, useInfiniteQuery as k, queryOptions as p, infiniteQueryOptions as A } from "@tanstack/react-query";
5
+ import { Client as F, PrivateKey as h, cryptoUtils as D, RCAPI as P } from "@hiveio/dhive";
6
6
  import d from "hivesigner";
7
- class P {
7
+ class I {
8
8
  constructor() {
9
- m(this, "length", 0);
9
+ C(this, "length", 0);
10
10
  }
11
11
  clear() {
12
12
  throw new Error("Method not implemented.");
@@ -24,11 +24,11 @@ class P {
24
24
  this[t] = n;
25
25
  }
26
26
  }
27
- const s = {
27
+ const a = {
28
28
  privateApiHost: "https://ecency.com",
29
- storage: typeof window > "u" ? new P() : window.localStorage,
29
+ storage: typeof window > "u" ? new I() : window.localStorage,
30
30
  storagePrefix: "ecency",
31
- hiveClient: new A(
31
+ hiveClient: new F(
32
32
  [
33
33
  "https://api.hive.blog",
34
34
  "https://api.deathwing.me",
@@ -49,88 +49,118 @@ const s = {
49
49
  }
50
50
  ),
51
51
  heliusApiKey: void 0,
52
- queryClient: new S(),
52
+ queryClient: new O(),
53
53
  plausibleHost: "https://pl.ecency.com"
54
54
  };
55
- var C;
55
+ var b;
56
56
  ((e) => {
57
57
  function t(n) {
58
- s.queryClient = n;
58
+ a.queryClient = n;
59
59
  }
60
60
  e.setQueryClient = t;
61
- })(C || (C = {}));
62
- function I(e) {
61
+ })(b || (b = {}));
62
+ function N(e) {
63
63
  let t = atob(e);
64
64
  if (t[0] === "{")
65
65
  return JSON.parse(t);
66
66
  }
67
67
  const f = (e) => {
68
68
  try {
69
- const t = s.storage.getItem(
70
- s.storagePrefix + "_user_" + e
69
+ const t = a.storage.getItem(
70
+ a.storagePrefix + "_user_" + e
71
71
  );
72
- return I(JSON.parse(t));
72
+ return N(JSON.parse(t));
73
73
  } catch (t) {
74
74
  console.error(t);
75
75
  return;
76
76
  }
77
- }, l = (e) => f(e) && f(e).accessToken, q = (e) => f(e) && f(e).postingKey, V = (e) => f(e) && f(e).refreshToken;
78
- function N(e = [], t, n) {
77
+ }, l = (e) => f(e) && f(e).accessToken, K = (e) => f(e) && f(e).postingKey, S = (e) => f(e) && f(e).loginType, Z = (e) => f(e) && f(e).refreshToken;
78
+ function J() {
79
+ return new Promise((e) => {
80
+ var t;
81
+ (t = window.hive_keychain) == null || t.requestHandshake(() => {
82
+ e();
83
+ });
84
+ });
85
+ }
86
+ const g = (e, t, n, o = null) => new Promise((i, c) => {
87
+ var s;
88
+ (s = window.hive_keychain) == null || s.requestBroadcast(
89
+ e,
90
+ t,
91
+ n,
92
+ (r) => {
93
+ r.success || c({ message: "Operation cancelled" }), i(r);
94
+ },
95
+ o
96
+ );
97
+ }), L = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
98
+ __proto__: null,
99
+ broadcast: g,
100
+ handshake: J
101
+ }, Symbol.toStringTag, { value: "Module" }));
102
+ function M(e = [], t, n) {
79
103
  return y({
80
104
  mutationKey: [...e, t],
81
- mutationFn: async (r) => {
105
+ mutationFn: async (o) => {
82
106
  if (!t)
83
107
  throw new Error(
84
108
  "[Core][Broadcast] Attempted to call broadcast API with anon user"
85
109
  );
86
- const o = q(t);
87
- if (o) {
88
- const i = h.fromString(o);
89
- return s.hiveClient.broadcast.sendOperations(
90
- n(r),
91
- i
110
+ const i = K(t);
111
+ if (i) {
112
+ const r = h.fromString(i);
113
+ return a.hiveClient.broadcast.sendOperations(
114
+ n(o),
115
+ r
92
116
  );
93
117
  }
94
- let u = l(t);
95
- if (u)
118
+ const c = S(t);
119
+ if (c && c == "keychain")
120
+ return g(t, n(o), "Posting").then((r) => r.result);
121
+ let s = l(t);
122
+ if (s)
96
123
  return (await new d.Client({
97
- accessToken: u
98
- }).broadcast(n(r))).result;
124
+ accessToken: s
125
+ }).broadcast(n(o))).result;
99
126
  throw new Error(
100
127
  "[SDK][Broadcast] – cannot broadcast w/o posting key or token"
101
128
  );
102
129
  }
103
130
  });
104
131
  }
105
- async function J(e, t, n) {
132
+ async function H(e, t, n) {
106
133
  if (!e)
107
134
  throw new Error(
108
135
  "[Core][Broadcast] Attempted to call broadcast API with anon user"
109
136
  );
110
- const r = q(e);
111
- if (r) {
112
- const u = h.fromString(r);
113
- return s.hiveClient.broadcast.json(
114
- {
115
- id: t,
116
- required_auths: [],
117
- required_posting_auths: [e],
118
- json: JSON.stringify(n)
119
- },
120
- u
137
+ const o = {
138
+ id: t,
139
+ required_auths: [],
140
+ required_posting_auths: [e],
141
+ json: JSON.stringify(n)
142
+ }, i = K(e);
143
+ if (i) {
144
+ const r = h.fromString(i);
145
+ return a.hiveClient.broadcast.json(
146
+ o,
147
+ r
121
148
  );
122
149
  }
123
- let o = l(e);
124
- if (o)
150
+ const c = S(e);
151
+ if (c && c == "keychain")
152
+ return g(e, [["custom_json", o]], "Posting").then((r) => r.result);
153
+ let s = l(e);
154
+ if (s)
125
155
  return (await new d.Client({
126
- accessToken: o
156
+ accessToken: s
127
157
  }).customJson([], [e], t, JSON.stringify(n))).result;
128
158
  throw new Error(
129
159
  "[SDK][Broadcast] – cannot broadcast w/o posting key or token"
130
160
  );
131
161
  }
132
- function X() {
133
- return new S({
162
+ function R() {
163
+ return new O({
134
164
  defaultOptions: {
135
165
  queries: {
136
166
  // With SSR, we usually want to set some default staleTime
@@ -142,46 +172,46 @@ function X() {
142
172
  }
143
173
  });
144
174
  }
145
- const c = () => s.queryClient;
146
- var O;
175
+ const u = () => a.queryClient;
176
+ var q;
147
177
  ((e) => {
148
- function t(a) {
149
- return c().getQueryData(a);
178
+ function t(r) {
179
+ return u().getQueryData(r);
150
180
  }
151
181
  e.getQueryData = t;
152
- function n(a) {
153
- return c().getQueryData(a);
182
+ function n(r) {
183
+ return u().getQueryData(r);
154
184
  }
155
185
  e.getInfiniteQueryData = n;
156
- async function r(a) {
157
- return await c().prefetchQuery(a), t(a.queryKey);
186
+ async function o(r) {
187
+ return await u().prefetchQuery(r), t(r.queryKey);
158
188
  }
159
- e.prefetchQuery = r;
160
- async function o(a) {
161
- return await c().prefetchInfiniteQuery(a), n(a.queryKey);
189
+ e.prefetchQuery = o;
190
+ async function i(r) {
191
+ return await u().prefetchInfiniteQuery(r), n(r.queryKey);
162
192
  }
163
- e.prefetchInfiniteQuery = o;
164
- function u(a) {
193
+ e.prefetchInfiniteQuery = i;
194
+ function c(r) {
165
195
  return {
166
- prefetch: () => r(a),
167
- getData: () => t(a.queryKey),
168
- useClientQuery: () => T(a),
169
- fetchAndGet: () => c().fetchQuery(a)
196
+ prefetch: () => o(r),
197
+ getData: () => t(r.queryKey),
198
+ useClientQuery: () => j(r),
199
+ fetchAndGet: () => u().fetchQuery(r)
170
200
  };
171
201
  }
172
- e.generateClientServerQuery = u;
173
- function i(a) {
202
+ e.generateClientServerQuery = c;
203
+ function s(r) {
174
204
  return {
175
- prefetch: () => o(a),
176
- getData: () => n(a.queryKey),
177
- useClientQuery: () => j(a),
178
- fetchAndGet: () => c().fetchInfiniteQuery(a)
205
+ prefetch: () => i(r),
206
+ getData: () => n(r.queryKey),
207
+ useClientQuery: () => k(r),
208
+ fetchAndGet: () => u().fetchInfiniteQuery(r)
179
209
  };
180
210
  }
181
- e.generateClientServerInfiniteQuery = i;
182
- })(O || (O = {}));
183
- function Y(e) {
184
- return N(
211
+ e.generateClientServerInfiniteQuery = s;
212
+ })(q || (q = {}));
213
+ function ee(e) {
214
+ return M(
185
215
  ["accounts", "update"],
186
216
  e,
187
217
  ({
@@ -203,36 +233,36 @@ function Y(e) {
203
233
  ]
204
234
  );
205
235
  }
206
- function Z(e) {
236
+ function te(e) {
207
237
  return p({
208
238
  queryKey: ["get-account-full", e],
209
239
  queryFn: async () => {
210
240
  if (!e)
211
241
  throw new Error("[SDK] Username is empty");
212
- const t = await s.hiveClient.database.getAccounts([e]);
242
+ const t = await a.hiveClient.database.getAccounts([e]);
213
243
  if (!t[0])
214
244
  throw new Error("[SDK] No account with given username");
215
245
  const n = JSON.parse(t[0].posting_json_metadata).profile;
216
- let r;
246
+ let o;
217
247
  try {
218
- r = await s.hiveClient.database.call(
248
+ o = await a.hiveClient.database.call(
219
249
  "get_follow_count",
220
250
  [e]
221
251
  );
222
252
  } catch {
223
253
  }
224
- const o = await s.hiveClient.call(
254
+ const i = await a.hiveClient.call(
225
255
  "condenser_api",
226
256
  "get_account_reputations",
227
257
  [e, 1]
228
258
  );
229
259
  return {
230
260
  ...t,
231
- follow_stats: r,
232
- reputation: o[0].reputation,
261
+ follow_stats: o,
262
+ reputation: i[0].reputation,
233
263
  profile: {
234
264
  ...n,
235
- reputation: o[0].reputation
265
+ reputation: i[0].reputation
236
266
  }
237
267
  };
238
268
  },
@@ -240,23 +270,23 @@ function Z(e) {
240
270
  staleTime: 6e4
241
271
  });
242
272
  }
243
- function R(e, t = 5, n = []) {
273
+ function ne(e, t = 5, n = []) {
244
274
  return p({
245
275
  queryKey: ["accounts", "search", e, n],
246
276
  enabled: !!e,
247
- queryFn: async () => (await s.hiveClient.database.call(
277
+ queryFn: async () => (await a.hiveClient.database.call(
248
278
  "lookup_accounts",
249
279
  [e, t]
250
280
  )).filter(
251
- (o) => n.length > 0 ? !n.includes(o) : !0
281
+ (i) => n.length > 0 ? !n.includes(i) : !0
252
282
  )
253
283
  });
254
284
  }
255
- function ee(e) {
285
+ function oe(e) {
256
286
  return p({
257
287
  queryKey: ["accounts", "check-wallet-pending", e],
258
288
  queryFn: async () => await (await fetch(
259
- s.privateApiHost + "/private-api/wallets-chkuser",
289
+ a.privateApiHost + "/private-api/wallets-chkuser",
260
290
  {
261
291
  method: "POST",
262
292
  headers: {
@@ -271,57 +301,70 @@ function ee(e) {
271
301
  refetchOnMount: !0
272
302
  });
273
303
  }
274
- function H(e, t) {
304
+ function B(e, t) {
275
305
  return p({
276
306
  queryKey: ["accounts", "relations", e, t],
277
307
  enabled: !!e && !!t,
278
308
  refetchOnMount: !1,
279
309
  refetchInterval: 36e5,
280
- queryFn: async () => await s.hiveClient.call(
310
+ queryFn: async () => await a.hiveClient.call(
281
311
  "bridge",
282
312
  "get_relationship_between_accounts",
283
313
  [e, t]
284
314
  )
285
315
  });
286
316
  }
287
- function te(e, t, n, r) {
317
+ function re(e) {
318
+ return p({
319
+ queryKey: ["accounts", "subscriptions", e],
320
+ enabled: !!e,
321
+ queryFn: async () => await a.hiveClient.call(
322
+ "bridge",
323
+ "list_all_subscriptions",
324
+ {
325
+ account: e
326
+ }
327
+ ) ?? []
328
+ });
329
+ }
330
+ function ie(e, t, n, o) {
288
331
  return y({
289
332
  mutationKey: [],
290
- mutationFn: async (o) => {
291
- const u = H(
333
+ mutationFn: async (i) => {
334
+ const c = B(
292
335
  e,
293
336
  t
294
337
  );
295
- await c().prefetchQuery(u);
296
- const i = c().getQueryData(
297
- u.queryKey
338
+ await u().prefetchQuery(c);
339
+ const s = u().getQueryData(
340
+ c.queryKey
298
341
  );
299
- return await J(e, "follow", [
342
+ return await H(e, "follow", [
300
343
  "follow",
301
344
  {
302
345
  follower: e,
303
346
  following: t,
304
347
  what: [
305
- ...o === "toggle-ignore" && !(i != null && i.ignores) ? ["ignore"] : [],
306
- ...o === "toggle-follow" && !(i != null && i.follows) ? ["blog"] : []
348
+ ...i === "toggle-ignore" && !(s != null && s.ignores) ? ["ignore"] : [],
349
+ ...i === "toggle-follow" && !(s != null && s.follows) ? ["blog"] : []
307
350
  ]
308
351
  }
309
352
  ]), {
310
- ...i,
311
- ignores: o === "toggle-ignore" ? !(i != null && i.ignores) : i == null ? void 0 : i.ignores,
312
- follows: o === "toggle-follow" ? !(i != null && i.follows) : i == null ? void 0 : i.follows
353
+ ...s,
354
+ ignores: i === "toggle-ignore" ? !(s != null && s.ignores) : s == null ? void 0 : s.ignores,
355
+ follows: i === "toggle-follow" ? !(s != null && s.follows) : s == null ? void 0 : s.follows
313
356
  };
314
357
  },
315
- onError: r,
316
- onSuccess(o) {
317
- n(o), c().setQueryData(
358
+ onError: o,
359
+ onSuccess(i) {
360
+ n(i), u().setQueryData(
318
361
  ["accounts", "relations", e, t],
319
- o
362
+ i
320
363
  );
321
364
  }
322
365
  });
323
366
  }
324
- function ne(e) {
367
+ function se(e) {
325
368
  return y({
326
369
  mutationKey: ["operations", "sign", e],
327
370
  mutationFn: ({
@@ -330,39 +373,15 @@ function ne(e) {
330
373
  }) => {
331
374
  if (!e)
332
375
  throw new Error("[Operations][Sign] – cannot sign op with anon user");
333
- let r;
334
- return n.split(" ").length === 12 ? r = h.fromLogin(e, n, "active") : F.isWif(n) ? r = h.fromString(n) : r = h.from(n), s.hiveClient.broadcast.sendOperations(
376
+ let o;
377
+ return n.split(" ").length === 12 ? o = h.fromLogin(e, n, "active") : D.isWif(n) ? o = h.fromString(n) : o = h.from(n), a.hiveClient.broadcast.sendOperations(
335
378
  [t],
336
- r
379
+ o
337
380
  );
338
381
  }
339
382
  });
340
383
  }
341
- function E() {
342
- return new Promise((e) => {
343
- var t;
344
- (t = window.hive_keychain) == null || t.requestHandshake(() => {
345
- e();
346
- });
347
- });
348
- }
349
- const K = (e, t, n, r = null) => new Promise((o, u) => {
350
- var i;
351
- (i = window.hive_keychain) == null || i.requestBroadcast(
352
- e,
353
- t,
354
- n,
355
- (a) => {
356
- a.success || u({ message: "Operation cancelled" }), o(a);
357
- },
358
- r
359
- );
360
- }), re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
361
- __proto__: null,
362
- broadcast: K,
363
- handshake: E
364
- }, Symbol.toStringTag, { value: "Module" }));
365
- function oe(e, t = "Active") {
384
+ function ae(e, t = "Active") {
366
385
  return y({
367
386
  mutationKey: ["operations", "sign-keychain", e],
368
387
  mutationFn: ({ operation: n }) => {
@@ -370,28 +389,28 @@ function oe(e, t = "Active") {
370
389
  throw new Error(
371
390
  "[SDK][Keychain] – cannot sign operation with anon user"
372
391
  );
373
- return K(e, [n], t);
392
+ return g(e, [n], t);
374
393
  }
375
394
  });
376
395
  }
377
- function ie(e = "/") {
396
+ function ce(e = "/") {
378
397
  return y({
379
398
  mutationKey: ["operations", "sign-hivesigner", e],
380
399
  mutationFn: async ({ operation: t }) => d.sendOperation(t, { callback: e }, () => {
381
400
  })
382
401
  });
383
402
  }
384
- function se() {
403
+ function ue() {
385
404
  return p({
386
405
  queryKey: ["operations", "chain-properties"],
387
- queryFn: async () => await s.hiveClient.database.getChainProperties()
406
+ queryFn: async () => await a.hiveClient.database.getChainProperties()
388
407
  });
389
408
  }
390
- function ae(e, t) {
409
+ function pe(e, t) {
391
410
  return p({
392
411
  queryKey: ["hive-engine", "tokens-list", e, t],
393
412
  queryFn: async () => (await (await fetch(
394
- `${s.privateApiHost}/private-api/engine-api`,
413
+ `${a.privateApiHost}/private-api/engine-api`,
395
414
  {
396
415
  method: "POST",
397
416
  body: JSON.stringify({
@@ -412,11 +431,11 @@ function ae(e, t) {
412
431
  )).json()).result
413
432
  });
414
433
  }
415
- function ce(e = 20) {
416
- return k({
434
+ function ye(e = 20) {
435
+ return A({
417
436
  queryKey: ["posts", "trending-tags"],
418
- queryFn: async ({ pageParam: { afterTag: t } }) => s.hiveClient.database.call("get_trending_tags", [t, e]).then(
419
- (n) => n.filter((r) => r.name !== "").filter((r) => !r.name.startsWith("hive-")).map((r) => r.name)
437
+ queryFn: async ({ pageParam: { afterTag: t } }) => a.hiveClient.database.call("get_trending_tags", [t, e]).then(
438
+ (n) => n.filter((o) => o.name !== "").filter((o) => !o.name.startsWith("hive-")).map((o) => o.name)
420
439
  ),
421
440
  initialPageParam: { afterTag: "" },
422
441
  getNextPageParam: (t) => ({
@@ -430,7 +449,7 @@ function v(e) {
430
449
  return p({
431
450
  queryKey: ["posts", "fragments", e],
432
451
  queryFn: async () => (await fetch(
433
- s.privateApiHost + "/private-api/fragments",
452
+ a.privateApiHost + "/private-api/fragments",
434
453
  {
435
454
  method: "POST",
436
455
  body: JSON.stringify({
@@ -444,12 +463,12 @@ function v(e) {
444
463
  enabled: !!e
445
464
  });
446
465
  }
447
- function ue(e = "feed") {
466
+ function le(e = "feed") {
448
467
  return p({
449
468
  queryKey: ["posts", "promoted", e],
450
469
  queryFn: async () => {
451
470
  const t = new URL(
452
- s.privateApiHost + "/private-api/promoted-entries"
471
+ a.privateApiHost + "/private-api/promoted-entries"
453
472
  );
454
473
  return e === "waves" && t.searchParams.append("short_content", "1"), await (await fetch(t.toString(), {
455
474
  method: "GET",
@@ -460,11 +479,11 @@ function ue(e = "feed") {
460
479
  }
461
480
  });
462
481
  }
463
- function pe(e) {
482
+ function fe(e) {
464
483
  return y({
465
484
  mutationKey: ["posts", "add-fragment", e],
466
485
  mutationFn: async ({ title: t, body: n }) => (await fetch(
467
- s.privateApiHost + "/private-api/fragments-add",
486
+ a.privateApiHost + "/private-api/fragments-add",
468
487
  {
469
488
  method: "POST",
470
489
  body: JSON.stringify({
@@ -478,25 +497,25 @@ function pe(e) {
478
497
  }
479
498
  )).json(),
480
499
  onSuccess(t) {
481
- c().setQueryData(
500
+ u().setQueryData(
482
501
  v(e).queryKey,
483
502
  (n) => [t, ...n ?? []]
484
503
  );
485
504
  }
486
505
  });
487
506
  }
488
- function ye(e, t) {
507
+ function he(e, t) {
489
508
  return y({
490
509
  mutationKey: ["posts", "edit-fragment", e, t],
491
- mutationFn: async ({ title: n, body: r }) => (await fetch(
492
- s.privateApiHost + "/private-api/fragments-update",
510
+ mutationFn: async ({ title: n, body: o }) => (await fetch(
511
+ a.privateApiHost + "/private-api/fragments-update",
493
512
  {
494
513
  method: "POST",
495
514
  body: JSON.stringify({
496
515
  code: l(e),
497
516
  id: t,
498
517
  title: n,
499
- body: r
518
+ body: o
500
519
  }),
501
520
  headers: {
502
521
  "Content-Type": "application/json"
@@ -504,22 +523,22 @@ function ye(e, t) {
504
523
  }
505
524
  )).json(),
506
525
  onSuccess(n) {
507
- c().setQueryData(
526
+ u().setQueryData(
508
527
  v(e).queryKey,
509
- (r) => {
510
- if (!r)
528
+ (o) => {
529
+ if (!o)
511
530
  return [];
512
- const o = r.findIndex(({ id: u }) => u === t);
513
- return o >= 0 && (r[o] = n), [...r];
531
+ const i = o.findIndex(({ id: c }) => c === t);
532
+ return i >= 0 && (o[i] = n), [...o];
514
533
  }
515
534
  );
516
535
  }
517
536
  });
518
537
  }
519
- function le(e, t) {
538
+ function de(e, t) {
520
539
  return y({
521
540
  mutationKey: ["posts", "remove-fragment", e],
522
- mutationFn: async () => fetch(s.privateApiHost + "/private-api/fragments-delete", {
541
+ mutationFn: async () => fetch(a.privateApiHost + "/private-api/fragments-delete", {
523
542
  method: "POST",
524
543
  body: JSON.stringify({
525
544
  code: l(e),
@@ -530,20 +549,20 @@ function le(e, t) {
530
549
  }
531
550
  }),
532
551
  onSuccess() {
533
- c().setQueryData(
552
+ u().setQueryData(
534
553
  v(e).queryKey,
535
- (n) => [...n ?? []].filter(({ id: r }) => r !== t)
554
+ (n) => [...n ?? []].filter(({ id: o }) => o !== t)
536
555
  );
537
556
  }
538
557
  });
539
558
  }
540
- function b(e, t) {
559
+ function Q(e, t) {
541
560
  return y({
542
561
  mutationKey: ["analytics", t],
543
562
  mutationFn: async () => {
544
563
  if (!t)
545
564
  throw new Error("[SDK][Analytics] – no activity type provided");
546
- await fetch(s.plausibleHost + "/api/event", {
565
+ await fetch(a.plausibleHost + "/api/event", {
547
566
  method: "POST",
548
567
  headers: {
549
568
  "Content-Type": "application/json"
@@ -560,11 +579,11 @@ function b(e, t) {
560
579
  }
561
580
  });
562
581
  }
563
- const fe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
582
+ const ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
564
583
  __proto__: null,
565
- useRecordActivity: b
584
+ useRecordActivity: Q
566
585
  }, Symbol.toStringTag, { value: "Module" }));
567
- function B(e, t) {
586
+ function E(e, t) {
568
587
  return p({
569
588
  queryKey: ["integrations", "hivesigner", "decode-memo", e],
570
589
  queryFn: async () => {
@@ -576,13 +595,13 @@ function B(e, t) {
576
595
  }
577
596
  });
578
597
  }
579
- const M = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
598
+ const G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
580
599
  __proto__: null,
581
- getDecodeMemoQueryOptions: B
582
- }, Symbol.toStringTag, { value: "Module" })), x = {
583
- queries: M
600
+ getDecodeMemoQueryOptions: E
601
+ }, Symbol.toStringTag, { value: "Module" })), U = {
602
+ queries: G
584
603
  };
585
- function w(e) {
604
+ function m(e) {
586
605
  return p({
587
606
  queryKey: ["integrations", "3speak", "authenticate", e],
588
607
  enabled: !!e,
@@ -596,28 +615,28 @@ function w(e) {
596
615
  "Content-Type": "application/json"
597
616
  }
598
617
  }
599
- ), n = x.queries.getDecodeMemoQueryOptions(
618
+ ), n = U.queries.getDecodeMemoQueryOptions(
600
619
  e,
601
620
  (await t.json()).memo
602
621
  );
603
- await c().prefetchQuery(n);
604
- const { memoDecoded: r } = c().getQueryData(
622
+ await u().prefetchQuery(n);
623
+ const { memoDecoded: o } = u().getQueryData(
605
624
  n.queryKey
606
625
  );
607
- return r.replace("#", "");
626
+ return o.replace("#", "");
608
627
  }
609
628
  });
610
629
  }
611
- function G(e) {
630
+ function x(e) {
612
631
  return p({
613
632
  queryKey: ["integrations", "3speak", "videos", e],
614
633
  enabled: !!e,
615
634
  queryFn: async () => {
616
- await c().prefetchQuery(
617
- w(e)
635
+ await u().prefetchQuery(
636
+ m(e)
618
637
  );
619
- const t = c().getQueryData(
620
- w(e).queryKey
638
+ const t = u().getQueryData(
639
+ m(e).queryKey
621
640
  );
622
641
  return await (await fetch(
623
642
  "https://studio.3speak.tv/mobile/api/my-videos",
@@ -631,31 +650,31 @@ function G(e) {
631
650
  }
632
651
  });
633
652
  }
634
- const U = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
653
+ const z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
635
654
  __proto__: null,
636
- getAccountTokenQueryOptions: w,
637
- getAccountVideosQueryOptions: G
638
- }, Symbol.toStringTag, { value: "Module" })), he = {
639
- queries: U
655
+ getAccountTokenQueryOptions: m,
656
+ getAccountVideosQueryOptions: x
657
+ }, Symbol.toStringTag, { value: "Module" })), we = {
658
+ queries: z
640
659
  };
641
- function de() {
660
+ function me() {
642
661
  return p({
643
662
  queryKey: ["resource-credits", "stats"],
644
- queryFn: async () => (await s.hiveClient.call(
663
+ queryFn: async () => (await a.hiveClient.call(
645
664
  "rc_api",
646
665
  "get_rc_stats",
647
666
  {}
648
667
  )).rc_stats
649
668
  });
650
669
  }
651
- function ge(e) {
670
+ function ve(e) {
652
671
  return p({
653
672
  queryKey: ["resource-credits", "account", e],
654
- queryFn: async () => new D(s.hiveClient).findRCAccounts([e]),
673
+ queryFn: async () => new P(a.hiveClient).findRCAccounts([e]),
655
674
  enabled: !!e
656
675
  });
657
676
  }
658
- function we(e, t) {
677
+ function Ce(e, t) {
659
678
  return p({
660
679
  queryKey: ["games", "status-check", t, e],
661
680
  enabled: !!e,
@@ -663,7 +682,7 @@ function we(e, t) {
663
682
  if (!e)
664
683
  throw new Error("[SDK][Games] – anon user in status check");
665
684
  return await (await fetch(
666
- s.privateApiHost + "/private-api/get-game",
685
+ a.privateApiHost + "/private-api/get-game",
667
686
  {
668
687
  method: "POST",
669
688
  body: JSON.stringify({
@@ -678,8 +697,8 @@ function we(e, t) {
678
697
  }
679
698
  });
680
699
  }
681
- function ve(e, t, n) {
682
- const { mutateAsync: r } = b(
700
+ function be(e, t, n) {
701
+ const { mutateAsync: o } = Q(
683
702
  e,
684
703
  "spin-rolled"
685
704
  );
@@ -689,7 +708,7 @@ function ve(e, t, n) {
689
708
  if (!e)
690
709
  throw new Error("[SDK][Games] – anon user in game post");
691
710
  return await (await fetch(
692
- s.privateApiHost + "/private-api/post-game",
711
+ a.privateApiHost + "/private-api/post-game",
693
712
  {
694
713
  method: "POST",
695
714
  body: JSON.stringify({
@@ -704,45 +723,91 @@ function ve(e, t, n) {
704
723
  )).json();
705
724
  },
706
725
  onSuccess() {
707
- r();
726
+ o();
708
727
  }
709
728
  });
710
729
  }
730
+ function qe(e, t, n = 100, o = void 0, i = !0) {
731
+ return p({
732
+ queryKey: ["communities", "list", e, t, n],
733
+ enabled: i,
734
+ queryFn: async () => await a.hiveClient.call(
735
+ "bridge",
736
+ "list_communities",
737
+ {
738
+ last: "",
739
+ limit: n,
740
+ sort: e,
741
+ query: t,
742
+ observer: o
743
+ }
744
+ ) ?? []
745
+ });
746
+ }
747
+ var W = /* @__PURE__ */ ((e) => (e.OWNER = "owner", e.ADMIN = "admin", e.MOD = "mod", e.MEMBER = "member", e.GUEST = "guest", e.MUTED = "muted", e))(W || {});
748
+ const Oe = {
749
+ owner: [
750
+ "admin",
751
+ "mod",
752
+ "member",
753
+ "guest",
754
+ "muted"
755
+ /* MUTED */
756
+ ],
757
+ admin: [
758
+ "mod",
759
+ "member",
760
+ "guest",
761
+ "muted"
762
+ /* MUTED */
763
+ ],
764
+ mod: [
765
+ "member",
766
+ "guest",
767
+ "muted"
768
+ /* MUTED */
769
+ ]
770
+ };
711
771
  export {
712
- s as CONFIG,
713
- C as ConfigManager,
714
- fe as EcencyAnalytics,
715
- O as EcencyQueriesManager,
716
- x as HiveSignerIntegration,
717
- re as Keychain,
718
- he as ThreeSpeakIntegration,
719
- J as broadcastJson,
720
- ee as checkUsernameWalletsPendingQueryOptions,
772
+ a as CONFIG,
773
+ b as ConfigManager,
774
+ ge as EcencyAnalytics,
775
+ q as EcencyQueriesManager,
776
+ U as HiveSignerIntegration,
777
+ L as Keychain,
778
+ W as ROLES,
779
+ we as ThreeSpeakIntegration,
780
+ H as broadcastJson,
781
+ oe as checkUsernameWalletsPendingQueryOptions,
721
782
  l as getAccessToken,
722
- Z as getAccountFullQueryOptions,
723
- ge as getAccountRcQueryOptions,
724
- se as getChainPropertiesQueryOptions,
783
+ te as getAccountFullQueryOptions,
784
+ ve as getAccountRcQueryOptions,
785
+ re as getAccountSubscriptionsQueryOptions,
786
+ ue as getChainPropertiesQueryOptions,
787
+ qe as getCommunitiesQueryOptions,
725
788
  v as getFragmentsQueryOptions,
726
- we as getGameStatusCheckQueryOptions,
727
- ae as getHiveEngineTokensListQueryOptions,
728
- q as getPostingKey,
729
- ue as getPromotedPostsQuery,
730
- c as getQueryClient,
731
- de as getRcStatsQueryOptions,
732
- V as getRefreshToken,
733
- H as getRelationshipBetweenAccountsQueryOptions,
734
- R as getSearchAccountsByUsernameQueryOptions,
735
- ce as getTrendingTagsQueryOptions,
789
+ Ce as getGameStatusCheckQueryOptions,
790
+ pe as getHiveEngineTokensListQueryOptions,
791
+ S as getLoginType,
792
+ K as getPostingKey,
793
+ le as getPromotedPostsQuery,
794
+ u as getQueryClient,
795
+ me as getRcStatsQueryOptions,
796
+ Z as getRefreshToken,
797
+ B as getRelationshipBetweenAccountsQueryOptions,
798
+ ne as getSearchAccountsByUsernameQueryOptions,
799
+ ye as getTrendingTagsQueryOptions,
736
800
  f as getUser,
737
- X as makeQueryClient,
738
- te as useAccountRelationsUpdate,
739
- Y as useAccountUpdate,
740
- pe as useAddFragment,
741
- N as useBroadcastMutation,
742
- ye as useEditFragment,
743
- ve as useGameClaim,
744
- le as useRemoveFragment,
745
- ie as useSignOperationByHivesigner,
746
- ne as useSignOperationByKey,
747
- oe as useSignOperationByKeychain
801
+ R as makeQueryClient,
802
+ Oe as roleMap,
803
+ ie as useAccountRelationsUpdate,
804
+ ee as useAccountUpdate,
805
+ fe as useAddFragment,
806
+ M as useBroadcastMutation,
807
+ he as useEditFragment,
808
+ be as useGameClaim,
809
+ de as useRemoveFragment,
810
+ ce as useSignOperationByHivesigner,
811
+ se as useSignOperationByKey,
812
+ ae as useSignOperationByKeychain
748
813
  };
package/dist/index.d.ts CHANGED
@@ -8,3 +8,4 @@ export * from './modules/analytics';
8
8
  export * from './modules/integrations';
9
9
  export * from './modules/resource-credits';
10
10
  export * from './modules/games';
11
+ export * from './modules/communities';
@@ -0,0 +1,10 @@
1
+ type Subscriptions = string[];
2
+ export declare function getAccountSubscriptionsQueryOptions(username: string | undefined): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<Subscriptions, Error, Subscriptions, (string | undefined)[]>, "queryFn"> & {
3
+ queryFn?: import('@tanstack/query-core').QueryFunction<Subscriptions, (string | undefined)[], never> | undefined;
4
+ } & {
5
+ queryKey: (string | undefined)[] & {
6
+ [dataTagSymbol]: Subscriptions;
7
+ [dataTagErrorSymbol]: Error;
8
+ };
9
+ };
10
+ export {};
@@ -2,3 +2,4 @@ export * from './get-account-full-query-options';
2
2
  export * from './search-accounts-by-username-query-options';
3
3
  export * from './check-username-wallets-pending-query-options';
4
4
  export * from './get-relationship-between-accounts-query-options';
5
+ export * from './get-account-subscriptions-query-options';
@@ -0,0 +1,2 @@
1
+ export * from './queries';
2
+ export * from './types';
@@ -0,0 +1,9 @@
1
+ import { Communities } from '../types';
2
+ export declare function getCommunitiesQueryOptions(sort: string, query?: string, limit?: number, observer?: string | undefined, enabled?: boolean): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<Communities, Error, Communities, (string | number | undefined)[]>, "queryFn"> & {
3
+ queryFn?: import('@tanstack/query-core').QueryFunction<Communities, (string | number | undefined)[], never> | undefined;
4
+ } & {
5
+ queryKey: (string | number | undefined)[] & {
6
+ [dataTagSymbol]: Communities;
7
+ [dataTagErrorSymbol]: Error;
8
+ };
9
+ };
@@ -0,0 +1 @@
1
+ export * from './get-communities-query-options';
@@ -0,0 +1,31 @@
1
+ export declare enum ROLES {
2
+ OWNER = "owner",
3
+ ADMIN = "admin",
4
+ MOD = "mod",
5
+ MEMBER = "member",
6
+ GUEST = "guest",
7
+ MUTED = "muted"
8
+ }
9
+ export declare const roleMap: Record<string, string[]>;
10
+ export type CommunityTeam = Array<Array<string>>;
11
+ export interface Community {
12
+ about: string;
13
+ admins?: string[];
14
+ avatar_url: string;
15
+ created_at: string;
16
+ description: string;
17
+ flag_text: string;
18
+ id: number;
19
+ is_nsfw: boolean;
20
+ lang: string;
21
+ name: string;
22
+ num_authors: number;
23
+ num_pending: number;
24
+ subscribers: number;
25
+ sum_pending: number;
26
+ settings?: any;
27
+ team: CommunityTeam;
28
+ title: string;
29
+ type_id: number;
30
+ }
31
+ export type Communities = Community[];
@@ -0,0 +1 @@
1
+ export * from './community';
@@ -4,5 +4,6 @@ export interface StoringUser {
4
4
  refreshToken: string;
5
5
  expiresIn: number;
6
6
  postingKey: null | undefined | string;
7
+ loginType: null | undefined | string;
7
8
  index?: number;
8
9
  }
@@ -2,4 +2,5 @@ import { StoringUser } from './entities';
2
2
  export declare const getUser: (username: string) => StoringUser | undefined;
3
3
  export declare const getAccessToken: (username: string) => string | undefined;
4
4
  export declare const getPostingKey: (username: string) => null | undefined | string;
5
+ export declare const getLoginType: (username: string) => null | undefined | string;
5
6
  export declare const getRefreshToken: (username: string) => string | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ecency/sdk",
3
3
  "private": false,
4
- "version": "1.0.45",
4
+ "version": "1.0.47",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "./dist/ecency-sdk.umd.js",