@ecency/sdk 1.5.4 → 1.5.6
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 +13 -0
- package/dist/browser/index.js +29 -14
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +29 -14
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +29 -14
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -115,6 +115,16 @@ exports.ConfigManager = void 0;
|
|
|
115
115
|
CONFIG.privateApiHost = host;
|
|
116
116
|
}
|
|
117
117
|
ConfigManager2.setPrivateApiHost = setPrivateApiHost;
|
|
118
|
+
function getValidatedBaseUrl() {
|
|
119
|
+
if (CONFIG.privateApiHost) {
|
|
120
|
+
return CONFIG.privateApiHost;
|
|
121
|
+
}
|
|
122
|
+
if (typeof window !== "undefined" && window.location?.origin) {
|
|
123
|
+
return window.location.origin;
|
|
124
|
+
}
|
|
125
|
+
return "https://ecency.com";
|
|
126
|
+
}
|
|
127
|
+
ConfigManager2.getValidatedBaseUrl = getValidatedBaseUrl;
|
|
118
128
|
function setImageHost(host) {
|
|
119
129
|
CONFIG.imageHost = host;
|
|
120
130
|
}
|
|
@@ -1049,7 +1059,8 @@ function getReferralsInfiniteQueryOptions(username) {
|
|
|
1049
1059
|
initialPageParam: { maxId: void 0 },
|
|
1050
1060
|
queryFn: async ({ pageParam }) => {
|
|
1051
1061
|
const { maxId } = pageParam ?? {};
|
|
1052
|
-
const
|
|
1062
|
+
const baseUrl = exports.ConfigManager.getValidatedBaseUrl();
|
|
1063
|
+
const url = new URL(`/private-api/referrals/${username}`, baseUrl);
|
|
1053
1064
|
if (maxId !== void 0) {
|
|
1054
1065
|
url.searchParams.set("max_id", maxId.toString());
|
|
1055
1066
|
}
|
|
@@ -1212,9 +1223,8 @@ function getPromotedPostsQuery(type = "feed") {
|
|
|
1212
1223
|
return reactQuery.queryOptions({
|
|
1213
1224
|
queryKey: ["posts", "promoted", type],
|
|
1214
1225
|
queryFn: async () => {
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1217
|
-
);
|
|
1226
|
+
const baseUrl = exports.ConfigManager.getValidatedBaseUrl();
|
|
1227
|
+
const url = new URL("/private-api/promoted-entries", baseUrl);
|
|
1218
1228
|
if (type === "waves") {
|
|
1219
1229
|
url.searchParams.append("short_content", "1");
|
|
1220
1230
|
}
|
|
@@ -1285,7 +1295,7 @@ function filterDmcaEntry(entryOrEntries) {
|
|
|
1285
1295
|
function applyFilter(entry) {
|
|
1286
1296
|
if (!entry) return entry;
|
|
1287
1297
|
const entryPath = `@${entry.author}/${entry.permlink}`;
|
|
1288
|
-
const isDmca = CONFIG.dmcaPatternRegexes.some((regex) => regex.test(entryPath));
|
|
1298
|
+
const isDmca = CONFIG.dmcaPatterns.includes(entryPath) || CONFIG.dmcaPatternRegexes.some((regex) => regex.test(entryPath));
|
|
1289
1299
|
if (isDmca) {
|
|
1290
1300
|
return {
|
|
1291
1301
|
...entry,
|
|
@@ -2139,7 +2149,8 @@ function getWavesByTagQueryOptions(host, tag, limit = DEFAULT_TAG_FEED_LIMIT) {
|
|
|
2139
2149
|
initialPageParam: void 0,
|
|
2140
2150
|
queryFn: async ({ signal }) => {
|
|
2141
2151
|
try {
|
|
2142
|
-
const
|
|
2152
|
+
const baseUrl = exports.ConfigManager.getValidatedBaseUrl();
|
|
2153
|
+
const url = new URL("/private-api/waves/tags", baseUrl);
|
|
2143
2154
|
url.searchParams.set("container", host);
|
|
2144
2155
|
url.searchParams.set("tag", tag);
|
|
2145
2156
|
const response = await fetch(url.toString(), {
|
|
@@ -2176,7 +2187,8 @@ function getWavesFollowingQueryOptions(host, username) {
|
|
|
2176
2187
|
return [];
|
|
2177
2188
|
}
|
|
2178
2189
|
try {
|
|
2179
|
-
const
|
|
2190
|
+
const baseUrl = exports.ConfigManager.getValidatedBaseUrl();
|
|
2191
|
+
const url = new URL("/private-api/waves/following", baseUrl);
|
|
2180
2192
|
url.searchParams.set("container", host);
|
|
2181
2193
|
url.searchParams.set("username", normalizedUsername);
|
|
2182
2194
|
const response = await fetch(url.toString(), {
|
|
@@ -2213,7 +2225,8 @@ function getWavesTrendingTagsQueryOptions(host, hours = 24) {
|
|
|
2213
2225
|
queryKey: ["posts", "waves", "trending-tags", host, hours],
|
|
2214
2226
|
queryFn: async ({ signal }) => {
|
|
2215
2227
|
try {
|
|
2216
|
-
const
|
|
2228
|
+
const baseUrl = exports.ConfigManager.getValidatedBaseUrl();
|
|
2229
|
+
const url = new URL("/private-api/waves/trending/tags", baseUrl);
|
|
2217
2230
|
url.searchParams.set("container", host);
|
|
2218
2231
|
url.searchParams.set("hours", hours.toString());
|
|
2219
2232
|
const response = await fetch(url.toString(), {
|
|
@@ -4853,7 +4866,8 @@ async function hsTokenRenew(code) {
|
|
|
4853
4866
|
var ENGINE_RPC_HEADERS = { "Content-type": "application/json" };
|
|
4854
4867
|
async function engineRpc(payload) {
|
|
4855
4868
|
const fetchApi = getBoundFetch();
|
|
4856
|
-
const
|
|
4869
|
+
const baseUrl = exports.ConfigManager.getValidatedBaseUrl();
|
|
4870
|
+
const response = await fetchApi(`${baseUrl}/private-api/engine-api`, {
|
|
4857
4871
|
method: "POST",
|
|
4858
4872
|
body: JSON.stringify(payload),
|
|
4859
4873
|
headers: ENGINE_RPC_HEADERS
|
|
@@ -5058,9 +5072,8 @@ async function getHiveEngineTokensMetadata(tokens) {
|
|
|
5058
5072
|
}
|
|
5059
5073
|
async function getHiveEngineTokenTransactions(username, symbol, limit, offset) {
|
|
5060
5074
|
const fetchApi = getBoundFetch();
|
|
5061
|
-
const
|
|
5062
|
-
|
|
5063
|
-
);
|
|
5075
|
+
const baseUrl = exports.ConfigManager.getValidatedBaseUrl();
|
|
5076
|
+
const url = new URL("/private-api/engine-account-history", baseUrl);
|
|
5064
5077
|
url.searchParams.set("account", username);
|
|
5065
5078
|
url.searchParams.set("symbol", symbol);
|
|
5066
5079
|
url.searchParams.set("limit", limit.toString());
|
|
@@ -5078,7 +5091,8 @@ async function getHiveEngineTokenTransactions(username, symbol, limit, offset) {
|
|
|
5078
5091
|
}
|
|
5079
5092
|
async function getHiveEngineTokenMetrics(symbol, interval = "daily") {
|
|
5080
5093
|
const fetchApi = getBoundFetch();
|
|
5081
|
-
const
|
|
5094
|
+
const baseUrl = exports.ConfigManager.getValidatedBaseUrl();
|
|
5095
|
+
const url = new URL("/private-api/engine-chart-api", baseUrl);
|
|
5082
5096
|
url.searchParams.set("symbol", symbol);
|
|
5083
5097
|
url.searchParams.set("interval", interval);
|
|
5084
5098
|
const response = await fetchApi(url.toString(), {
|
|
@@ -5093,8 +5107,9 @@ async function getHiveEngineTokenMetrics(symbol, interval = "daily") {
|
|
|
5093
5107
|
}
|
|
5094
5108
|
async function getHiveEngineUnclaimedRewards(username) {
|
|
5095
5109
|
const fetchApi = getBoundFetch();
|
|
5110
|
+
const baseUrl = exports.ConfigManager.getValidatedBaseUrl();
|
|
5096
5111
|
const response = await fetchApi(
|
|
5097
|
-
`${
|
|
5112
|
+
`${baseUrl}/private-api/engine-reward-api/${username}?hive=1`
|
|
5098
5113
|
);
|
|
5099
5114
|
if (!response.ok) {
|
|
5100
5115
|
throw new Error(
|