@orbinum/sdk 0.10.0 → 0.11.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/dist/index.js CHANGED
@@ -1150,11 +1150,27 @@ var EvmExplorer = class _EvmExplorer {
1150
1150
  };
1151
1151
 
1152
1152
  // src/indexer/IndexerClient.ts
1153
+ var LOCAL_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]", "::1"]);
1154
+ function normalizeBaseUrl(baseUrl) {
1155
+ let url;
1156
+ try {
1157
+ url = new URL(baseUrl);
1158
+ } catch {
1159
+ throw new Error(`IndexerClient: invalid baseUrl ${JSON.stringify(baseUrl)}`);
1160
+ }
1161
+ const isLocal = LOCAL_HOSTS.has(url.hostname);
1162
+ if (url.protocol !== "https:" && !(url.protocol === "http:" && isLocal)) {
1163
+ throw new Error(
1164
+ `IndexerClient: baseUrl must use https:// (got ${url.protocol}//${url.hostname}). Plain http is only allowed for localhost.`
1165
+ );
1166
+ }
1167
+ return baseUrl.replace(/\/$/, "");
1168
+ }
1153
1169
  var IndexerClient = class _IndexerClient {
1154
1170
  baseUrl;
1155
1171
  timeoutMs;
1156
1172
  constructor(config) {
1157
- this.baseUrl = config.baseUrl.replace(/\/$/, "");
1173
+ this.baseUrl = normalizeBaseUrl(config.baseUrl);
1158
1174
  this.timeoutMs = config.timeoutMs ?? 1e4;
1159
1175
  }
1160
1176
  // ─── Internal helpers ──────────────────────────────────────────────────────
package/dist/index.mjs CHANGED
@@ -1020,11 +1020,27 @@ var EvmExplorer = class _EvmExplorer {
1020
1020
  };
1021
1021
 
1022
1022
  // src/indexer/IndexerClient.ts
1023
+ var LOCAL_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]", "::1"]);
1024
+ function normalizeBaseUrl(baseUrl) {
1025
+ let url;
1026
+ try {
1027
+ url = new URL(baseUrl);
1028
+ } catch {
1029
+ throw new Error(`IndexerClient: invalid baseUrl ${JSON.stringify(baseUrl)}`);
1030
+ }
1031
+ const isLocal = LOCAL_HOSTS.has(url.hostname);
1032
+ if (url.protocol !== "https:" && !(url.protocol === "http:" && isLocal)) {
1033
+ throw new Error(
1034
+ `IndexerClient: baseUrl must use https:// (got ${url.protocol}//${url.hostname}). Plain http is only allowed for localhost.`
1035
+ );
1036
+ }
1037
+ return baseUrl.replace(/\/$/, "");
1038
+ }
1023
1039
  var IndexerClient = class _IndexerClient {
1024
1040
  baseUrl;
1025
1041
  timeoutMs;
1026
1042
  constructor(config) {
1027
- this.baseUrl = config.baseUrl.replace(/\/$/, "");
1043
+ this.baseUrl = normalizeBaseUrl(config.baseUrl);
1028
1044
  this.timeoutMs = config.timeoutMs ?? 1e4;
1029
1045
  }
1030
1046
  // ─── Internal helpers ──────────────────────────────────────────────────────
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbinum/sdk",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Official TypeScript SDK for Orbinum.",
5
5
  "author": "Orbinum",
6
6
  "license": "MIT",