ton-provider-system 0.2.1 → 0.2.2
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/index.cjs +33 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +33 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/rpc.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1912,7 +1912,10 @@ declare class TatumProvider extends BaseProvider {
|
|
|
1912
1912
|
* Documentation: https://documentation.onfinality.io/support/ton
|
|
1913
1913
|
*
|
|
1914
1914
|
* Endpoint format: https://ton-{network}.api.onfinality.io/public or /rpc
|
|
1915
|
-
* API key:
|
|
1915
|
+
* API key: Required for /rpc endpoint, passed as query parameter ?apikey=YOUR_API_KEY
|
|
1916
|
+
*
|
|
1917
|
+
* IMPORTANT: OnFinality uses query parameters for API key authentication, NOT headers.
|
|
1918
|
+
* The API key must be included in the URL as ?apikey=YOUR_API_KEY
|
|
1916
1919
|
*/
|
|
1917
1920
|
|
|
1918
1921
|
declare class OnFinalityProvider extends BaseProvider {
|
package/dist/index.d.ts
CHANGED
|
@@ -1912,7 +1912,10 @@ declare class TatumProvider extends BaseProvider {
|
|
|
1912
1912
|
* Documentation: https://documentation.onfinality.io/support/ton
|
|
1913
1913
|
*
|
|
1914
1914
|
* Endpoint format: https://ton-{network}.api.onfinality.io/public or /rpc
|
|
1915
|
-
* API key:
|
|
1915
|
+
* API key: Required for /rpc endpoint, passed as query parameter ?apikey=YOUR_API_KEY
|
|
1916
|
+
*
|
|
1917
|
+
* IMPORTANT: OnFinality uses query parameters for API key authentication, NOT headers.
|
|
1918
|
+
* The API key must be included in the URL as ?apikey=YOUR_API_KEY
|
|
1916
1919
|
*/
|
|
1917
1920
|
|
|
1918
1921
|
declare class OnFinalityProvider extends BaseProvider {
|
package/dist/index.js
CHANGED
|
@@ -750,17 +750,43 @@ var OnFinalityProvider = class extends BaseProvider {
|
|
|
750
750
|
if (normalized.includes("onfinality.io")) {
|
|
751
751
|
try {
|
|
752
752
|
const url = new URL(normalized);
|
|
753
|
-
const
|
|
753
|
+
const hasQueryParams = normalized.includes("?");
|
|
754
|
+
const queryString = hasQueryParams ? normalized.split("?")[1] : "";
|
|
755
|
+
const hasApiKeyInQuery = queryString.includes("apikey=");
|
|
754
756
|
if (!url.pathname || url.pathname === "/") {
|
|
755
757
|
if (this.provider.apiKey) {
|
|
756
|
-
|
|
758
|
+
const baseUrl2 = normalized.split("?")[0];
|
|
759
|
+
if (hasApiKeyInQuery) {
|
|
760
|
+
return normalized.replace(/\/?$/, "/rpc");
|
|
761
|
+
}
|
|
762
|
+
if (hasQueryParams) {
|
|
763
|
+
return `${baseUrl2.replace(/\/?$/, "/rpc")}?${queryString}&apikey=${encodeURIComponent(this.provider.apiKey)}`;
|
|
764
|
+
}
|
|
765
|
+
return `${baseUrl2.replace(/\/?$/, "/rpc")}?apikey=${encodeURIComponent(this.provider.apiKey)}`;
|
|
757
766
|
}
|
|
767
|
+
const baseUrl = normalized.split("?")[0];
|
|
758
768
|
return baseUrl.replace(/\/?$/, "/public");
|
|
759
769
|
}
|
|
760
770
|
if (url.pathname === "/rpc" || url.pathname === "/public") {
|
|
761
|
-
|
|
771
|
+
if (url.pathname === "/rpc") {
|
|
772
|
+
if (hasApiKeyInQuery) {
|
|
773
|
+
return normalized;
|
|
774
|
+
}
|
|
775
|
+
if (this.provider.apiKey) {
|
|
776
|
+
const baseUrl = normalized.split("?")[0];
|
|
777
|
+
if (hasQueryParams) {
|
|
778
|
+
return `${baseUrl}?${queryString}&apikey=${encodeURIComponent(this.provider.apiKey)}`;
|
|
779
|
+
}
|
|
780
|
+
return `${baseUrl}?apikey=${encodeURIComponent(this.provider.apiKey)}`;
|
|
781
|
+
}
|
|
782
|
+
return normalized;
|
|
783
|
+
}
|
|
784
|
+
if (url.pathname === "/public") {
|
|
785
|
+
return normalized.split("?")[0];
|
|
786
|
+
}
|
|
787
|
+
return normalized;
|
|
762
788
|
}
|
|
763
|
-
return
|
|
789
|
+
return normalized;
|
|
764
790
|
} catch {
|
|
765
791
|
if (normalized.includes("{key}")) {
|
|
766
792
|
return normalized.split("?")[0].replace(/\/?$/, "/public");
|
|
@@ -768,7 +794,7 @@ var OnFinalityProvider = class extends BaseProvider {
|
|
|
768
794
|
if (!normalized.includes("/rpc") && !normalized.includes("/public")) {
|
|
769
795
|
return normalized.split("?")[0] + "/public";
|
|
770
796
|
}
|
|
771
|
-
return normalized
|
|
797
|
+
return normalized;
|
|
772
798
|
}
|
|
773
799
|
}
|
|
774
800
|
return normalized;
|
|
@@ -777,9 +803,6 @@ var OnFinalityProvider = class extends BaseProvider {
|
|
|
777
803
|
const headers = {
|
|
778
804
|
"Content-Type": "application/json"
|
|
779
805
|
};
|
|
780
|
-
if (this.provider.apiKey) {
|
|
781
|
-
headers["apikey"] = this.provider.apiKey;
|
|
782
|
-
}
|
|
783
806
|
return headers;
|
|
784
807
|
}
|
|
785
808
|
parseResponse(data) {
|
|
@@ -1083,7 +1106,8 @@ var HealthChecker = class {
|
|
|
1083
1106
|
} catch (error) {
|
|
1084
1107
|
if (provider.type === "onfinality" && normalizedEndpoint.includes("/rpc") && provider.apiKey && error.message?.includes("backend error")) {
|
|
1085
1108
|
this.logger.debug(`OnFinality /rpc failed, retrying with /public endpoint`);
|
|
1086
|
-
const
|
|
1109
|
+
const baseUrl = normalizedEndpoint.split("?")[0];
|
|
1110
|
+
const publicEndpoint = baseUrl.replace("/rpc", "/public");
|
|
1087
1111
|
const publicProvider = { ...provider, apiKey: void 0 };
|
|
1088
1112
|
const publicProviderImpl = createProvider(publicProvider);
|
|
1089
1113
|
info = await this.callGetMasterchainInfo(publicEndpoint, publicProvider, publicProviderImpl);
|