@ecency/sdk 1.5.5 → 1.5.7
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 +37 -21
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +50 -21
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +50 -21
- 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
|
}
|
|
@@ -173,35 +183,48 @@ exports.ConfigManager = void 0;
|
|
|
173
183
|
return { safe: true };
|
|
174
184
|
}
|
|
175
185
|
function safeCompileRegex(pattern, maxLength = 200) {
|
|
186
|
+
const isDevelopment = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
|
|
176
187
|
try {
|
|
177
188
|
if (!pattern) {
|
|
178
|
-
|
|
189
|
+
if (isDevelopment) {
|
|
190
|
+
console.warn(`[SDK] DMCA pattern rejected: empty pattern`);
|
|
191
|
+
}
|
|
179
192
|
return null;
|
|
180
193
|
}
|
|
181
194
|
if (pattern.length > maxLength) {
|
|
182
|
-
|
|
195
|
+
if (isDevelopment) {
|
|
196
|
+
console.warn(`[SDK] DMCA pattern rejected: length ${pattern.length} exceeds max ${maxLength} - pattern: ${pattern.substring(0, 50)}...`);
|
|
197
|
+
}
|
|
183
198
|
return null;
|
|
184
199
|
}
|
|
185
200
|
const staticAnalysis = analyzeRedosRisk(pattern);
|
|
186
201
|
if (!staticAnalysis.safe) {
|
|
187
|
-
|
|
202
|
+
if (isDevelopment) {
|
|
203
|
+
console.warn(`[SDK] DMCA pattern rejected: static analysis failed (${staticAnalysis.reason}) - pattern: ${pattern.substring(0, 50)}...`);
|
|
204
|
+
}
|
|
188
205
|
return null;
|
|
189
206
|
}
|
|
190
207
|
let regex;
|
|
191
208
|
try {
|
|
192
209
|
regex = new RegExp(pattern);
|
|
193
210
|
} catch (compileErr) {
|
|
194
|
-
|
|
211
|
+
if (isDevelopment) {
|
|
212
|
+
console.warn(`[SDK] DMCA pattern rejected: compilation failed - pattern: ${pattern.substring(0, 50)}...`, compileErr);
|
|
213
|
+
}
|
|
195
214
|
return null;
|
|
196
215
|
}
|
|
197
216
|
const runtimeTest = testRegexPerformance(regex);
|
|
198
217
|
if (!runtimeTest.safe) {
|
|
199
|
-
|
|
218
|
+
if (isDevelopment) {
|
|
219
|
+
console.warn(`[SDK] DMCA pattern rejected: runtime test failed (${runtimeTest.reason}) - pattern: ${pattern.substring(0, 50)}...`);
|
|
220
|
+
}
|
|
200
221
|
return null;
|
|
201
222
|
}
|
|
202
223
|
return regex;
|
|
203
224
|
} catch (err) {
|
|
204
|
-
|
|
225
|
+
if (isDevelopment) {
|
|
226
|
+
console.warn(`[SDK] DMCA pattern rejected: unexpected error - pattern: ${pattern.substring(0, 50)}...`, err);
|
|
227
|
+
}
|
|
205
228
|
return null;
|
|
206
229
|
}
|
|
207
230
|
}
|
|
@@ -212,7 +235,8 @@ exports.ConfigManager = void 0;
|
|
|
212
235
|
CONFIG.dmcaTagRegexes = tags.map((pattern) => safeCompileRegex(pattern)).filter((r) => r !== null);
|
|
213
236
|
CONFIG.dmcaPatternRegexes = [];
|
|
214
237
|
const rejectedTagCount = tags.length - CONFIG.dmcaTagRegexes.length;
|
|
215
|
-
|
|
238
|
+
const isDevelopment = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
|
|
239
|
+
if (!CONFIG._dmcaInitialized && isDevelopment) {
|
|
216
240
|
console.log(`[SDK] DMCA configuration loaded:`);
|
|
217
241
|
console.log(` - Accounts: ${accounts.length}`);
|
|
218
242
|
console.log(` - Tag patterns: ${CONFIG.dmcaTagRegexes.length}/${tags.length} compiled (${rejectedTagCount} rejected)`);
|
|
@@ -220,8 +244,8 @@ exports.ConfigManager = void 0;
|
|
|
220
244
|
if (rejectedTagCount > 0) {
|
|
221
245
|
console.warn(`[SDK] ${rejectedTagCount} DMCA tag patterns were rejected due to security validation. Check warnings above for details.`);
|
|
222
246
|
}
|
|
223
|
-
CONFIG._dmcaInitialized = true;
|
|
224
247
|
}
|
|
248
|
+
CONFIG._dmcaInitialized = true;
|
|
225
249
|
}
|
|
226
250
|
ConfigManager2.setDmcaLists = setDmcaLists;
|
|
227
251
|
})(exports.ConfigManager || (exports.ConfigManager = {}));
|
|
@@ -1049,7 +1073,8 @@ function getReferralsInfiniteQueryOptions(username) {
|
|
|
1049
1073
|
initialPageParam: { maxId: void 0 },
|
|
1050
1074
|
queryFn: async ({ pageParam }) => {
|
|
1051
1075
|
const { maxId } = pageParam ?? {};
|
|
1052
|
-
const
|
|
1076
|
+
const baseUrl = exports.ConfigManager.getValidatedBaseUrl();
|
|
1077
|
+
const url = new URL(`/private-api/referrals/${username}`, baseUrl);
|
|
1053
1078
|
if (maxId !== void 0) {
|
|
1054
1079
|
url.searchParams.set("max_id", maxId.toString());
|
|
1055
1080
|
}
|
|
@@ -1212,9 +1237,8 @@ function getPromotedPostsQuery(type = "feed") {
|
|
|
1212
1237
|
return reactQuery.queryOptions({
|
|
1213
1238
|
queryKey: ["posts", "promoted", type],
|
|
1214
1239
|
queryFn: async () => {
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1217
|
-
);
|
|
1240
|
+
const baseUrl = exports.ConfigManager.getValidatedBaseUrl();
|
|
1241
|
+
const url = new URL("/private-api/promoted-entries", baseUrl);
|
|
1218
1242
|
if (type === "waves") {
|
|
1219
1243
|
url.searchParams.append("short_content", "1");
|
|
1220
1244
|
}
|
|
@@ -2139,7 +2163,8 @@ function getWavesByTagQueryOptions(host, tag, limit = DEFAULT_TAG_FEED_LIMIT) {
|
|
|
2139
2163
|
initialPageParam: void 0,
|
|
2140
2164
|
queryFn: async ({ signal }) => {
|
|
2141
2165
|
try {
|
|
2142
|
-
const
|
|
2166
|
+
const baseUrl = exports.ConfigManager.getValidatedBaseUrl();
|
|
2167
|
+
const url = new URL("/private-api/waves/tags", baseUrl);
|
|
2143
2168
|
url.searchParams.set("container", host);
|
|
2144
2169
|
url.searchParams.set("tag", tag);
|
|
2145
2170
|
const response = await fetch(url.toString(), {
|
|
@@ -2176,7 +2201,8 @@ function getWavesFollowingQueryOptions(host, username) {
|
|
|
2176
2201
|
return [];
|
|
2177
2202
|
}
|
|
2178
2203
|
try {
|
|
2179
|
-
const
|
|
2204
|
+
const baseUrl = exports.ConfigManager.getValidatedBaseUrl();
|
|
2205
|
+
const url = new URL("/private-api/waves/following", baseUrl);
|
|
2180
2206
|
url.searchParams.set("container", host);
|
|
2181
2207
|
url.searchParams.set("username", normalizedUsername);
|
|
2182
2208
|
const response = await fetch(url.toString(), {
|
|
@@ -2213,7 +2239,8 @@ function getWavesTrendingTagsQueryOptions(host, hours = 24) {
|
|
|
2213
2239
|
queryKey: ["posts", "waves", "trending-tags", host, hours],
|
|
2214
2240
|
queryFn: async ({ signal }) => {
|
|
2215
2241
|
try {
|
|
2216
|
-
const
|
|
2242
|
+
const baseUrl = exports.ConfigManager.getValidatedBaseUrl();
|
|
2243
|
+
const url = new URL("/private-api/waves/trending/tags", baseUrl);
|
|
2217
2244
|
url.searchParams.set("container", host);
|
|
2218
2245
|
url.searchParams.set("hours", hours.toString());
|
|
2219
2246
|
const response = await fetch(url.toString(), {
|
|
@@ -4853,7 +4880,8 @@ async function hsTokenRenew(code) {
|
|
|
4853
4880
|
var ENGINE_RPC_HEADERS = { "Content-type": "application/json" };
|
|
4854
4881
|
async function engineRpc(payload) {
|
|
4855
4882
|
const fetchApi = getBoundFetch();
|
|
4856
|
-
const
|
|
4883
|
+
const baseUrl = exports.ConfigManager.getValidatedBaseUrl();
|
|
4884
|
+
const response = await fetchApi(`${baseUrl}/private-api/engine-api`, {
|
|
4857
4885
|
method: "POST",
|
|
4858
4886
|
body: JSON.stringify(payload),
|
|
4859
4887
|
headers: ENGINE_RPC_HEADERS
|
|
@@ -5058,9 +5086,8 @@ async function getHiveEngineTokensMetadata(tokens) {
|
|
|
5058
5086
|
}
|
|
5059
5087
|
async function getHiveEngineTokenTransactions(username, symbol, limit, offset) {
|
|
5060
5088
|
const fetchApi = getBoundFetch();
|
|
5061
|
-
const
|
|
5062
|
-
|
|
5063
|
-
);
|
|
5089
|
+
const baseUrl = exports.ConfigManager.getValidatedBaseUrl();
|
|
5090
|
+
const url = new URL("/private-api/engine-account-history", baseUrl);
|
|
5064
5091
|
url.searchParams.set("account", username);
|
|
5065
5092
|
url.searchParams.set("symbol", symbol);
|
|
5066
5093
|
url.searchParams.set("limit", limit.toString());
|
|
@@ -5078,7 +5105,8 @@ async function getHiveEngineTokenTransactions(username, symbol, limit, offset) {
|
|
|
5078
5105
|
}
|
|
5079
5106
|
async function getHiveEngineTokenMetrics(symbol, interval = "daily") {
|
|
5080
5107
|
const fetchApi = getBoundFetch();
|
|
5081
|
-
const
|
|
5108
|
+
const baseUrl = exports.ConfigManager.getValidatedBaseUrl();
|
|
5109
|
+
const url = new URL("/private-api/engine-chart-api", baseUrl);
|
|
5082
5110
|
url.searchParams.set("symbol", symbol);
|
|
5083
5111
|
url.searchParams.set("interval", interval);
|
|
5084
5112
|
const response = await fetchApi(url.toString(), {
|
|
@@ -5093,8 +5121,9 @@ async function getHiveEngineTokenMetrics(symbol, interval = "daily") {
|
|
|
5093
5121
|
}
|
|
5094
5122
|
async function getHiveEngineUnclaimedRewards(username) {
|
|
5095
5123
|
const fetchApi = getBoundFetch();
|
|
5124
|
+
const baseUrl = exports.ConfigManager.getValidatedBaseUrl();
|
|
5096
5125
|
const response = await fetchApi(
|
|
5097
|
-
`${
|
|
5126
|
+
`${baseUrl}/private-api/engine-reward-api/${username}?hive=1`
|
|
5098
5127
|
);
|
|
5099
5128
|
if (!response.ok) {
|
|
5100
5129
|
throw new Error(
|