@secondlayer/sdk 14.1.0 → 14.3.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/AGENTS.md +6 -0
- package/README.md +5 -1
- package/dist/index.d.ts +53 -7
- package/dist/index.js +31 -6
- package/dist/index.js.map +5 -5
- package/dist/streams/index.js +13 -6
- package/dist/streams/index.js.map +4 -4
- package/dist/subgraphs/index.d.ts +43 -2
- package/dist/subgraphs/index.js +30 -6
- package/dist/subgraphs/index.js.map +5 -5
- package/package.json +3 -3
package/dist/streams/index.js
CHANGED
|
@@ -211,13 +211,20 @@ function resolveBaseUrl(explicit) {
|
|
|
211
211
|
}
|
|
212
212
|
return LOCAL_API_URL;
|
|
213
213
|
}
|
|
214
|
-
function
|
|
214
|
+
function isHostedApiUrl(url) {
|
|
215
|
+
try {
|
|
216
|
+
return new URL(url).hostname === "api.secondlayer.tools";
|
|
217
|
+
} catch {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function resolveApiKey(apiKey, baseUrl) {
|
|
215
222
|
if (apiKey !== undefined)
|
|
216
223
|
return apiKey;
|
|
217
224
|
if (typeof process === "undefined")
|
|
218
225
|
return;
|
|
219
|
-
const
|
|
220
|
-
return
|
|
226
|
+
const name = baseUrl !== undefined && isHostedApiUrl(baseUrl) ? ACCOUNT_KEY_ENV : INSTANCE_TOKEN_ENV;
|
|
227
|
+
return process.env?.[name] || undefined;
|
|
221
228
|
}
|
|
222
229
|
function resolveAccountKey(accountKey) {
|
|
223
230
|
if (accountKey !== undefined)
|
|
@@ -275,7 +282,7 @@ class BaseClient {
|
|
|
275
282
|
etagCache;
|
|
276
283
|
constructor(options = {}) {
|
|
277
284
|
this.baseUrl = resolveBaseUrl(options.baseUrl);
|
|
278
|
-
this.apiKey = resolveApiKey(options.apiKey);
|
|
285
|
+
this.apiKey = resolveApiKey(options.apiKey, this.baseUrl);
|
|
279
286
|
this.origin = options.origin ?? "cli";
|
|
280
287
|
this.requestTimeoutMs = options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
281
288
|
this.fetchImpl = options.fetchImpl ?? ((...args) => fetch(...args));
|
|
@@ -1237,7 +1244,7 @@ function isLoopbackUrl(baseUrl) {
|
|
|
1237
1244
|
}
|
|
1238
1245
|
function createStreamsClient(options) {
|
|
1239
1246
|
const baseUrl = normalizeBaseUrl(resolveBaseUrl(options.baseUrl));
|
|
1240
|
-
const apiKey = resolveApiKey(options.apiKey);
|
|
1247
|
+
const apiKey = resolveApiKey(options.apiKey, baseUrl);
|
|
1241
1248
|
const origin = options.origin ?? "cli";
|
|
1242
1249
|
const authHeaders = () => ({
|
|
1243
1250
|
"x-sl-origin": origin,
|
|
@@ -1603,5 +1610,5 @@ export {
|
|
|
1603
1610
|
isStxTransfer
|
|
1604
1611
|
};
|
|
1605
1612
|
|
|
1606
|
-
//# debugId=
|
|
1613
|
+
//# debugId=B1CA7FDD739B36F364756E2164756E21
|
|
1607
1614
|
//# sourceMappingURL=index.js.map
|