@obolnetwork/obol-sdk 2.12.1 → 2.12.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/README.md CHANGED
@@ -39,11 +39,13 @@ Checkout our [docs](https://docs.obol.org/docs/advanced/quickstart-sdk), [exampl
39
39
  ## Terms and Conditions
40
40
  To use obol-sdk and in order to be able to create a cluster definition or accept an invite to join a cluster, you must accept the [latest Obol terms and conditions](https://obol.org/terms.pdf) by calling acceptObolLatestTermsAndConditions.
41
41
 
42
- ## ⚠️ Important Security Notice:
43
- If you're integrating this SDK with a **backend** (e.g., in Node.js), and you store a private key for executing splitter transactions, handle it with extreme caution. Ensure that:
42
+ ## Security
44
43
 
45
- - The private key is securely stored (e.g., in an `.env` file).
46
- - Never commit or push your `.env` file containing the private key to version control.
44
+ **API host:** `baseUrl` must be one of `https://api.obol.tech`, `https://obol-api-nonprod-dev.dev.obol.tech`, or `https://obol-api-nonprod-qa.dev.obol.tech` (no path suffix). Endpoints are still called as `/v1/...` as before. Any other value throws `InvalidBaseUrlError`.
45
+
46
+ **RPC URLs:** Set `RPC_MAINNET`, `RPC_HOODI`, etc. in your own app or pass an explicit provider/RPC to the client. The SDK does not load a `.env` file on import.
47
+
48
+ **Private keys:** If you use a backend signer, store keys securely (KMS, HSM, or env vars your app loads explicitly). Never commit secrets to version control.
47
49
 
48
50
  ## ⚡️ Integration with Safe Wallet
49
51
 
@@ -98,7 +98,7 @@ import { v4 as uuidv4 } from "uuid";
98
98
  // package.json
99
99
  var package_default = {
100
100
  name: "@obolnetwork/obol-sdk",
101
- version: "2.12.1",
101
+ version: "2.12.2",
102
102
  description: "A package for creating Distributed Validators using the Obol API.",
103
103
  bugs: {
104
104
  url: "https://github.com/obolnetwork/obol-sdk/issues"
@@ -176,7 +176,6 @@ var package_default = {
176
176
  "ajv-formats": "3.0.1",
177
177
  "ajv-keywords": "5.1.0",
178
178
  "cross-fetch": "4.1.0",
179
- dotenv: "17.4.2",
180
179
  elliptic: "6.6.1",
181
180
  ethers: "6.16.0",
182
181
  semver: "7.7.4",
@@ -189,6 +188,7 @@ var package_default = {
189
188
  "@types/node": "24.12.2",
190
189
  "@types/semver": "7.7.1",
191
190
  "@types/uuid": "9.0.8",
191
+ dotenv: "17.4.2",
192
192
  "@typescript-eslint/eslint-plugin": "6.21.0",
193
193
  "@typescript-eslint/parser": "6.21.0",
194
194
  eslint: "8.57.1",
@@ -316,8 +316,6 @@ var MAINNET_SPLIT_V2_FACTORY_BYTECODE = "0x6080604090808252600480361015610015575
316
316
  var HOODI_SPLIT_V2_FACTORY_BYTECODE = "0x6080604090808252600480361015610015575f80fd5b5f3560e01c9182632556fa391461043c5750816380ebf0ab146102be5781639e317f121461027a578163cd6bc1211461023f578163e9889edd1461016d578163f79918b0146100de575063fc6119b11461006d575f80fd5b346100da575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100da576020905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000f9c25250523df26343222fc46de932355b850c97168152f35b5f80fd5b82346100da577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc916080833601126100da5780359267ffffffffffffffff84116100da5760809084360301126100da5761016573ffffffffffffffffffffffffffffffffffffffff916020946101526105e7565b61015a61060a565b91606435930161090f565b915191168152f35b82346100da5760209073ffffffffffffffffffffffffffffffffffffffff6101656101a061019a3661062d565b91610b37565b309061023a7f000000000000000000000000f9c25250523df26343222fc46de932355b850c9790604051916c5af43d3d93803e605757fd5bf36051526044526f593da1005b3d3d3d3d363d3d37363d736030527f9e4ac34f21c619cefc926c8bd93b54bf5a39c7ab2127a895af1cc0691d7e3dff6020527060593d8160093d39f336602c57343d527f5f526071600f20916040525f606052565b610b7a565b82346100da576102546101a061019a3661062d565b803b151573ffffffffffffffffffffffffffffffffffffffff8351921682526020820152f35b82346100da5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100da57602091355f525f8252805f20549051908152f35b82346100da577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc9181833601126100da5780359267ffffffffffffffff84116100da5760809084360301126100da5761016561039c73ffffffffffffffffffffffffffffffffffffffff9261034a6103766103376105e7565b875192839160209a8b84019601866107c7565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101835282610858565b519020805f525f8652845f205490855191878301528682526103978261083c565b6108c2565b848151910120309061023a7f000000000000000000000000f9c25250523df26343222fc46de932355b850c9790604051916c5af43d3d93803e605757fd5bf36051526044526f593da1005b3d3d3d3d363d3d37363d736030527f9e4ac34f21c619cefc926c8bd93b54bf5a39c7ab2127a895af1cc0691d7e3dff6020527060593d8160093d39f336602c57343d527f5f526071600f20916040525f606052565b9083346100da577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc6060813601126100da5782359067ffffffffffffffff82116100da5760809082850192360301126100da576104976105e7565b6105286104a261060a565b6104e4602097888101906104bb8161034a888a866107c7565b519020805f525f8952865f20908154916001830190558751918a8301528982526103978261083c565b73ffffffffffffffffffffffffffffffffffffffff9281898593519101207f000000000000000000000000f9c25250523df26343222fc46de932355b850c97610aae565b1695863b156100da575f858592610569895194859384937fbaa7fda400000000000000000000000000000000000000000000000000000000855284016107c7565b0381838b5af180156105dd57928795927fb3ec24e9259e438f9917b49f27c0dd89a11b7626cb63e6fc977863c0b26a681b95926105ba956105ce575b508188519586956060875260608701906106f5565b93168a85015216868301520390a251908152f35b6105d7906107fb565b8a6105a5565b86513d5f823e3d90fd5b6024359073ffffffffffffffffffffffffffffffffffffffff821682036100da57565b6044359073ffffffffffffffffffffffffffffffffffffffff821682036100da57565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc906060828201126100da576004359167ffffffffffffffff83116100da57826080920301126100da576004019060243573ffffffffffffffffffffffffffffffffffffffff811681036100da579060443590565b90357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1823603018112156100da57016020813591019167ffffffffffffffff82116100da578160051b360383136100da57565b6080820161070382806106a2565b608085529182905260a08401915f905b80821061078f5750505061072a60208301836106a2565b909284830360208601528183527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82116100da5760609160051b8094602085013760408101356040860152013561ffff81168091036100da5760606020940152010190565b90919283359073ffffffffffffffffffffffffffffffffffffffff82168092036100da57600191815260208091019401920190610713565b9073ffffffffffffffffffffffffffffffffffffffff6107f46020929594956040855260408501906106f5565b9416910152565b67ffffffffffffffff811161080f57604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6040810190811067ffffffffffffffff82111761080f57604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761080f57604052565b908151915f5b8381106108af575050015f815290565b806020809284010151818501520161089f565b61090d909291926108e160405194859260208401526040830190610899565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101845283610858565b565b93929161091d838387610b37565b7f000000000000000000000000f9c25250523df26343222fc46de932355b850c976109bb308361023a8490604051916c5af43d3d93803e605757fd5bf36051526044526f593da1005b3d3d3d3d363d3d37363d736030527f9e4ac34f21c619cefc926c8bd93b54bf5a39c7ab2127a895af1cc0691d7e3dff6020527060593d8160093d39f336602c57343d527f5f526071600f20916040525f606052565b803b610aa55750906109cc91610aae565b9473ffffffffffffffffffffffffffffffffffffffff9283871694853b156100da57604051947fbaa7fda40000000000000000000000000000000000000000000000000000000086525f8680610a268688600484016107c7565b0381838b5af1948515610a9a577fc4cec5a1846f5c98dc275670618bfecffec4da2e7cba63760ef46f38c75d236e96610a7496610a8b575b50816040519687966080885260808801906106f5565b9416602086015216604084015260608301520390a2565b610a94906107fb565b5f610a5e565b6040513d5f823e3d90fd5b96505050505050565b9190604051926c5af43d3d93803e605757fd5bf36051526044526f593da1005b3d3d3d3d363d3d37363d736030527f9e4ac34f21c619cefc926c8bd93b54bf5a39c7ab2127a895af1cc0691d7e3dff6020527060593d8160093d39f336602c57343d527f5f526071600f5ff5916040525f6060528115610b2a57565b63301164255f526004601cfd5b6040519291610b4f9184916108e191602084016107c7565b610b7460206040518093610b668383018097610899565b908152038084520182610858565b51902090565b91909160ff5f5360355260601b60015260155260555f20905f60355256fea2646970667358221220edd55753c55f257991df670fc562cdf54adb62d710125933fc4a0a7afddbc02564736f6c63430008170033";
317
317
 
318
318
  // src/constants.ts
319
- import * as dotenv from "dotenv";
320
- dotenv.config();
321
319
  var CONFLICT_ERROR_MSG = "Conflict";
322
320
  var EIP712_DOMAIN_NAME = "Obol";
323
321
  var EIP712_DOMAIN_VERSION = "1";
@@ -526,40 +524,6 @@ var CAPELLA_FORK_MAPPING = {
526
524
  // Hoodi
527
525
  };
528
526
 
529
- // src/base.ts
530
- var Base = class {
531
- constructor({
532
- baseUrl = DEFAULT_BASE_URL,
533
- chainId = DEFAULT_CHAIN_ID
534
- }) {
535
- this.baseUrl = baseUrl;
536
- this.chainId = chainId;
537
- this.fork_version = FORK_MAPPING[this.chainId];
538
- }
539
- request(endpoint, options) {
540
- return __async(this, null, function* () {
541
- const url = `${this.baseUrl}${endpoint}`;
542
- const config2 = __spreadProps(__spreadValues({}, options), {
543
- headers: __spreadValues({
544
- "Content-Type": "application/json",
545
- "User-Agent": `Obol-SDK/${SDK_VERSION}`
546
- }, options == null ? void 0 : options.headers)
547
- });
548
- try {
549
- const response = yield fetch(url, config2);
550
- if (response.ok) {
551
- return yield response.json();
552
- } else {
553
- const errorResponse = yield response.json();
554
- throw errorResponse;
555
- }
556
- } catch (e) {
557
- throw e;
558
- }
559
- });
560
- }
561
- };
562
-
563
527
  // src/errors.ts
564
528
  var ConflictError = class _ConflictError extends Error {
565
529
  constructor() {
@@ -582,6 +546,13 @@ var UnsupportedChainError = class _UnsupportedChainError extends Error {
582
546
  Object.setPrototypeOf(this, _UnsupportedChainError.prototype);
583
547
  }
584
548
  };
549
+ var InvalidBaseUrlError = class _InvalidBaseUrlError extends Error {
550
+ constructor(message2) {
551
+ super(message2);
552
+ this.name = "InvalidBaseUrlError";
553
+ Object.setPrototypeOf(this, _InvalidBaseUrlError.prototype);
554
+ }
555
+ };
585
556
  var ClusterLockValidationTimeoutError = class _ClusterLockValidationTimeoutError extends Error {
586
557
  /**
587
558
  * @param timeoutMs - Same value as SDK whole-lock validation worker timeout.
@@ -596,6 +567,58 @@ var ClusterLockValidationTimeoutError = class _ClusterLockValidationTimeoutError
596
567
  }
597
568
  };
598
569
 
570
+ // src/base.ts
571
+ var ALLOWED_OBOL_API_BASE_URLS = [
572
+ DEFAULT_BASE_URL,
573
+ "https://obol-api-nonprod-dev.dev.obol.tech",
574
+ "https://obol-api-nonprod-qa.dev.obol.tech"
575
+ ];
576
+ var ALLOWED_BASE_URLS = new Set(ALLOWED_OBOL_API_BASE_URLS);
577
+ function assertAllowedBaseUrl(baseUrl) {
578
+ let candidate = baseUrl.trim();
579
+ while (candidate.endsWith("/")) {
580
+ candidate = candidate.slice(0, -1);
581
+ }
582
+ if (!ALLOWED_BASE_URLS.has(candidate)) {
583
+ throw new InvalidBaseUrlError(
584
+ `baseUrl must be one of: ${ALLOWED_OBOL_API_BASE_URLS.join(", ")}`
585
+ );
586
+ }
587
+ return candidate;
588
+ }
589
+ var Base = class {
590
+ constructor({
591
+ baseUrl = DEFAULT_BASE_URL,
592
+ chainId = DEFAULT_CHAIN_ID
593
+ }) {
594
+ this.baseUrl = assertAllowedBaseUrl(baseUrl);
595
+ this.chainId = chainId;
596
+ this.fork_version = FORK_MAPPING[this.chainId];
597
+ }
598
+ request(endpoint, options) {
599
+ return __async(this, null, function* () {
600
+ const url = `${this.baseUrl}${endpoint}`;
601
+ const config = __spreadProps(__spreadValues({}, options), {
602
+ headers: __spreadValues({
603
+ "Content-Type": "application/json",
604
+ "User-Agent": `Obol-SDK/${SDK_VERSION}`
605
+ }, options == null ? void 0 : options.headers)
606
+ });
607
+ try {
608
+ const response = yield fetch(url, config);
609
+ if (response.ok) {
610
+ return yield response.json();
611
+ } else {
612
+ const errorResponse = yield response.json();
613
+ throw errorResponse;
614
+ }
615
+ } catch (e) {
616
+ throw e;
617
+ }
618
+ });
619
+ }
620
+ };
621
+
599
622
  // src/verification/common.ts
600
623
  import { fromHexString as fromHexString6 } from "@chainsafe/ssz";
601
624
  import elliptic from "elliptic";
@@ -5532,15 +5555,7 @@ function validateClusterLockInWorker(lock, safeRpcUrl) {
5532
5555
  const worker = new wt.Worker(workerFile, {
5533
5556
  workerData: { lock, safeRpcUrl }
5534
5557
  });
5535
- let timer;
5536
- const finish = (result) => {
5537
- if (settled) return;
5538
- settled = true;
5539
- clearTimeout(timer);
5540
- worker.terminate();
5541
- resolve(result);
5542
- };
5543
- timer = setTimeout(() => {
5558
+ const timer = setTimeout(() => {
5544
5559
  if (settled) return;
5545
5560
  settled = true;
5546
5561
  clearTimeout(timer);
@@ -5549,6 +5564,13 @@ function validateClusterLockInWorker(lock, safeRpcUrl) {
5549
5564
  new ClusterLockValidationTimeoutError(VALIDATION_WORKER_TIMEOUT_MS)
5550
5565
  );
5551
5566
  }, VALIDATION_WORKER_TIMEOUT_MS);
5567
+ const finish = (result) => {
5568
+ if (settled) return;
5569
+ settled = true;
5570
+ clearTimeout(timer);
5571
+ worker.terminate();
5572
+ resolve(result);
5573
+ };
5552
5574
  worker.once("message", (msg) => {
5553
5575
  finish(msg === true);
5554
5576
  });
@@ -19532,11 +19554,11 @@ var encodeCreateSplitV2DeterministicTxData = (splitParams, splitOwnerAddress, sa
19532
19554
  );
19533
19555
  };
19534
19556
  var getChainConfig = (chainId) => {
19535
- const config2 = CHAIN_CONFIGURATION[chainId];
19536
- if (!config2) {
19557
+ const config = CHAIN_CONFIGURATION[chainId];
19558
+ if (!config) {
19537
19559
  throw new Error(`Chain configuration not found for chain ID ${chainId}`);
19538
19560
  }
19539
- return config2;
19561
+ return config;
19540
19562
  };
19541
19563
  var requestWithdrawalFromOVM = (_0) => __async(null, [_0], function* ({
19542
19564
  ovmAddress,
@@ -21132,6 +21154,7 @@ var Client = class extends Base {
21132
21154
  *
21133
21155
  * @param config - Client configuration object.
21134
21156
  * @param config.baseUrl - Obol API base URL. Defaults to `https://api.obol.tech`.
21157
+ * Must match one of {@link ALLOWED_OBOL_API_BASE_URLS} (API paths use `/v1/...` separately).
21135
21158
  * @param config.chainId - Target chain ID. Defaults to `560048` (Hoodi).
21136
21159
  * Supported: 1 (Mainnet), 560048 (Hoodi), 100 (Gnosis), 11155111 (Sepolia).
21137
21160
  * @param signer - An ethers `Wallet` or `JsonRpcSigner`. Required for any
@@ -21149,8 +21172,8 @@ var Client = class extends Base {
21149
21172
  * const client = new Client({ chainId: 560048 }, signer);
21150
21173
  * ```
21151
21174
  */
21152
- constructor(config2, signer, provider) {
21153
- super(config2);
21175
+ constructor(config, signer, provider) {
21176
+ super(config);
21154
21177
  this.signer = signer;
21155
21178
  this.provider = provider != null ? provider : signer && "provider" in signer ? signer.provider : void 0;
21156
21179
  this.incentives = new Incentives(
@@ -21712,6 +21735,7 @@ var Client = class extends Base {
21712
21735
  }
21713
21736
  };
21714
21737
  export {
21738
+ ALLOWED_OBOL_API_BASE_URLS,
21715
21739
  AVAILABLE_SPLITTER_CHAINS,
21716
21740
  CAPELLA_FORK_MAPPING,
21717
21741
  CHAIN_CONFIGURATION,
@@ -21744,6 +21768,7 @@ export {
21744
21768
  FORK_NAMES,
21745
21769
  GENESIS_VALIDATOR_ROOT,
21746
21770
  Incentives,
21771
+ InvalidBaseUrlError,
21747
21772
  OBOL_SDK_EMAIL,
21748
21773
  ObolSplits,
21749
21774
  OperatorConfigHashSigningTypes,