@ecency/sdk 1.0.34 → 1.0.35

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 O = Object.defineProperty;
2
- var K = (e, t, n) => t in e ? O(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var d = (e, t, n) => K(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { QueryClient as v, useMutation as y, useQuery as Q, useInfiniteQuery as b, queryOptions as f, infiniteQueryOptions as q } from "@tanstack/react-query";
5
- import { Client as S, PrivateKey as l, cryptoUtils as _ } from "@hiveio/dhive";
6
- import m from "hivesigner";
7
- class k {
1
+ var b = Object.defineProperty;
2
+ var Q = (e, t, n) => t in e ? b(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var w = (e, t, n) => Q(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { QueryClient as C, useMutation as l, useQuery as K, useInfiniteQuery as S, queryOptions as y, infiniteQueryOptions as _ } from "@tanstack/react-query";
5
+ import { Client as k, PrivateKey as h, cryptoUtils as T } from "@hiveio/dhive";
6
+ import g from "hivesigner";
7
+ class j {
8
8
  constructor() {
9
- d(this, "length", 0);
9
+ w(this, "length", 0);
10
10
  }
11
11
  clear() {
12
12
  throw new Error("Method not implemented.");
@@ -26,9 +26,9 @@ class k {
26
26
  }
27
27
  const o = {
28
28
  privateApiHost: "https://ecency.com",
29
- storage: typeof window > "u" ? new k() : window.localStorage,
29
+ storage: typeof window > "u" ? new j() : window.localStorage,
30
30
  storagePrefix: "ecency",
31
- hiveClient: new S(
31
+ hiveClient: new k(
32
32
  [
33
33
  "https://api.hive.blog",
34
34
  "https://api.deathwing.me",
@@ -49,17 +49,17 @@ const o = {
49
49
  }
50
50
  ),
51
51
  heliusApiKey: void 0,
52
- queryClient: new v(),
52
+ queryClient: new C(),
53
53
  plausibleHost: "https://pl.ecency.com"
54
54
  };
55
- var g;
55
+ var v;
56
56
  ((e) => {
57
57
  function t(n) {
58
58
  o.queryClient = n;
59
59
  }
60
60
  e.setQueryClient = t;
61
- })(g || (g = {}));
62
- function T(e) {
61
+ })(v || (v = {}));
62
+ function A(e) {
63
63
  let t = atob(e);
64
64
  if (t[0] === "{")
65
65
  return JSON.parse(t);
@@ -69,32 +69,32 @@ const p = (e) => {
69
69
  const t = o.storage.getItem(
70
70
  o.storagePrefix + "_user_" + e
71
71
  );
72
- return T(JSON.parse(t));
72
+ return A(JSON.parse(t));
73
73
  } catch (t) {
74
74
  console.error(t);
75
75
  return;
76
76
  }
77
- }, A = (e) => p(e) && p(e).accessToken, I = (e) => p(e) && p(e).postingKey, J = (e) => p(e) && p(e).refreshToken;
78
- function j(e = [], t, n) {
79
- return y({
77
+ }, O = (e) => p(e) && p(e).accessToken, D = (e) => p(e) && p(e).postingKey, W = (e) => p(e) && p(e).refreshToken;
78
+ function I(e = [], t, n) {
79
+ return l({
80
80
  mutationKey: [...e, t],
81
81
  mutationFn: async (r) => {
82
82
  if (!t)
83
83
  throw new Error(
84
84
  "[Core][Broadcast] Attempted to call broadcast API with anon user"
85
85
  );
86
- const a = I(t);
86
+ const a = D(t);
87
87
  if (a) {
88
- const c = l.fromString(a);
88
+ const u = h.fromString(a);
89
89
  return o.hiveClient.broadcast.sendOperations(
90
90
  n(r),
91
- c
91
+ u
92
92
  );
93
93
  }
94
- let s = A(t);
95
- if (s)
96
- return (await new m.Client({
97
- accessToken: s
94
+ let c = O(t);
95
+ if (c)
96
+ return (await new g.Client({
97
+ accessToken: c
98
98
  }).broadcast(n(r))).result;
99
99
  throw new Error(
100
100
  "[SDK][Broadcast] – cannot broadcast w/o posting key or token"
@@ -102,8 +102,8 @@ function j(e = [], t, n) {
102
102
  }
103
103
  });
104
104
  }
105
- function x() {
106
- return new v({
105
+ function $() {
106
+ return new C({
107
107
  defaultOptions: {
108
108
  queries: {
109
109
  // With SSR, we usually want to set some default staleTime
@@ -115,46 +115,46 @@ function x() {
115
115
  }
116
116
  });
117
117
  }
118
- const u = () => o.queryClient;
119
- var w;
118
+ const s = () => o.queryClient;
119
+ var m;
120
120
  ((e) => {
121
121
  function t(i) {
122
- return u().getQueryData(i);
122
+ return s().getQueryData(i);
123
123
  }
124
124
  e.getQueryData = t;
125
125
  function n(i) {
126
- return u().getQueryData(i);
126
+ return s().getQueryData(i);
127
127
  }
128
128
  e.getInfiniteQueryData = n;
129
129
  async function r(i) {
130
- return await u().prefetchQuery(i), t(i.queryKey);
130
+ return await s().prefetchQuery(i), t(i.queryKey);
131
131
  }
132
132
  e.prefetchQuery = r;
133
133
  async function a(i) {
134
- return await u().prefetchInfiniteQuery(i), n(i.queryKey);
134
+ return await s().prefetchInfiniteQuery(i), n(i.queryKey);
135
135
  }
136
136
  e.prefetchInfiniteQuery = a;
137
- function s(i) {
137
+ function c(i) {
138
138
  return {
139
139
  prefetch: () => r(i),
140
140
  getData: () => t(i.queryKey),
141
- useClientQuery: () => Q(i),
142
- fetchAndGet: () => u().fetchQuery(i)
141
+ useClientQuery: () => K(i),
142
+ fetchAndGet: () => s().fetchQuery(i)
143
143
  };
144
144
  }
145
- e.generateClientServerQuery = s;
146
- function c(i) {
145
+ e.generateClientServerQuery = c;
146
+ function u(i) {
147
147
  return {
148
148
  prefetch: () => a(i),
149
149
  getData: () => n(i.queryKey),
150
- useClientQuery: () => b(i),
151
- fetchAndGet: () => u().fetchInfiniteQuery(i)
150
+ useClientQuery: () => S(i),
151
+ fetchAndGet: () => s().fetchInfiniteQuery(i)
152
152
  };
153
153
  }
154
- e.generateClientServerInfiniteQuery = c;
155
- })(w || (w = {}));
156
- function E(e) {
157
- return j(
154
+ e.generateClientServerInfiniteQuery = u;
155
+ })(m || (m = {}));
156
+ function G(e) {
157
+ return I(
158
158
  ["accounts", "update"],
159
159
  e,
160
160
  ({
@@ -176,8 +176,8 @@ function E(e) {
176
176
  ]
177
177
  );
178
178
  }
179
- function M(e) {
180
- return f({
179
+ function R(e) {
180
+ return y({
181
181
  queryKey: ["get-account-full", e],
182
182
  queryFn: async () => {
183
183
  if (!e)
@@ -213,8 +213,8 @@ function M(e) {
213
213
  staleTime: 6e4
214
214
  });
215
215
  }
216
- function U(e, t = 5, n = []) {
217
- return f({
216
+ function V(e, t = 5, n = []) {
217
+ return y({
218
218
  queryKey: ["accounts", "search", e, n],
219
219
  enabled: !!e,
220
220
  queryFn: async () => (await o.hiveClient.database.call(
@@ -225,8 +225,8 @@ function U(e, t = 5, n = []) {
225
225
  )
226
226
  });
227
227
  }
228
- function W(e) {
229
- return f({
228
+ function L(e) {
229
+ return y({
230
230
  queryKey: ["accounts", "check-wallet-pending", e],
231
231
  queryFn: async () => await (await fetch(
232
232
  o.privateApiHost + "/private-api/wallets-chkuser",
@@ -244,8 +244,8 @@ function W(e) {
244
244
  refetchOnMount: !0
245
245
  });
246
246
  }
247
- function G(e) {
248
- return y({
247
+ function X(e) {
248
+ return l({
249
249
  mutationKey: ["operations", "sign", e],
250
250
  mutationFn: ({
251
251
  operation: t,
@@ -254,7 +254,7 @@ function G(e) {
254
254
  if (!e)
255
255
  throw new Error("[Operations][Sign] – cannot sign op with anon user");
256
256
  let r;
257
- return n.split(" ").length === 12 ? r = l.fromLogin(e, n, "active") : _.isWif(n) ? r = l.fromString(n) : r = l.from(n), o.hiveClient.broadcast.sendOperations(
257
+ return n.split(" ").length === 12 ? r = h.fromLogin(e, n, "active") : T.isWif(n) ? r = h.fromString(n) : r = h.from(n), o.hiveClient.broadcast.sendOperations(
258
258
  [t],
259
259
  r
260
260
  );
@@ -269,43 +269,43 @@ function F() {
269
269
  });
270
270
  });
271
271
  }
272
- const C = (e, t, n, r = null) => new Promise((a, s) => {
273
- var c;
274
- (c = window.hive_keychain) == null || c.requestBroadcast(
272
+ const q = (e, t, n, r = null) => new Promise((a, c) => {
273
+ var u;
274
+ (u = window.hive_keychain) == null || u.requestBroadcast(
275
275
  e,
276
276
  t,
277
277
  n,
278
278
  (i) => {
279
- i.success || s({ message: "Operation cancelled" }), a(i);
279
+ i.success || c({ message: "Operation cancelled" }), a(i);
280
280
  },
281
281
  r
282
282
  );
283
- }), z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
283
+ }), Y = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
284
284
  __proto__: null,
285
- broadcast: C,
285
+ broadcast: q,
286
286
  handshake: F
287
287
  }, Symbol.toStringTag, { value: "Module" }));
288
- function R(e, t = "Active") {
289
- return y({
288
+ function Z(e, t = "Active") {
289
+ return l({
290
290
  mutationKey: ["operations", "sign-keychain", e],
291
291
  mutationFn: ({ operation: n }) => {
292
292
  if (!e)
293
293
  throw new Error(
294
294
  "[SDK][Keychain] – cannot sign operation with anon user"
295
295
  );
296
- return C(e, [n], t);
296
+ return q(e, [n], t);
297
297
  }
298
298
  });
299
299
  }
300
- function $(e = "/") {
301
- return y({
300
+ function ee(e = "/") {
301
+ return l({
302
302
  mutationKey: ["operations", "sign-hivesigner", e],
303
- mutationFn: async ({ operation: t }) => m.sendOperation(t, { callback: e }, () => {
303
+ mutationFn: async ({ operation: t }) => g.sendOperation(t, { callback: e }, () => {
304
304
  })
305
305
  });
306
306
  }
307
- function L(e, t) {
308
- return f({
307
+ function te(e, t) {
308
+ return y({
309
309
  queryKey: ["hive-engine", "tokens-list", e, t],
310
310
  queryFn: async () => (await (await fetch(
311
311
  `${o.privateApiHost}/private-api/engine-api`,
@@ -329,8 +329,8 @@ function L(e, t) {
329
329
  )).json()).result
330
330
  });
331
331
  }
332
- function V(e = 20) {
333
- return q({
332
+ function ne(e = 20) {
333
+ return _({
334
334
  queryKey: ["posts", "trending-tags"],
335
335
  queryFn: async ({ pageParam: { afterTag: t } }) => o.hiveClient.database.call("get_trending_tags", [t, e]).then(
336
336
  (n) => n.filter((r) => r.name !== "").filter((r) => !r.name.startsWith("hive-")).map((r) => r.name)
@@ -343,8 +343,8 @@ function V(e = 20) {
343
343
  refetchOnMount: !0
344
344
  });
345
345
  }
346
- function D(e, t) {
347
- return y({
346
+ function P(e, t) {
347
+ return l({
348
348
  mutationKey: ["analytics", t],
349
349
  mutationFn: async () => {
350
350
  if (!t)
@@ -366,30 +366,106 @@ function D(e, t) {
366
366
  }
367
367
  });
368
368
  }
369
- const X = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
369
+ const re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
370
370
  __proto__: null,
371
- useRecordActivity: D
371
+ useRecordActivity: P
372
372
  }, Symbol.toStringTag, { value: "Module" }));
373
+ function M(e, t) {
374
+ return y({
375
+ queryKey: ["integrations", "hivesigner", "decode-memo", e],
376
+ queryFn: async () => {
377
+ const n = O(e);
378
+ if (n)
379
+ return new g.Client({
380
+ accessToken: n
381
+ }).decode(t);
382
+ }
383
+ });
384
+ }
385
+ const N = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
386
+ __proto__: null,
387
+ getDecodeMemoQueryOptions: M
388
+ }, Symbol.toStringTag, { value: "Module" })), B = {
389
+ queries: N
390
+ };
391
+ function d(e) {
392
+ return y({
393
+ queryKey: ["integrations", "3speak", "authenticate", e],
394
+ enabled: !!e,
395
+ queryFn: async () => {
396
+ if (!e)
397
+ throw new Error("[SDK][Integrations][3Speak] – anon user");
398
+ const t = await fetch(
399
+ `https://studio.3speak.tv/mobile/login?username=${e}&hivesigner=true`,
400
+ {
401
+ headers: {
402
+ "Content-Type": "application/json"
403
+ }
404
+ }
405
+ ), n = B.queries.getDecodeMemoQueryOptions(
406
+ e,
407
+ (await t.json()).memo
408
+ );
409
+ await s().prefetchQuery(n);
410
+ const { memoDecoded: r } = s().getQueryData(
411
+ n.queryKey
412
+ );
413
+ return r.replace("#", "");
414
+ }
415
+ });
416
+ }
417
+ function H(e) {
418
+ return y({
419
+ queryKey: ["integrations", "3speak", "videos", e],
420
+ enabled: !!e,
421
+ queryFn: async () => {
422
+ await s().prefetchQuery(
423
+ d(e)
424
+ );
425
+ const t = s().getQueryData(
426
+ d(e).queryKey
427
+ );
428
+ return await (await fetch(
429
+ "https://studio.3speak.tv/mobile/api/my-videos",
430
+ {
431
+ headers: {
432
+ "Content-Type": "application/json",
433
+ Authorization: `Bearer ${t}`
434
+ }
435
+ }
436
+ )).json();
437
+ }
438
+ });
439
+ }
440
+ const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
441
+ __proto__: null,
442
+ getAccountTokenQueryOptions: d,
443
+ getAccountVideosQueryOptions: H
444
+ }, Symbol.toStringTag, { value: "Module" })), ie = {
445
+ queries: E
446
+ };
373
447
  export {
374
448
  o as CONFIG,
375
- g as ConfigManager,
376
- X as EcencyAnalytics,
377
- w as EcencyQueriesManager,
378
- z as Keychain,
379
- W as checkUsernameWalletsPendingQueryOptions,
380
- A as getAccessToken,
381
- M as getAccountFullQueryOptions,
382
- L as getHiveEngineTokensListQueryOptions,
383
- I as getPostingKey,
384
- u as getQueryClient,
385
- J as getRefreshToken,
386
- U as getSearchAccountsByUsernameQueryOptions,
387
- V as getTrendingTagsQueryOptions,
449
+ v as ConfigManager,
450
+ re as EcencyAnalytics,
451
+ m as EcencyQueriesManager,
452
+ B as HiveSignerIntegration,
453
+ Y as Keychain,
454
+ ie as ThreeSpeakIntegration,
455
+ L as checkUsernameWalletsPendingQueryOptions,
456
+ O as getAccessToken,
457
+ R as getAccountFullQueryOptions,
458
+ te as getHiveEngineTokensListQueryOptions,
459
+ D as getPostingKey,
460
+ s as getQueryClient,
461
+ W as getRefreshToken,
462
+ V as getSearchAccountsByUsernameQueryOptions,
463
+ ne as getTrendingTagsQueryOptions,
388
464
  p as getUser,
389
- x as makeQueryClient,
390
- E as useAccountUpdate,
391
- j as useBroadcastMutation,
392
- $ as useSignOperationByHivesigner,
393
- G as useSignOperationByKey,
394
- R as useSignOperationByKeychain
465
+ $ as makeQueryClient,
466
+ G as useAccountUpdate,
467
+ I as useBroadcastMutation,
468
+ ee as useSignOperationByHivesigner,
469
+ X as useSignOperationByKey,
470
+ Z as useSignOperationByKeychain
395
471
  };
package/dist/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export * from './modules/hive-engine';
5
5
  export * from './modules/keychain';
6
6
  export * from './modules/posts';
7
7
  export * from './modules/analytics';
8
+ export * from './modules/integrations';
@@ -1,15 +1,15 @@
1
1
  export declare function checkUsernameWalletsPendingQueryOptions(username: string): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<{
2
- exists: boolean;
2
+ exist: boolean;
3
3
  }, Error, {
4
- exists: boolean;
4
+ exist: boolean;
5
5
  }, string[]>, "queryFn"> & {
6
6
  queryFn?: import('@tanstack/query-core').QueryFunction<{
7
- exists: boolean;
7
+ exist: boolean;
8
8
  }, string[], never> | undefined;
9
9
  } & {
10
10
  queryKey: string[] & {
11
11
  [dataTagSymbol]: {
12
- exists: boolean;
12
+ exist: boolean;
13
13
  };
14
14
  [dataTagErrorSymbol]: Error;
15
15
  };
@@ -0,0 +1,6 @@
1
+ export * from './types';
2
+ import * as queries from "./queries";
3
+ declare const ThreeSpeakIntegration: {
4
+ queries: typeof queries;
5
+ };
6
+ export { ThreeSpeakIntegration };
@@ -0,0 +1,8 @@
1
+ export declare function getAccountTokenQueryOptions(username: string | undefined): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<any, Error, any, (string | undefined)[]>, "queryFn"> & {
2
+ queryFn?: import('@tanstack/query-core').QueryFunction<any, (string | undefined)[], never> | undefined;
3
+ } & {
4
+ queryKey: (string | undefined)[] & {
5
+ [dataTagSymbol]: any;
6
+ [dataTagErrorSymbol]: Error;
7
+ };
8
+ };
@@ -0,0 +1,9 @@
1
+ import { ThreeSpeakVideo } from '../types';
2
+ export declare function getAccountVideosQueryOptions(username: string | undefined): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<ThreeSpeakVideo[], Error, ThreeSpeakVideo[], (string | undefined)[]>, "queryFn"> & {
3
+ queryFn?: import('@tanstack/query-core').QueryFunction<ThreeSpeakVideo[], (string | undefined)[], never> | undefined;
4
+ } & {
5
+ queryKey: (string | undefined)[] & {
6
+ [dataTagSymbol]: ThreeSpeakVideo[];
7
+ [dataTagErrorSymbol]: Error;
8
+ };
9
+ };
@@ -0,0 +1,2 @@
1
+ export * from './get-account-token-query-options';
2
+ export * from './get-account-videos-query-options';
@@ -0,0 +1 @@
1
+ export * from './three-speak-video';
@@ -0,0 +1,52 @@
1
+ export interface ThreeSpeakVideo {
2
+ app: string;
3
+ beneficiaries: string;
4
+ category: string;
5
+ community: unknown | null;
6
+ created: string;
7
+ declineRewards: boolean;
8
+ description: string;
9
+ donations: boolean;
10
+ duration: number;
11
+ encoding: Record<number, boolean>;
12
+ encodingProgress: number;
13
+ encoding_price_steem: string;
14
+ filename: string;
15
+ firstUpload: boolean;
16
+ fromMobile: boolean;
17
+ height: unknown;
18
+ hive: string;
19
+ indexed: boolean;
20
+ is3CJContent: boolean;
21
+ isNsfwContent: boolean;
22
+ isReel: boolean;
23
+ isVOD: boolean;
24
+ job_id: string;
25
+ language: string;
26
+ local_filename: string;
27
+ lowRc: boolean;
28
+ needsBlockchainUpdate: boolean;
29
+ originalFilename: string;
30
+ owner: string;
31
+ paid: boolean;
32
+ permlink: string;
33
+ postToHiveBlog: boolean;
34
+ publish_type: string;
35
+ reducedUpvote: boolean;
36
+ rewardPowerup: boolean;
37
+ size: number;
38
+ status: string;
39
+ tags_v2: unknown[];
40
+ thumbUrl: string;
41
+ thumbnail: string;
42
+ title: string;
43
+ updateSteem: boolean;
44
+ upload_type: string;
45
+ upvoteEligible: boolean;
46
+ video_v2: string;
47
+ views: number;
48
+ votePercent: number;
49
+ width: unknown;
50
+ __v: number;
51
+ _id: string;
52
+ }
@@ -0,0 +1,5 @@
1
+ import * as queries from "./queries";
2
+ declare const HiveSignerIntegration: {
3
+ queries: typeof queries;
4
+ };
5
+ export { HiveSignerIntegration };
@@ -0,0 +1,8 @@
1
+ export declare function getDecodeMemoQueryOptions(username: string, memo: string): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<any, Error, any, string[]>, "queryFn"> & {
2
+ queryFn?: import('@tanstack/query-core').QueryFunction<any, string[], never> | undefined;
3
+ } & {
4
+ queryKey: string[] & {
5
+ [dataTagSymbol]: any;
6
+ [dataTagErrorSymbol]: Error;
7
+ };
8
+ };
@@ -0,0 +1 @@
1
+ export * from './get-decode-memo-query-options';
@@ -0,0 +1,2 @@
1
+ export * from './3speak';
2
+ export * from './hivesigner';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ecency/sdk",
3
3
  "private": false,
4
- "version": "1.0.34",
4
+ "version": "1.0.35",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "./dist/ecency-sdk.umd.js",