@hsuite/smart-engines-sdk 3.7.0 → 3.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
@@ -6609,7 +6609,7 @@ var SdkHttpError = class extends Error {
6609
6609
  };
6610
6610
  function createHttpClient(config) {
6611
6611
  const timeout = config.timeout ?? 3e4;
6612
- function getHeaders(contentType) {
6612
+ function getHeaders(contentType, opts) {
6613
6613
  const headers = {};
6614
6614
  if (contentType) {
6615
6615
  headers["Content-Type"] = contentType;
@@ -6620,6 +6620,12 @@ function createHttpClient(config) {
6620
6620
  if (config.apiKey) {
6621
6621
  headers["X-API-Key"] = config.apiKey;
6622
6622
  }
6623
+ if (opts?.customerToken) {
6624
+ headers["X-Customer-Session-Token"] = opts.customerToken;
6625
+ }
6626
+ if (opts?.headers) {
6627
+ Object.assign(headers, opts.headers);
6628
+ }
6623
6629
  return headers;
6624
6630
  }
6625
6631
  function setAuthToken(token) {
@@ -6628,14 +6634,14 @@ function createHttpClient(config) {
6628
6634
  function getAuthToken() {
6629
6635
  return config.authToken;
6630
6636
  }
6631
- async function request(method, path, body) {
6637
+ async function request(method, path, body, opts) {
6632
6638
  const url = `${config.baseUrl}${path}`;
6633
6639
  const controller = new AbortController();
6634
6640
  const timeoutId = setTimeout(() => controller.abort(), timeout);
6635
6641
  try {
6636
6642
  const init = {
6637
6643
  method,
6638
- headers: getHeaders("application/json"),
6644
+ headers: getHeaders("application/json", opts),
6639
6645
  signal: controller.signal
6640
6646
  };
6641
6647
  if (body !== void 0) {
@@ -6664,14 +6670,14 @@ function createHttpClient(config) {
6664
6670
  throw new SdkHttpError(`Network error: ${err.message}`, 0, error);
6665
6671
  }
6666
6672
  }
6667
- async function getText(path) {
6673
+ async function getText(path, opts) {
6668
6674
  const url = `${config.baseUrl}${path}`;
6669
6675
  const controller = new AbortController();
6670
6676
  const timeoutId = setTimeout(() => controller.abort(), timeout);
6671
6677
  try {
6672
6678
  const response = await fetch(url, {
6673
6679
  method: "GET",
6674
- headers: getHeaders(),
6680
+ headers: getHeaders(void 0, opts),
6675
6681
  signal: controller.signal
6676
6682
  });
6677
6683
  clearTimeout(timeoutId);
@@ -6694,7 +6700,37 @@ function createHttpClient(config) {
6694
6700
  throw new SdkHttpError(`Network error: ${err.message}`, 0, error);
6695
6701
  }
6696
6702
  }
6697
- async function upload(path, file, filename, metadata, fieldName = "file") {
6703
+ async function getBinary(path, opts) {
6704
+ const url = `${config.baseUrl}${path}`;
6705
+ const controller = new AbortController();
6706
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
6707
+ try {
6708
+ const response = await fetch(url, {
6709
+ method: "GET",
6710
+ headers: getHeaders(void 0, opts),
6711
+ signal: controller.signal
6712
+ });
6713
+ clearTimeout(timeoutId);
6714
+ if (!response.ok) {
6715
+ const errBody = await response.json().catch(() => ({}));
6716
+ throw new SdkHttpError(
6717
+ errBody.message || `API error: ${response.status} ${response.statusText}`,
6718
+ response.status,
6719
+ errBody
6720
+ );
6721
+ }
6722
+ return new Uint8Array(await response.arrayBuffer());
6723
+ } catch (error) {
6724
+ clearTimeout(timeoutId);
6725
+ if (error instanceof SdkHttpError) throw error;
6726
+ const err = error;
6727
+ if (err.name === "AbortError") {
6728
+ throw new SdkHttpError("Request timeout", 408);
6729
+ }
6730
+ throw new SdkHttpError(`Network error: ${err.message}`, 0, error);
6731
+ }
6732
+ }
6733
+ async function upload(path, file, filename, metadata, fieldName = "file", opts) {
6698
6734
  const url = `${config.baseUrl}${path}`;
6699
6735
  const controller = new AbortController();
6700
6736
  const timeoutId = setTimeout(() => controller.abort(), timeout * 2);
@@ -6714,6 +6750,12 @@ function createHttpClient(config) {
6714
6750
  if (config.apiKey) {
6715
6751
  headers["X-API-Key"] = config.apiKey;
6716
6752
  }
6753
+ if (opts?.customerToken) {
6754
+ headers["X-Customer-Session-Token"] = opts.customerToken;
6755
+ }
6756
+ if (opts?.headers) {
6757
+ Object.assign(headers, opts.headers);
6758
+ }
6717
6759
  const response = await fetch(url, {
6718
6760
  method: "POST",
6719
6761
  headers,
@@ -6745,7 +6787,7 @@ function createHttpClient(config) {
6745
6787
  try {
6746
6788
  return await op();
6747
6789
  } catch (error) {
6748
- const refreshable = !!config.onUnauthorized && !path.startsWith("/api/auth/") && error instanceof SdkHttpError && error.statusCode === 401;
6790
+ const refreshable = !!config.onUnauthorized && !path.startsWith("/api/v3/baas/auth/") && !path.startsWith("/api/v3/auth/") && error instanceof SdkHttpError && error.statusCode === 401;
6749
6791
  if (!refreshable) throw error;
6750
6792
  if (!reauthInFlight) {
6751
6793
  reauthInFlight = Promise.resolve(config.onUnauthorized()).finally(() => {
@@ -6761,13 +6803,14 @@ function createHttpClient(config) {
6761
6803
  }
6762
6804
  }
6763
6805
  const client = {
6764
- post: (path, body) => withAuthRetry(path, () => request("POST", path, body)),
6765
- get: (path) => withAuthRetry(path, () => request("GET", path)),
6766
- put: (path, body) => withAuthRetry(path, () => request("PUT", path, body)),
6767
- patch: (path, body) => withAuthRetry(path, () => request("PATCH", path, body)),
6768
- delete: (path) => withAuthRetry(path, () => request("DELETE", path)),
6769
- getText: (path) => withAuthRetry(path, () => getText(path)),
6770
- upload: ((path, file, filename, metadata, fieldName) => withAuthRetry(path, () => upload(path, file, filename, metadata, fieldName))),
6806
+ post: (path, body, opts) => withAuthRetry(path, () => request("POST", path, body, opts)),
6807
+ get: (path, opts) => withAuthRetry(path, () => request("GET", path, void 0, opts)),
6808
+ put: (path, body, opts) => withAuthRetry(path, () => request("PUT", path, body, opts)),
6809
+ patch: (path, body, opts) => withAuthRetry(path, () => request("PATCH", path, body, opts)),
6810
+ delete: (path, opts) => withAuthRetry(path, () => request("DELETE", path, void 0, opts)),
6811
+ getText: (path, opts) => withAuthRetry(path, () => getText(path, opts)),
6812
+ getBinary: (path, opts) => withAuthRetry(path, () => getBinary(path, opts)),
6813
+ upload: ((path, file, filename, metadata, fieldName, opts) => withAuthRetry(path, () => upload(path, file, filename, metadata, fieldName, opts))),
6771
6814
  setAuthToken,
6772
6815
  getAuthToken
6773
6816
  };
@@ -7729,7 +7772,7 @@ var HederaTransactionsClient = class {
7729
7772
  * - `client.hedera.tss.createTopic(...)` makes the cluster sign+submit in one call.
7730
7773
  *
7731
7774
  * `tssHttp` is the validator's `/api/v3`-rooted HTTP client (different from
7732
- * the `/api/transactions` one this class uses for prepare paths). Both
7775
+ * the `/api/v3/transactions` one this class uses for prepare paths). Both
7733
7776
  * clients are required — the previous single-arg fallback to `http` was
7734
7777
  * unreachable through `SmartEngineClient` (the only call site always
7735
7778
  * passes both).
@@ -8530,77 +8573,85 @@ var AgentsClient = class {
8530
8573
  }
8531
8574
  http;
8532
8575
  /** Register a new agent */
8533
- async register(request) {
8534
- return this.http.post("/api/agents/register", request);
8576
+ async register(request, opts) {
8577
+ return this.http.post("/api/v3/baas/agents/register", request, opts);
8535
8578
  }
8536
8579
  /** Get agent details */
8537
- async get(agentId) {
8538
- return this.http.get(`/api/agents/${encodePathParam(agentId)}`);
8580
+ async get(agentId, opts) {
8581
+ return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}`, opts);
8539
8582
  }
8540
8583
  /** List all agents */
8541
- async list() {
8542
- return this.http.get("/api/agents");
8584
+ async list(opts) {
8585
+ return this.http.get("/api/v3/baas/agents", opts);
8543
8586
  }
8544
8587
  /**
8545
8588
  * Fund agent treasury (owner-only). Returns a
8546
8589
  * `PreparedTransactionResponse` wrapped in a `success: true` envelope —
8547
8590
  * the caller is expected to sign and submit the prepared bytes.
8548
8591
  */
8549
- async fund(agentId, request) {
8550
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/fund`, request);
8592
+ async fund(agentId, request, opts) {
8593
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/fund`, request, opts);
8551
8594
  }
8552
8595
  /**
8553
8596
  * Execute a trade (agent-wallet OR owner). Returns a
8554
8597
  * `PreparedTransactionResponse` wrapped in a `success: true` envelope.
8555
8598
  */
8556
- async trade(agentId, request) {
8557
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/trade`, request);
8599
+ async trade(agentId, request, opts) {
8600
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/trade`, request, opts);
8558
8601
  }
8559
8602
  /**
8560
8603
  * Withdraw from agent treasury (owner-only). Returns a
8561
8604
  * `PreparedTransactionResponse` wrapped in a `success: true` envelope.
8562
8605
  */
8563
- async withdraw(agentId, request) {
8564
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/withdraw`, request);
8606
+ async withdraw(agentId, request, opts) {
8607
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/withdraw`, request, opts);
8608
+ }
8609
+ /**
8610
+ * Execute a generic, declared capability (agent-wallet OR owner). The
8611
+ * chain-agnostic general form of an agent action: the capability may settle
8612
+ * on-chain, act off-chain, or both. Returns the ordered step results.
8613
+ */
8614
+ async execute(agentId, request, opts) {
8615
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/execute`, request, opts);
8565
8616
  }
8566
8617
  /** Pause an agent */
8567
- async pause(agentId) {
8568
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/pause`, {});
8618
+ async pause(agentId, opts) {
8619
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/pause`, {}, opts);
8569
8620
  }
8570
8621
  /** Resume a paused agent */
8571
- async resume(agentId) {
8572
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/resume`, {});
8622
+ async resume(agentId, opts) {
8623
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/resume`, {}, opts);
8573
8624
  }
8574
8625
  /** Revoke an agent (permanent) */
8575
- async revoke(agentId) {
8576
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/revoke`, {});
8626
+ async revoke(agentId, opts) {
8627
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/revoke`, {}, opts);
8577
8628
  }
8578
8629
  /**
8579
8630
  * Update agent rules.
8580
8631
  *
8581
- * Server route is PATCH `/api/agents/:agentId/rules`
8632
+ * Server route is PATCH `/api/v3/baas/agents/:agentId/rules`
8582
8633
  * (`agents.controller.ts:375`). The previous PUT variant 404'd because
8583
8634
  * Nest matched the dynamic `:agentId` GET/POST handlers and rejected
8584
8635
  * the verb mismatch.
8585
8636
  */
8586
- async updateRules(agentId, rules) {
8587
- return this.http.patch(`/api/agents/${encodePathParam(agentId)}/rules`, rules);
8637
+ async updateRules(agentId, rules, opts) {
8638
+ return this.http.patch(`/api/v3/baas/agents/${encodePathParam(agentId)}/rules`, rules, opts);
8588
8639
  }
8589
8640
  /** Get agent events */
8590
- async getEvents(agentId) {
8591
- return this.http.get(`/api/agents/${encodePathParam(agentId)}/events`);
8641
+ async getEvents(agentId, opts) {
8642
+ return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}/events`, opts);
8592
8643
  }
8593
8644
  /** Get agent balances across chains */
8594
- async getBalances(agentId) {
8595
- return this.http.get(`/api/agents/${encodePathParam(agentId)}/balances`);
8645
+ async getBalances(agentId, opts) {
8646
+ return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}/balances`, opts);
8596
8647
  }
8597
8648
  /** Approve a pending agent operation */
8598
- async approve(agentId, operationId) {
8599
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/approve/${encodePathParam(operationId)}`, {});
8649
+ async approve(agentId, operationId, opts) {
8650
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/approve/${encodePathParam(operationId)}`, {}, opts);
8600
8651
  }
8601
8652
  /** Reject a pending agent operation */
8602
- async reject(agentId, operationId) {
8603
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/reject/${encodePathParam(operationId)}`, {});
8653
+ async reject(agentId, operationId, opts) {
8654
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/reject/${encodePathParam(operationId)}`, {}, opts);
8604
8655
  }
8605
8656
  };
8606
8657
 
@@ -8628,7 +8679,56 @@ var DeploymentClient = class {
8628
8679
  * {@link deploy} with the pushed image tag.
8629
8680
  */
8630
8681
  async init(request) {
8631
- return this.http.post("/api/deployment/apps/init", request);
8682
+ return this.http.post("/api/v3/baas/deployment/apps/init", request);
8683
+ }
8684
+ /**
8685
+ * Issue ephemeral Harbor push credentials for a smart-app that ALREADY
8686
+ * EXISTS — the MINT-FIRST / DEPLOY-LAST credentials-push call.
8687
+ *
8688
+ * Unlike {@link init} (which historically allocated a fresh entity), this
8689
+ * takes the developer's pre-existing `appId` — the `SUBSCRIPTION_APP_ID`
8690
+ * minted by `hsuite subscribe` (`appId == DKG entityId`) — and ONLY
8691
+ * (re)provisions the per-app Harbor project + push robot. The server creates
8692
+ * no DKG entity and no subscription; it asserts the caller owns the app and
8693
+ * that its subscription is ACTIVE (402 otherwise) first.
8694
+ *
8695
+ * Returns the same `{ appId, registry }` shape as {@link init}. Single-use
8696
+ * secret discipline applies to `registry.password` exactly as in `init`.
8697
+ *
8698
+ * This is the credentials path the mint-first `hsuite deploy` uses to obtain
8699
+ * push creds for the developer's already-minted subscription app
8700
+ * (`POST /apps/:appId/credentials/push`). The `hsuite redeploy` re-push path
8701
+ * uses {@link reissuePushCredentials} instead, which targets a dedicated
8702
+ * `credentials/reissue` route with stricter SUSPENDED-app + Harbor-failure
8703
+ * handling.
8704
+ */
8705
+ async pushCredentials(appId) {
8706
+ return this.http.post(
8707
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/credentials/push`,
8708
+ {}
8709
+ );
8710
+ }
8711
+ /**
8712
+ * Reissue ephemeral Harbor push credentials for an EXISTING app, WITHOUT
8713
+ * allocating a new appId / entity. Unlike {@link init} — which historically
8714
+ * forked a fresh smart-app entity (and a fresh paid subscription) on every
8715
+ * call — this re-binds to an app the developer already owns: the `appId` is
8716
+ * echoed back unchanged and only a new single-use `registry.password` push
8717
+ * robot is minted. Same `{ appId, registry }` response shape as `init`.
8718
+ *
8719
+ * Owner-only + active-subscription gated server-side. This is the credential
8720
+ * path `hsuite redeploy` uses so a re-push does not cost a new entity +
8721
+ * subscription each run. Targets the dedicated
8722
+ * `POST /apps/:appId/credentials/reissue` route (distinct from
8723
+ * {@link pushCredentials}'s first-deploy `credentials/push`): the reissue
8724
+ * route additionally refuses SUSPENDED apps and surfaces Harbor failures
8725
+ * loudly rather than returning placeholder creds.
8726
+ */
8727
+ async reissuePushCredentials(appId) {
8728
+ return this.http.post(
8729
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/credentials/reissue`,
8730
+ {}
8731
+ );
8632
8732
  }
8633
8733
  /**
8634
8734
  * Step 3 (optional) — upload the SPA tarball.
@@ -8639,7 +8739,7 @@ var DeploymentClient = class {
8639
8739
  */
8640
8740
  async uploadFrontend(appId, bundle, filename = "bundle.tar.gz") {
8641
8741
  return this.http.upload(
8642
- `/api/deployment/apps/${encodePathParam(appId)}/frontend`,
8742
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/frontend`,
8643
8743
  bundle,
8644
8744
  filename,
8645
8745
  void 0,
@@ -8653,32 +8753,32 @@ var DeploymentClient = class {
8653
8753
  * until `runtime.runtimeState === 'RUNNING'` for the URL to be live.
8654
8754
  */
8655
8755
  async deploy(appId, request) {
8656
- return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/deploy`, request);
8756
+ return this.http.post(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/deploy`, request);
8657
8757
  }
8658
8758
  /**
8659
8759
  * Roll back to a previously-deployed image tag (must exist in
8660
8760
  * `runtime.deploymentHistory[]`).
8661
8761
  */
8662
8762
  async rollback(appId, request) {
8663
- return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/rollback`, request);
8763
+ return this.http.post(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/rollback`, request);
8664
8764
  }
8665
8765
  /**
8666
8766
  * Live combined lifecycle + runtime status of an app.
8667
8767
  */
8668
8768
  async status(appId) {
8669
- return this.http.get(`/api/deployment/apps/${encodePathParam(appId)}/status`);
8769
+ return this.http.get(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/status`);
8670
8770
  }
8671
8771
  /**
8672
8772
  * List all deployed apps for the authenticated developer.
8673
8773
  */
8674
8774
  async list() {
8675
- return this.http.get("/api/deployment/apps");
8775
+ return this.http.get("/api/v3/smart-apps");
8676
8776
  }
8677
8777
  /**
8678
8778
  * Get app details.
8679
8779
  */
8680
8780
  async get(appId) {
8681
- return this.http.get(`/api/deployment/apps/${encodePathParam(appId)}`);
8781
+ return this.http.get(`/api/v3/smart-apps/${encodePathParam(appId)}`);
8682
8782
  }
8683
8783
  /**
8684
8784
  * Update app configuration.
@@ -8688,31 +8788,31 @@ var DeploymentClient = class {
8688
8788
  * @returns The updated app info.
8689
8789
  */
8690
8790
  async update(appId, updates) {
8691
- return this.http.put(`/api/deployment/apps/${encodePathParam(appId)}`, updates);
8791
+ return this.http.put(`/api/v3/smart-apps/${encodePathParam(appId)}`, updates);
8692
8792
  }
8693
8793
  /**
8694
8794
  * Delete an app (runtime effect: namespace teardown).
8695
8795
  */
8696
8796
  async delete(appId) {
8697
- return this.http.delete(`/api/deployment/apps/${encodePathParam(appId)}`);
8797
+ return this.http.delete(`/api/v3/smart-apps/${encodePathParam(appId)}`);
8698
8798
  }
8699
8799
  /**
8700
8800
  * Suspend an app (runtime effect: scale to zero).
8701
8801
  */
8702
8802
  async suspend(appId) {
8703
- return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/suspend`, {});
8803
+ return this.http.post(`/api/v3/smart-apps/${encodePathParam(appId)}/suspend`, {});
8704
8804
  }
8705
8805
  /**
8706
8806
  * Resume a suspended app (runtime effect: scale back up).
8707
8807
  */
8708
8808
  async resume(appId) {
8709
- return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/resume`, {});
8809
+ return this.http.post(`/api/v3/smart-apps/${encodePathParam(appId)}/resume`, {});
8710
8810
  }
8711
8811
  /**
8712
8812
  * Get deployment statistics.
8713
8813
  */
8714
8814
  async getStats() {
8715
- return this.http.get("/api/deployment/stats");
8815
+ return this.http.get("/api/v3/smart-apps/stats");
8716
8816
  }
8717
8817
  /**
8718
8818
  * Register or update the developer-facing webhook URL for runtime
@@ -8733,7 +8833,7 @@ var DeploymentClient = class {
8733
8833
  * CGNAT / cloud metadata destinations (SSRF guard).
8734
8834
  */
8735
8835
  async setWebhook(appId, webhookUrl) {
8736
- return this.http.put(`/api/deployment/apps/${encodePathParam(appId)}/webhook`, {
8836
+ return this.http.put(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/webhook`, {
8737
8837
  webhookUrl
8738
8838
  });
8739
8839
  }
@@ -8749,7 +8849,7 @@ var DeploymentClient = class {
8749
8849
  * exposition format.
8750
8850
  */
8751
8851
  async getMetrics(appId) {
8752
- return this.http.getText(`/api/deployment/apps/${encodePathParam(appId)}/metrics`);
8852
+ return this.http.getText(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/metrics`);
8753
8853
  }
8754
8854
  /**
8755
8855
  * Rotate the smart-app's tenant-secret KEK.
@@ -8760,7 +8860,7 @@ var DeploymentClient = class {
8760
8860
  */
8761
8861
  async rotateKek(appId) {
8762
8862
  return this.http.post(
8763
- `/api/deployment/apps/${encodePathParam(appId)}/credentials/rotate-kek`,
8863
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/credentials/rotate-kek`,
8764
8864
  {}
8765
8865
  );
8766
8866
  }
@@ -8774,7 +8874,7 @@ var DeploymentClient = class {
8774
8874
  */
8775
8875
  async revokeKek(appId, version) {
8776
8876
  return this.http.post(
8777
- `/api/deployment/apps/${encodePathParam(appId)}/credentials/revoke-kek`,
8877
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/credentials/revoke-kek`,
8778
8878
  { version }
8779
8879
  );
8780
8880
  }
@@ -9011,7 +9111,7 @@ var SmartEngineClient = class _SmartEngineClient {
9011
9111
  baseUrl;
9012
9112
  allowInsecure;
9013
9113
  http;
9014
- /** Separate HTTP client for /api/transactions (non-v3 base path) */
9114
+ /** Separate HTTP client for /api/v3/transactions */
9015
9115
  txHttp;
9016
9116
  /** Last HTTP error (for getHttpHealth) */
9017
9117
  lastHttpError;
@@ -9072,7 +9172,7 @@ var SmartEngineClient = class _SmartEngineClient {
9072
9172
  timeout: config.timeout
9073
9173
  });
9074
9174
  this.txHttp = createHttpClient({
9075
- baseUrl: `${this.baseUrl}/api/transactions`,
9175
+ baseUrl: `${this.baseUrl}/api/v3/transactions`,
9076
9176
  apiKey: config.apiKey,
9077
9177
  authToken: config.authToken,
9078
9178
  timeout: config.timeout
@@ -9406,7 +9506,17 @@ var SmartEngineClient = class _SmartEngineClient {
9406
9506
  return this.http.get("/status");
9407
9507
  }
9408
9508
  // ========== Messaging Operations ==========
9409
- /** Submit a message to consensus */
9509
+ /**
9510
+ * Submit a message to consensus.
9511
+ *
9512
+ * @deprecated Operator-funded message submission is RETIRED on the validator
9513
+ * under transaction sovereignty — `POST /api/v3/messages/:chain/:topicId`
9514
+ * now returns `403 Forbidden` (the operator must never front the chain fee
9515
+ * for a customer-supplied message). Use the payer-funded prepare path
9516
+ * instead: prepare a topic-message transaction via
9517
+ * `POST /api/transactions/topic/message/prepare`, then have the payer sign
9518
+ * and submit the returned bytes.
9519
+ */
9410
9520
  async submitMessage(chain, topicId, message) {
9411
9521
  if (message.length > 1024 * 1024) {
9412
9522
  throw new SmartEngineError2("Message too large (max 1MB)", 400);
@@ -10295,7 +10405,7 @@ var DatabaseClient = class {
10295
10405
  async insert(collection, document) {
10296
10406
  const appId = this.getAppId();
10297
10407
  return this.http.post(
10298
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}`,
10408
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}`,
10299
10409
  document
10300
10410
  );
10301
10411
  }
@@ -10313,7 +10423,7 @@ var DatabaseClient = class {
10313
10423
  if (options?.sort) params.set("sort", options.sort);
10314
10424
  const qs = params.toString();
10315
10425
  return this.http.get(
10316
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}${qs ? `?${qs}` : ""}`
10426
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}${qs ? `?${qs}` : ""}`
10317
10427
  );
10318
10428
  }
10319
10429
  /**
@@ -10322,7 +10432,7 @@ var DatabaseClient = class {
10322
10432
  async update(collection, documentId, updates) {
10323
10433
  const appId = this.getAppId();
10324
10434
  return this.http.put(
10325
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`,
10435
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`,
10326
10436
  updates
10327
10437
  );
10328
10438
  }
@@ -10332,19 +10442,19 @@ var DatabaseClient = class {
10332
10442
  async delete(collection, documentId) {
10333
10443
  const appId = this.getAppId();
10334
10444
  return this.http.delete(
10335
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`
10445
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`
10336
10446
  );
10337
10447
  }
10338
10448
  /**
10339
10449
  * List collections for the app.
10340
10450
  *
10341
- * Server route is `/api/db/:appId/collections`
10451
+ * Server route is `/api/v3/baas/db/:appId/collections`
10342
10452
  * (`database.controller.ts:106`). The previous bare-`:appId` GET 404'd
10343
10453
  * — Nest reserves that pattern for the document-find router below.
10344
10454
  */
10345
10455
  async listCollections() {
10346
10456
  const appId = this.getAppId();
10347
- return this.http.get(`/api/db/${encodePathParam(appId)}/collections`);
10457
+ return this.http.get(`/api/v3/baas/db/${encodePathParam(appId)}/collections`);
10348
10458
  }
10349
10459
  /**
10350
10460
  * Create a new collection in the database.
@@ -10354,7 +10464,7 @@ var DatabaseClient = class {
10354
10464
  */
10355
10465
  async createCollection(name) {
10356
10466
  const appId = this.getAppId();
10357
- return this.http.post(`/api/db/${encodePathParam(appId)}/collections`, { name });
10467
+ return this.http.post(`/api/v3/baas/db/${encodePathParam(appId)}/collections`, { name });
10358
10468
  }
10359
10469
  /**
10360
10470
  * Drop a collection and all its documents.
@@ -10365,7 +10475,7 @@ var DatabaseClient = class {
10365
10475
  async dropCollection(name) {
10366
10476
  const appId = this.getAppId();
10367
10477
  return this.http.delete(
10368
- `/api/db/${encodePathParam(appId)}/collections/${encodePathParam(name)}`
10478
+ `/api/v3/baas/db/${encodePathParam(appId)}/collections/${encodePathParam(name)}`
10369
10479
  );
10370
10480
  }
10371
10481
  // ========== State Proofs ==========
@@ -10374,7 +10484,7 @@ var DatabaseClient = class {
10374
10484
  */
10375
10485
  async getStateRoot() {
10376
10486
  const appId = this.getAppId();
10377
- return this.http.get(`/api/db/${encodePathParam(appId)}/state/root`);
10487
+ return this.http.get(`/api/v3/baas/db/${encodePathParam(appId)}/state/root`);
10378
10488
  }
10379
10489
  /**
10380
10490
  * Get a Merkle proof for a specific document
@@ -10382,7 +10492,7 @@ var DatabaseClient = class {
10382
10492
  async getDocumentProof(documentId) {
10383
10493
  const appId = this.getAppId();
10384
10494
  return this.http.get(
10385
- `/api/db/${encodePathParam(appId)}/${encodePathParam(documentId)}/proof`
10495
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(documentId)}/proof`
10386
10496
  );
10387
10497
  }
10388
10498
  /**
@@ -10396,7 +10506,7 @@ var DatabaseClient = class {
10396
10506
  if (options?.limit !== void 0) params.set("limit", String(options.limit));
10397
10507
  const qs = params.toString();
10398
10508
  return this.http.get(
10399
- `/api/db/${encodePathParam(appId)}/state/transitions${qs ? `?${qs}` : ""}`
10509
+ `/api/v3/baas/db/${encodePathParam(appId)}/state/transitions${qs ? `?${qs}` : ""}`
10400
10510
  );
10401
10511
  }
10402
10512
  /**
@@ -10404,7 +10514,7 @@ var DatabaseClient = class {
10404
10514
  */
10405
10515
  async getDbStats() {
10406
10516
  const appId = this.getAppId();
10407
- return this.http.get(`/api/db/${encodePathParam(appId)}/stats`);
10517
+ return this.http.get(`/api/v3/baas/db/${encodePathParam(appId)}/stats`);
10408
10518
  }
10409
10519
  };
10410
10520
 
@@ -10419,30 +10529,31 @@ var StorageClient = class {
10419
10529
  /**
10420
10530
  * Upload a file to storage
10421
10531
  */
10422
- async upload(file, filename, metadata) {
10532
+ async upload(file, filename, metadata, opts) {
10423
10533
  const appId = this.getAppId();
10424
- return this.http.upload(`/api/storage/${encodePathParam(appId)}/upload`, file, filename, metadata);
10534
+ return this.http.upload(`/api/v3/baas/storage/${encodePathParam(appId)}/upload`, file, filename, metadata, void 0, opts);
10425
10535
  }
10426
10536
  /**
10427
- * Download a file by CID
10537
+ * Download a file by CID. Returns the raw file bytes as a `Uint8Array`
10538
+ * (binary-safe — never JSON-parsed or text-decoded).
10428
10539
  */
10429
- async download(cid) {
10540
+ async download(cid, opts) {
10430
10541
  const appId = this.getAppId();
10431
- return this.http.get(`/api/storage/${encodePathParam(appId)}/download/${encodePathParam(cid)}`);
10542
+ return this.http.getBinary(`/api/v3/baas/storage/${encodePathParam(appId)}/download/${encodePathParam(cid)}`, opts);
10432
10543
  }
10433
10544
  /**
10434
10545
  * Get file metadata
10435
10546
  */
10436
- async getMetadata(cid) {
10547
+ async getMetadata(cid, opts) {
10437
10548
  const appId = this.getAppId();
10438
- return this.http.get(`/api/storage/${encodePathParam(appId)}/metadata/${encodePathParam(cid)}`);
10549
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/metadata/${encodePathParam(cid)}`, opts);
10439
10550
  }
10440
10551
  /**
10441
10552
  * Delete a file
10442
10553
  */
10443
- async delete(cid) {
10554
+ async delete(cid, opts) {
10444
10555
  const appId = this.getAppId();
10445
- return this.http.delete(`/api/storage/${encodePathParam(appId)}/${encodePathParam(cid)}`);
10556
+ return this.http.delete(`/api/v3/baas/storage/${encodePathParam(appId)}/${encodePathParam(cid)}`, opts);
10446
10557
  }
10447
10558
  /**
10448
10559
  * List all files for the app.
@@ -10451,27 +10562,27 @@ var StorageClient = class {
10451
10562
  * `offset` for pagination).
10452
10563
  * @returns The file list and total count.
10453
10564
  */
10454
- async listFiles(pagination) {
10565
+ async listFiles(pagination, opts) {
10455
10566
  const appId = this.getAppId();
10456
10567
  const params = new URLSearchParams();
10457
10568
  if (pagination?.limit !== void 0) params.set("limit", String(pagination.limit));
10458
10569
  if (pagination?.offset !== void 0) params.set("offset", String(pagination.offset));
10459
10570
  const qs = params.toString();
10460
- return this.http.get(`/api/storage/${encodePathParam(appId)}/files${qs ? `?${qs}` : ""}`);
10571
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/files${qs ? `?${qs}` : ""}`, opts);
10461
10572
  }
10462
10573
  /**
10463
10574
  * Get storage usage for the current app
10464
10575
  */
10465
- async getUsage() {
10576
+ async getUsage(opts) {
10466
10577
  const appId = this.getAppId();
10467
- return this.http.get(`/api/storage/${encodePathParam(appId)}/usage`);
10578
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/usage`, opts);
10468
10579
  }
10469
10580
  /**
10470
10581
  * Check if a file exists
10471
10582
  */
10472
- async exists(cid) {
10583
+ async exists(cid, opts) {
10473
10584
  const appId = this.getAppId();
10474
- return this.http.get(`/api/storage/${encodePathParam(appId)}/exists/${encodePathParam(cid)}`);
10585
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/exists/${encodePathParam(cid)}`, opts);
10475
10586
  }
10476
10587
  };
10477
10588
 
@@ -10484,61 +10595,99 @@ var FunctionsClient = class {
10484
10595
  http;
10485
10596
  getAppId;
10486
10597
  /**
10487
- * Deploy a new function
10488
- */
10489
- async deploy(request) {
10598
+ * Build the Ed25519 signed-code envelope the host mandates for every deploy
10599
+ * and eval. A fresh ephemeral keypair is generated per call, so no long-lived
10600
+ * signing key is held anywhere — each artifact carries its own signature.
10601
+ *
10602
+ * Scheme (must match the host verifier): `hash = sha256(code)` (hex),
10603
+ * `message = "<hash>:<timestamp>"`, signed Ed25519; `publicKey` is SPKI-DER
10604
+ * (base64). `crypto` is imported lazily so this never pulls Node built-ins
10605
+ * into a browser bundle that doesn't sign code.
10606
+ */
10607
+ async signCode(code) {
10608
+ const { generateKeyPairSync, createHash, sign: sign2 } = await import('crypto');
10609
+ const { publicKey, privateKey } = generateKeyPairSync("ed25519");
10610
+ const hash = createHash("sha256").update(code, "utf8").digest("hex");
10611
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
10612
+ const signature = sign2(null, Buffer.from(`${hash}:${timestamp}`, "utf8"), privateKey).toString("base64");
10613
+ const publicKeyDer = publicKey.export({ format: "der", type: "spki" }).toString("base64");
10614
+ return { code, hash, timestamp, signature, publicKey: publicKeyDer };
10615
+ }
10616
+ /**
10617
+ * Deploy a new function. If `signedCode` is omitted it is auto-built from
10618
+ * `request.code` via {@link signCode} — the host requires it, so the default
10619
+ * is to sign rather than 400. Pass your own envelope to override.
10620
+ */
10621
+ async deploy(request, opts) {
10490
10622
  const appId = this.getAppId();
10491
- return this.http.post(`/api/functions/${encodePathParam(appId)}`, request);
10623
+ const signedCode = request.signedCode ?? await this.signCode(request.code);
10624
+ return this.http.post(`/api/v3/baas/functions/${encodePathParam(appId)}`, { ...request, signedCode }, opts);
10492
10625
  }
10493
10626
  /**
10494
10627
  * Invoke a function
10495
10628
  */
10496
- async invoke(functionId, payload) {
10629
+ async invoke(functionId, payload, opts) {
10497
10630
  const appId = this.getAppId();
10498
10631
  return this.http.post(
10499
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/invoke`,
10500
- payload ?? {}
10632
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/invoke`,
10633
+ payload ?? {},
10634
+ opts
10501
10635
  );
10502
10636
  }
10637
+ /**
10638
+ * Evaluate signed code once (ephemeral) — no persistent deploy.
10639
+ *
10640
+ * For throwaway / AI-generated snippets. The host runs it in the same hardened
10641
+ * isolate and discards it; metered + quota'd like a normal invocation. As with
10642
+ * {@link deploy}, `signedCode` is auto-built from `request.code` when omitted.
10643
+ */
10644
+ async eval(request, opts) {
10645
+ const appId = this.getAppId();
10646
+ const signedCode = request.signedCode ?? await this.signCode(request.code);
10647
+ return this.http.post(`/api/v3/baas/functions/${encodePathParam(appId)}/eval`, { ...request, signedCode }, opts);
10648
+ }
10503
10649
  /**
10504
10650
  * List all functions for the current app
10505
10651
  */
10506
- async list() {
10652
+ async list(opts) {
10507
10653
  const appId = this.getAppId();
10508
- return this.http.get(`/api/functions/${encodePathParam(appId)}`);
10654
+ return this.http.get(`/api/v3/baas/functions/${encodePathParam(appId)}`, opts);
10509
10655
  }
10510
10656
  /**
10511
10657
  * Get function details
10512
10658
  */
10513
- async get(functionId) {
10659
+ async get(functionId, opts) {
10514
10660
  const appId = this.getAppId();
10515
10661
  return this.http.get(
10516
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`
10662
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
10663
+ opts
10517
10664
  );
10518
10665
  }
10519
10666
  /**
10520
10667
  * Update a function
10521
10668
  */
10522
- async update(functionId, updates) {
10669
+ async update(functionId, updates, opts) {
10523
10670
  const appId = this.getAppId();
10524
10671
  return this.http.put(
10525
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
10526
- updates
10672
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
10673
+ updates,
10674
+ opts
10527
10675
  );
10528
10676
  }
10529
10677
  /**
10530
10678
  * Delete a function
10531
10679
  */
10532
- async delete(functionId) {
10680
+ async delete(functionId, opts) {
10533
10681
  const appId = this.getAppId();
10534
10682
  return this.http.delete(
10535
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`
10683
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
10684
+ opts
10536
10685
  );
10537
10686
  }
10538
10687
  /**
10539
10688
  * Get function execution logs
10540
10689
  */
10541
- async getLogs(functionId, options) {
10690
+ async getLogs(functionId, options, opts) {
10542
10691
  const appId = this.getAppId();
10543
10692
  const params = new URLSearchParams();
10544
10693
  if (options?.limit !== void 0) params.set("limit", String(options.limit));
@@ -10546,15 +10695,16 @@ var FunctionsClient = class {
10546
10695
  if (options?.level) params.set("level", options.level);
10547
10696
  const qs = params.toString();
10548
10697
  return this.http.get(
10549
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/logs${qs ? `?${qs}` : ""}`
10698
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/logs${qs ? `?${qs}` : ""}`,
10699
+ opts
10550
10700
  );
10551
10701
  }
10552
10702
  /**
10553
10703
  * Get function statistics for an app
10554
10704
  */
10555
- async getStats() {
10705
+ async getStats(opts) {
10556
10706
  const appId = this.getAppId();
10557
- return this.http.get(`/api/functions/${encodePathParam(appId)}/stats`);
10707
+ return this.http.get(`/api/v3/baas/functions/${encodePathParam(appId)}/stats`, opts);
10558
10708
  }
10559
10709
  };
10560
10710
 
@@ -10569,45 +10719,46 @@ var MessagingClient = class {
10569
10719
  /**
10570
10720
  * Create a new channel
10571
10721
  */
10572
- async createChannel(config) {
10722
+ async createChannel(config, opts) {
10573
10723
  const appId = this.getAppId();
10574
- return this.http.post(`/api/messaging/${encodePathParam(appId)}/channels`, config);
10724
+ return this.http.post(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels`, config, opts);
10575
10725
  }
10576
10726
  /**
10577
10727
  * Delete a channel
10578
10728
  */
10579
- async deleteChannel(channelId) {
10729
+ async deleteChannel(channelId, opts) {
10580
10730
  const appId = this.getAppId();
10581
- return this.http.delete(`/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`);
10731
+ return this.http.delete(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`, opts);
10582
10732
  }
10583
10733
  /**
10584
10734
  * Get a channel by ID
10585
10735
  */
10586
- async getChannel(channelId) {
10736
+ async getChannel(channelId, opts) {
10587
10737
  const appId = this.getAppId();
10588
- return this.http.get(`/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`);
10738
+ return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`, opts);
10589
10739
  }
10590
10740
  /**
10591
10741
  * List all channels for the app
10592
10742
  */
10593
- async listChannels() {
10743
+ async listChannels(opts) {
10594
10744
  const appId = this.getAppId();
10595
- return this.http.get(`/api/messaging/${encodePathParam(appId)}/channels`);
10745
+ return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels`, opts);
10596
10746
  }
10597
10747
  /**
10598
10748
  * Publish a message to a channel
10599
10749
  */
10600
- async publish(channel, message, metadata) {
10750
+ async publish(channel, message, metadata, opts) {
10601
10751
  const appId = this.getAppId();
10602
10752
  return this.http.post(
10603
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/publish`,
10604
- { data: message, metadata }
10753
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/publish`,
10754
+ { data: message, metadata },
10755
+ opts
10605
10756
  );
10606
10757
  }
10607
10758
  /**
10608
10759
  * Get message history for a channel
10609
10760
  */
10610
- async getHistory(channel, options) {
10761
+ async getHistory(channel, options, opts) {
10611
10762
  const appId = this.getAppId();
10612
10763
  const params = new URLSearchParams();
10613
10764
  if (options?.limit !== void 0) params.set("limit", String(options.limit));
@@ -10615,7 +10766,8 @@ var MessagingClient = class {
10615
10766
  if (options?.after) params.set("after", options.after);
10616
10767
  const qs = params.toString();
10617
10768
  return this.http.get(
10618
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/history${qs ? `?${qs}` : ""}`
10769
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/history${qs ? `?${qs}` : ""}`,
10770
+ opts
10619
10771
  );
10620
10772
  }
10621
10773
  /**
@@ -10626,43 +10778,46 @@ var MessagingClient = class {
10626
10778
  * `setPresence(member)` hit a non-existent appId-scoped route and 404'd
10627
10779
  * in production. The channel is now the first argument.
10628
10780
  */
10629
- async setPresence(channel, member) {
10781
+ async setPresence(channel, member, opts) {
10630
10782
  const appId = this.getAppId();
10631
10783
  return this.http.post(
10632
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`,
10633
- member
10784
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`,
10785
+ member,
10786
+ opts
10634
10787
  );
10635
10788
  }
10636
10789
  /**
10637
10790
  * Remove a member's presence from a channel.
10638
10791
  *
10639
10792
  * BREAKING CHANGE (SDK 3.3.0): server route is
10640
- * `/api/messaging/:appId/channels/:channel/presence/:clientId`
10793
+ * `/api/v3/baas/messaging/:appId/channels/:channel/presence/:clientId`
10641
10794
  * (`messaging.controller.ts:352`). `channel` is now the first arg and
10642
10795
  * `clientId` (not `memberId`) the second — they're the same identifier
10643
10796
  * but renamed to match the server param.
10644
10797
  */
10645
- async removePresence(channel, clientId) {
10798
+ async removePresence(channel, clientId, opts) {
10646
10799
  const appId = this.getAppId();
10647
10800
  return this.http.delete(
10648
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence/${encodePathParam(clientId)}`
10801
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence/${encodePathParam(clientId)}`,
10802
+ opts
10649
10803
  );
10650
10804
  }
10651
10805
  /**
10652
10806
  * Get presence info for a channel
10653
10807
  */
10654
- async getPresence(channel) {
10808
+ async getPresence(channel, opts) {
10655
10809
  const appId = this.getAppId();
10656
10810
  return this.http.get(
10657
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`
10811
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`,
10812
+ opts
10658
10813
  );
10659
10814
  }
10660
10815
  /**
10661
10816
  * Get messaging statistics
10662
10817
  */
10663
- async getStats() {
10818
+ async getStats(opts) {
10664
10819
  const appId = this.getAppId();
10665
- return this.http.get(`/api/messaging/${encodePathParam(appId)}/stats`);
10820
+ return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/stats`, opts);
10666
10821
  }
10667
10822
  };
10668
10823
 
@@ -10678,21 +10833,21 @@ var CustomerSessionClient = class {
10678
10833
  * Step 1: ask the host to issue a fresh challenge for the customer to sign.
10679
10834
  */
10680
10835
  async challenge(input) {
10681
- return this.fetch("POST", "/api/customer-session/challenge", input);
10836
+ return this.fetch("POST", "/api/v3/baas/customer-session/challenge", input);
10682
10837
  }
10683
10838
  /**
10684
10839
  * Step 2: submit the customer's signed challenge. On success returns a
10685
10840
  * short-lived bearer JWT scoped to {appId, chain, address}.
10686
10841
  */
10687
10842
  async verify(req) {
10688
- return this.fetch("POST", "/api/customer-session/verify", req);
10843
+ return this.fetch("POST", "/api/v3/baas/customer-session/verify", req);
10689
10844
  }
10690
10845
  /**
10691
10846
  * Validate a customer bearer + return the decoded session info. Used by
10692
10847
  * smart-app backends to authorise incoming customer requests.
10693
10848
  */
10694
10849
  async validate(bearer) {
10695
- return this.fetch("GET", "/api/customer-session/validate", void 0, bearer);
10850
+ return this.fetch("GET", "/api/v3/baas/customer-session/validate", void 0, bearer);
10696
10851
  }
10697
10852
  /**
10698
10853
  * Revoke a customer session. Idempotent.
@@ -10700,7 +10855,7 @@ var CustomerSessionClient = class {
10700
10855
  async end(bearer) {
10701
10856
  return this.fetch(
10702
10857
  "POST",
10703
- "/api/customer-session/end",
10858
+ "/api/v3/baas/customer-session/end",
10704
10859
  void 0,
10705
10860
  bearer
10706
10861
  );
@@ -10746,15 +10901,15 @@ var RulesClient = class {
10746
10901
  http;
10747
10902
  /** Publish a canonical ValidatorRules document to HCS. */
10748
10903
  async publish(rule) {
10749
- return this.http.post("/api/rules/publish", rule);
10904
+ return this.http.post("/api/v3/baas/rules/publish", rule);
10750
10905
  }
10751
10906
  /** Fetch a published rule by its HCS consensus timestamp. */
10752
10907
  async get(consensusTimestamp) {
10753
- return this.http.get(`/api/rules/${encodePathParam(consensusTimestamp)}`);
10908
+ return this.http.get(`/api/v3/baas/rules/${encodePathParam(consensusTimestamp)}`);
10754
10909
  }
10755
10910
  /** List rules owned by the authenticated entity, optionally filtered by type. */
10756
10911
  async listByOwner(filter) {
10757
- const path = filter?.type ? `/api/rules?type=${encodeURIComponent(filter.type)}` : "/api/rules";
10912
+ const path = filter?.type ? `/api/v3/baas/rules?type=${encodeURIComponent(filter.type)}` : "/api/v3/baas/rules";
10758
10913
  return this.http.get(path);
10759
10914
  }
10760
10915
  /**
@@ -10762,44 +10917,332 @@ var RulesClient = class {
10762
10917
  * `ruleRef` (published) or `rule` (inline) must be supplied by the caller.
10763
10918
  */
10764
10919
  async simulate(params) {
10765
- return this.http.post("/api/rules/simulate", params);
10920
+ return this.http.post("/api/v3/baas/rules/simulate", params);
10766
10921
  }
10767
10922
  /** Walk the version history of a published rule. */
10768
10923
  async getVersionHistory(consensusTimestamp) {
10769
10924
  return this.http.get(
10770
- `/api/rules/${encodePathParam(consensusTimestamp)}/versions`
10925
+ `/api/v3/baas/rules/${encodePathParam(consensusTimestamp)}/versions`
10771
10926
  );
10772
10927
  }
10773
10928
  /** Deprecate a published rule (owner-only). */
10774
10929
  async deprecate(consensusTimestamp) {
10775
10930
  return this.http.post(
10776
- `/api/rules/${encodePathParam(consensusTimestamp)}/deprecate`,
10931
+ `/api/v3/baas/rules/${encodePathParam(consensusTimestamp)}/deprecate`,
10777
10932
  {}
10778
10933
  );
10779
10934
  }
10780
10935
  };
10781
10936
 
10782
10937
  // src/baas/entities/client.ts
10783
- var EntitiesClient = class {
10938
+ var EntitiesClient = class _EntitiesClient {
10784
10939
  constructor(http) {
10785
10940
  this.http = http;
10786
10941
  }
10787
10942
  http;
10788
- /** Create a canonical token entity bound to a published rule. */
10943
+ /**
10944
+ * Chains whose token-create routes through the payer-funded 3-step (prepare →
10945
+ * fund → execute), mirroring `createAccount`. Hedera = real HTS TokenCreate
10946
+ * (admin/supply = the per-entity DKG slot-pubkey KeyList; treasury = the
10947
+ * entity's own account; `0.0.X` token id is network-assigned, resolved from the
10948
+ * receipt via the threaded `createTxId`). Cardano/Solana/Polkadot = the
10949
+ * AUTHORITY entity (the entity IS the policy/mint/Assets-admin multisig — same
10950
+ * address as an account; the asset MINT itself is a later operate-tab payer
10951
+ * call). XRPL/Stellar token = an ISSUER ACCOUNT (reuses the account preparer) +
10952
+ * issuer flags set at finalize: XRPL relays the funding Payment then finalizes
10953
+ * (issuer-flag AccountSets + SignerListSet + disable-master); Stellar relays the
10954
+ * CreateAccount then finalizes (SetOptions install incl. issuer setFlags +
10955
+ * master lock). Every OTHER chain (EVM) stays on the legacy synchronous path.
10956
+ */
10957
+ static PAYER_FUNDED_TOKEN_CHAINS = /* @__PURE__ */ new Set([
10958
+ "hedera",
10959
+ "cardano",
10960
+ "solana",
10961
+ "polkadot",
10962
+ "xrpl",
10963
+ "stellar"
10964
+ ]);
10965
+ /**
10966
+ * PREPARE half of the payer-funded token-create flow.
10967
+ *
10968
+ * POSTs `/api/v3/baas/entities/prepare-create` with `entityType: 'token'`. The cluster
10969
+ * runs the per-entity DKG, builds the payer-funded create (Hedera: TokenCreate
10970
+ * keyed by the slot-pubkey KeyList with the entity account as treasury;
10971
+ * Cardano/Solana/Polkadot: funds/provisions the authority multisig), and returns
10972
+ * the prepared blob. The prepared `transactionId` is the `createTxId` for
10973
+ * execute (Hedera).
10974
+ */
10975
+ async prepareCreateToken(req) {
10976
+ return this.http.post("/api/v3/baas/entities/prepare-create", {
10977
+ entityType: "token",
10978
+ ...req
10979
+ });
10980
+ }
10981
+ /**
10982
+ * EXECUTE half of the payer-funded token-create flow.
10983
+ *
10984
+ * POSTs `/api/v3/baas/entities/execute-create` with `entityType: 'token'`. For Hedera,
10985
+ * pass `createTxId` (the prepared create's `transactionId`) so the validator
10986
+ * resolves the network-assigned `0.0.X` token id from the receipt and stamps
10987
+ * `chainAccounts.hedera`. For the authority-entity chains (cardano/solana/
10988
+ * polkadot) execute just verifies the binding and echoes the stamped authority
10989
+ * address (no `createTxId` needed).
10990
+ */
10991
+ async executeCreateToken(req) {
10992
+ const { createTxId, signedFundingBlob, ...rest } = req;
10993
+ return this.http.post("/api/v3/baas/entities/execute-create", {
10994
+ ...rest,
10995
+ ...createTxId !== void 0 ? { createTxId } : {},
10996
+ ...signedFundingBlob !== void 0 ? { signedFundingBlob } : {},
10997
+ entityType: "token"
10998
+ });
10999
+ }
11000
+ /**
11001
+ * Create a canonical token entity bound to a published rule.
11002
+ *
11003
+ * Dispatches by `chain` (mirrors `createAccount`):
11004
+ * - **Hedera / Cardano / Solana / Polkadot** = payer-funded 3-step (prepare →
11005
+ * caller funds via `fundWith` → execute). Hedera resolves the network-assigned
11006
+ * `0.0.X` token id from the receipt (threads `createTxId`); the authority-
11007
+ * entity chains verify/echo the stamped authority address. `fundWith` is
11008
+ * REQUIRED; to drive the steps manually call `prepareCreateToken` /
11009
+ * `executeCreateToken` directly.
11010
+ * - **XRPL / Stellar** = payer-funded too (account-model issuer): `fundWith`
11011
+ * REQUIRED; the caller's signed funding blob is RELAYED to the validator,
11012
+ * which submits it then finalizes the issuer multisig (master-locked). NO
11013
+ * issuer flags are set at create — issuer auth flags / DefaultRipple / clawback
11014
+ * are an operate-tab, rules-validated concern.
11015
+ * - **EVM / other** = legacy synchronous `POST /api/v3/baas/entities/createToken`
11016
+ * (payer-funded-only fields ignored) until it migrates.
11017
+ */
10789
11018
  async createToken(req) {
10790
- return this.http.post("/api/entities/createToken", req);
11019
+ if (_EntitiesClient.PAYER_FUNDED_TOKEN_CHAINS.has(req.chain)) {
11020
+ const { fundWith, ...prepReq } = req;
11021
+ const prep = await this.prepareCreateToken(prepReq);
11022
+ if (!fundWith) {
11023
+ throw new Error(
11024
+ `createToken(${req.chain}): pass fundWith (sign+submit the prepared create tx), or call prepareCreateToken/executeCreateToken directly`
11025
+ );
11026
+ }
11027
+ const funded = await fundWith(prep.prepared, {
11028
+ address: prep.address,
11029
+ reserveRequirement: prep.reserveRequirement
11030
+ });
11031
+ return this.executeCreateToken({
11032
+ entityId: prep.entityId,
11033
+ chain: req.chain,
11034
+ securityMode: req.securityMode,
11035
+ signedFundingBlob: _EntitiesClient.FUNDING_BLOB_RELAY_CHAINS.has(req.chain) ? funded?.signedFundingBlob : void 0,
11036
+ createTxId: req.chain === "hedera" ? prep.prepared?.[0]?.transactionId : void 0
11037
+ });
11038
+ }
11039
+ const {
11040
+ fundWith: _ignoredFundWith,
11041
+ payerAccountId: _ignoredPayer,
11042
+ securityMode: _ignoredSecurityMode,
11043
+ ...legacyReq
11044
+ } = req;
11045
+ return this.http.post("/api/v3/baas/entities/createToken", legacyReq);
11046
+ }
11047
+ /**
11048
+ * PREPARE half of the payer-funded account-create flow.
11049
+ *
11050
+ * POSTs `/api/v3/baas/entities/prepare-create`. The cluster runs the per-entity DKG
11051
+ * (persists the binding, submits nothing on-chain) and returns the unsigned
11052
+ * payer-funding `Payment`(s) the caller signs + submits with their own wallet.
11053
+ */
11054
+ async prepareCreateAccount(req) {
11055
+ return this.http.post("/api/v3/baas/entities/prepare-create", {
11056
+ entityType: "account",
11057
+ ...req
11058
+ });
11059
+ }
11060
+ /**
11061
+ * EXECUTE half of the payer-funded account-create flow.
11062
+ *
11063
+ * POSTs `/api/v3/baas/entities/execute-create`. The entity already exists (its DKG
11064
+ * ran during prepare); pass `signedFundingBlob` for the validator to submit
11065
+ * the payer's signed funding `Payment` (XRPL only), or omit it when the caller
11066
+ * already submitted the funding tx themselves (then execute just finalizes /
11067
+ * verifies).
11068
+ *
11069
+ * `createTxId` is the HEDERA thread: a Hedera AccountCreate gets its
11070
+ * network-assigned `0.0.X` id only from the on-chain receipt after the payer
11071
+ * submits. The caller threads the prepared create's `transactionId` (from
11072
+ * `prepared[0].transactionId`) back here so the validator resolves the id from
11073
+ * the receipt server-side. Ignored for non-Hedera chains.
11074
+ */
11075
+ async executeCreateAccount(req) {
11076
+ const { createTxId, ...rest } = req;
11077
+ return this.http.post("/api/v3/baas/entities/execute-create", {
11078
+ ...rest,
11079
+ ...createTxId !== void 0 ? { createTxId } : {}
11080
+ });
10791
11081
  }
10792
- /** Create a canonical account entity bound to a published rule. */
11082
+ /**
11083
+ * Chains whose account-create routes through the payer-funded 3-step
11084
+ * (prepare → fund → execute). All are ledgers where the validators never pay:
11085
+ * XRPL funds a reserve; Bitcoin funds a P2WSH UTXO; Cardano funds a
11086
+ * native-script enterprise address above min-UTXO; Polkadot funds a
11087
+ * pallet_multisig SS58 above the existential deposit; Solana funds a Squads
11088
+ * multisig PDA (deterministic from the createKey) via a payer-paid
11089
+ * `multisigCreateV2` — the payer's submission IS the create (no separate
11090
+ * finalizer). Hedera is create-WITH-KEY: the payer submits an AccountCreate
11091
+ * whose controlling key is the per-entity DKG slot-pubkey KeyList, so the
11092
+ * payer's submit IS the create; its `0.0.X` id is network-assigned (resolved
11093
+ * from the receipt at execute-create via the threaded `createTxId`). Stellar is
11094
+ * account-MODEL (like XRPL): the payer funds the entity's slot-0 `G...` master
11095
+ * via a CreateAccount, the validator RELAYS the signed funding blob, then
11096
+ * execute-create finalizes on-chain (threshold-signs a SetOptions installing
11097
+ * the validator chain-key multisig + locking the master). EVM stays on the
11098
+ * legacy synchronous create until it migrates.
11099
+ */
11100
+ static PAYER_FUNDED_CREATE_CHAINS = /* @__PURE__ */ new Set([
11101
+ "xrpl",
11102
+ "bitcoin",
11103
+ "cardano",
11104
+ "polkadot",
11105
+ "solana",
11106
+ "hedera",
11107
+ "stellar"
11108
+ ]);
11109
+ /**
11110
+ * Chains whose execute-create RELAYS the payer's signed funding blob for the
11111
+ * validator to submit (then finalizes on-chain). Both are account-model ledgers
11112
+ * with a validator-side finalize step: XRPL (SignerListSet + disable-master),
11113
+ * Stellar (SetOptions install + master lock). Every OTHER payer-funded chain
11114
+ * has the PAYER submit the funding tx directly with their own wallet — their
11115
+ * execute-create REJECTS a non-undefined `signedFundingBlob` (400), so the blob
11116
+ * is omitted for them.
11117
+ */
11118
+ static FUNDING_BLOB_RELAY_CHAINS = /* @__PURE__ */ new Set(["xrpl", "stellar"]);
11119
+ /**
11120
+ * Create a canonical account entity bound to a published rule.
11121
+ *
11122
+ * Dispatches by `chain`:
11123
+ * - **XRPL / Stellar / Bitcoin / Cardano / Polkadot / Solana / Hedera** =
11124
+ * payer-funded 3-step (prepare → fund → execute). The cluster runs the
11125
+ * per-entity DKG and returns the unsigned payer-funding tx(s); the
11126
+ * caller-supplied `fundWith` callback signs + submits (or just signs) the
11127
+ * funding tx with their OWN wallet — the SDK never holds the customer's chain
11128
+ * key nor opens a network connection — then `executeCreateAccount` finalizes
11129
+ * (XRPL + Stellar finalize on-chain after relaying the funding blob; the
11130
+ * deterministic ledgers + Solana verify/stamp the binding; Hedera resolves
11131
+ * the network-assigned id from the receipt). `fundWith` is REQUIRED on these
11132
+ * chains; to drive the steps manually call `prepareCreateAccount` /
11133
+ * `executeCreateAccount` directly.
11134
+ * - **other chains** (EVM) = legacy synchronous create — a single
11135
+ * `POST /api/v3/baas/entities/createAccount`, unchanged from pre-3.9.0. These chains
11136
+ * migrate to the payer-funded flow in a later phase; until then the
11137
+ * payer-funded-only fields (`fundWith` / `payerAccountId` / `securityMode`)
11138
+ * are ignored.
11139
+ */
10793
11140
  async createAccount(req) {
10794
- return this.http.post("/api/entities/createAccount", req);
11141
+ if (_EntitiesClient.PAYER_FUNDED_CREATE_CHAINS.has(req.chain)) {
11142
+ const { fundWith, ...prepReq } = req;
11143
+ const prep = await this.prepareCreateAccount(prepReq);
11144
+ if (!fundWith) {
11145
+ throw new Error(
11146
+ `createAccount(${req.chain}): pass fundWith (sign+submit the prepared funding tx), or call prepareCreateAccount/executeCreateAccount directly`
11147
+ );
11148
+ }
11149
+ const funded = await fundWith(prep.prepared, {
11150
+ address: prep.address,
11151
+ reserveRequirement: prep.reserveRequirement
11152
+ });
11153
+ return this.executeCreateAccount({
11154
+ entityId: prep.entityId,
11155
+ chain: req.chain,
11156
+ securityMode: req.securityMode,
11157
+ signedFundingBlob: _EntitiesClient.FUNDING_BLOB_RELAY_CHAINS.has(req.chain) ? funded?.signedFundingBlob : void 0,
11158
+ createTxId: req.chain === "hedera" ? prep.prepared?.[0]?.transactionId : void 0
11159
+ });
11160
+ }
11161
+ const {
11162
+ fundWith: _ignoredFundWith,
11163
+ payerAccountId: _ignoredPayer,
11164
+ securityMode: _ignoredSecurityMode,
11165
+ ...legacyReq
11166
+ } = req;
11167
+ return this.http.post("/api/v3/baas/entities/createAccount", legacyReq);
11168
+ }
11169
+ /**
11170
+ * PREPARE half of the payer-funded topic-create flow (Hedera).
11171
+ *
11172
+ * POSTs `/api/v3/baas/entities/prepare-create` with `entityType: 'topic'`. The cluster
11173
+ * runs the per-entity DKG (persists the binding), builds the payer-funded
11174
+ * TopicCreate keyed by the slot-pubkey KeyList, attaches the validator admin
11175
+ * threshold sig, and returns the prepared blob for the caller to add the fee
11176
+ * sig + submit. The prepared `transactionId` is the `createTxId` for execute.
11177
+ */
11178
+ async prepareCreateTopic(req) {
11179
+ return this.http.post("/api/v3/baas/entities/prepare-create", {
11180
+ entityType: "topic",
11181
+ ...req
11182
+ });
11183
+ }
11184
+ /**
11185
+ * EXECUTE half of the payer-funded topic-create flow (Hedera).
11186
+ *
11187
+ * POSTs `/api/v3/baas/entities/execute-create` with `entityType: 'topic'`. The topic
11188
+ * already exists once the payer submitted the create tx; pass `createTxId` (the
11189
+ * prepared create's `transactionId`) so the validator resolves the network-
11190
+ * assigned `0.0.X` topic id from the receipt and stamps `chainAccounts.hedera`.
11191
+ */
11192
+ async executeCreateTopic(req) {
11193
+ return this.http.post("/api/v3/baas/entities/execute-create", {
11194
+ ...req,
11195
+ entityType: "topic"
11196
+ });
10795
11197
  }
10796
- /** Create a canonical topic entity bound to a published rule. */
11198
+ /**
11199
+ * Create a canonical topic entity bound to a published rule.
11200
+ *
11201
+ * Dispatches by `chain`:
11202
+ * - **Hedera** = payer-funded 3-step (prepare → caller submits the TopicCreate
11203
+ * via `fundWith` → execute resolves the `0.0.X` topic id from the receipt).
11204
+ * `fundWith` is REQUIRED; to drive the steps manually call
11205
+ * `prepareCreateTopic` / `executeCreateTopic` directly.
11206
+ * - **other chains** = legacy synchronous `POST /api/v3/baas/entities/createTopic`
11207
+ * (topics are a Hedera primitive; the legacy path is unchanged).
11208
+ */
10797
11209
  async createTopic(req) {
10798
- return this.http.post("/api/entities/createTopic", req);
11210
+ if (req.chain === "hedera") {
11211
+ const { fundWith, ...prepReq } = req;
11212
+ const prep = await this.prepareCreateTopic(prepReq);
11213
+ if (!fundWith) {
11214
+ throw new Error(
11215
+ "createTopic(hedera): pass fundWith (sign+submit the prepared TopicCreate), or call prepareCreateTopic/executeCreateTopic directly"
11216
+ );
11217
+ }
11218
+ await fundWith(prep.prepared, {
11219
+ address: prep.address,
11220
+ reserveRequirement: prep.reserveRequirement
11221
+ });
11222
+ const createTxId = prep.prepared?.[0]?.transactionId;
11223
+ if (!createTxId) {
11224
+ throw new Error(
11225
+ "createTopic(hedera): prepared TopicCreate carries no transactionId \u2014 cannot resolve the topic id from the receipt"
11226
+ );
11227
+ }
11228
+ return this.executeCreateTopic({
11229
+ entityId: prep.entityId,
11230
+ chain: req.chain,
11231
+ createTxId,
11232
+ securityMode: req.securityMode
11233
+ });
11234
+ }
11235
+ const {
11236
+ fundWith: _ignoredFundWith,
11237
+ payerAccountId: _ignoredPayer,
11238
+ securityMode: _ignoredSecurityMode,
11239
+ ...legacyReq
11240
+ } = req;
11241
+ return this.http.post("/api/v3/baas/entities/createTopic", legacyReq);
10799
11242
  }
10800
11243
  /** Create a canonical agent entity bound to a published rule. */
10801
11244
  async createAgent(req) {
10802
- return this.http.post("/api/entities/createAgent", req);
11245
+ return this.http.post("/api/v3/baas/entities/createAgent", req);
10803
11246
  }
10804
11247
  /**
10805
11248
  * Mega-helper: build a token rule with a launchpad ModuleEntry attached,
@@ -10807,15 +11250,15 @@ var EntitiesClient = class {
10807
11250
  * round-trip.
10808
11251
  */
10809
11252
  async launchpad(req) {
10810
- return this.http.post("/api/entities/launchpad", req);
11253
+ return this.http.post("/api/v3/baas/entities/launchpad", req);
10811
11254
  }
10812
11255
  /** Fetch an entity by its canonical `entityId`. */
10813
11256
  async get(entityId) {
10814
- return this.http.get(`/api/entities/${encodePathParam(entityId)}`);
11257
+ return this.http.get(`/api/v3/baas/entities/${encodePathParam(entityId)}`);
10815
11258
  }
10816
11259
  /** List entities owned by the authenticated wallet, optionally filtered by type. */
10817
11260
  async listByOwner(filter) {
10818
- const path = filter?.type ? `/api/entities?type=${encodeURIComponent(filter.type)}` : "/api/entities";
11261
+ const path = filter?.type ? `/api/v3/baas/entities?type=${encodeURIComponent(filter.type)}` : "/api/v3/baas/entities";
10819
11262
  return this.http.get(path);
10820
11263
  }
10821
11264
  };
@@ -10828,6 +11271,13 @@ var BaasClient = class _BaasClient {
10828
11271
  timeout;
10829
11272
  allowInsecure;
10830
11273
  http;
11274
+ /**
11275
+ * Validator-routed HTTP client for the `/api/v3/transactions/*` prepare/execute
11276
+ * surface — a SIBLING of `/host`, NOT under the `pathPrefix`. Rooted at the
11277
+ * raw gateway/ingress origin (`hostUrl`) so transactions reach the validator
11278
+ * even when BaaS traffic is gateway-routed at `/host/*`.
11279
+ */
11280
+ txHttp;
10831
11281
  /** Last HTTP error (for getHttpHealth) */
10832
11282
  lastHttpError;
10833
11283
  /**
@@ -10856,6 +11306,14 @@ var BaasClient = class _BaasClient {
10856
11306
  rules;
10857
11307
  /** Canonical entity authoring surface (token/account/topic/agent + launchpad). */
10858
11308
  entities;
11309
+ /**
11310
+ * Validator-routed transaction prepare/execute (sovereignty model). The
11311
+ * prepare endpoints accept an explicit `payerAccountId` for the session-less
11312
+ * payer path, OR carry the web3-auth session token for the JWT-wallet payer
11313
+ * path (kept in sync with the main client's token — see {@link authenticate}).
11314
+ * Targets `/api/v3/transactions/*`, a sibling of the `/host` BaaS surface.
11315
+ */
11316
+ transactions;
10859
11317
  constructor(config) {
10860
11318
  this.allowInsecure = config.allowInsecure ?? false;
10861
11319
  this.hostUrl = validateUrl2(config.hostUrl, this.allowInsecure);
@@ -10869,7 +11327,12 @@ var BaasClient = class _BaasClient {
10869
11327
  timeout: this.timeout,
10870
11328
  // Transparent session refresh: on a 401, re-run the challenge-response
10871
11329
  // with the retained signer and retry once. No-op until authenticate() has
10872
- // been called (authContext set). Excludes /api/auth/* (see http client).
11330
+ // been called (authContext set). Excludes /api/v3/{,baas/}auth/* (see http client).
11331
+ onUnauthorized: () => this.reauthenticate()
11332
+ });
11333
+ this.txHttp = createHttpClient({
11334
+ baseUrl: `${this.hostUrl.replace(/\/$/, "")}/api/v3/transactions`,
11335
+ timeout: this.timeout,
10873
11336
  onUnauthorized: () => this.reauthenticate()
10874
11337
  });
10875
11338
  const getAppId = () => this.requireAppId();
@@ -10882,6 +11345,7 @@ var BaasClient = class _BaasClient {
10882
11345
  this.customerSession = new CustomerSessionClient(baseUrlWithPrefix, this.timeout);
10883
11346
  this.rules = new RulesClient(this.http);
10884
11347
  this.entities = new EntitiesClient(this.http);
11348
+ this.transactions = new TransactionsClient(this.txHttp);
10885
11349
  }
10886
11350
  /**
10887
11351
  * Connect to the Smart Engines BaaS via cluster auto-discovery.
@@ -11009,7 +11473,7 @@ var BaasClient = class _BaasClient {
11009
11473
  this.authContext = options;
11010
11474
  let challenge;
11011
11475
  try {
11012
- challenge = await this.http.post("/api/auth/challenge", {
11476
+ challenge = await this.http.post("/api/v3/baas/auth/challenge", {
11013
11477
  chain,
11014
11478
  walletAddress,
11015
11479
  appId: this.appId
@@ -11020,7 +11484,7 @@ var BaasClient = class _BaasClient {
11020
11484
  const signature = await signFn(challenge.message);
11021
11485
  let result;
11022
11486
  try {
11023
- result = await this.http.post("/api/auth/verify", {
11487
+ result = await this.http.post("/api/v3/baas/auth/verify", {
11024
11488
  challengeId: challenge.challengeId,
11025
11489
  signature,
11026
11490
  publicKey
@@ -11029,6 +11493,7 @@ var BaasClient = class _BaasClient {
11029
11493
  throw asBaasError(err);
11030
11494
  }
11031
11495
  this.http.setAuthToken(result.token);
11496
+ this.txHttp.setAuthToken(result.token);
11032
11497
  return result;
11033
11498
  }
11034
11499
  /**
@@ -11036,30 +11501,31 @@ var BaasClient = class _BaasClient {
11036
11501
  * session token. Invoked by the http client's `onUnauthorized` hook when a
11037
11502
  * request 401s because the token expired — so long-lived clients keep working
11038
11503
  * without the caller re-implementing refresh. No-op if {@link authenticate}
11039
- * was never called. The `/api/auth/*` calls below are excluded from the http
11504
+ * was never called. The `/api/v3/baas/auth/*` calls below are excluded from the http
11040
11505
  * client's 401-retry path, so this can never recurse.
11041
11506
  */
11042
11507
  async reauthenticate() {
11043
11508
  const ctx = this.authContext;
11044
11509
  if (!ctx) return;
11045
- const challenge = await this.http.post("/api/auth/challenge", {
11510
+ const challenge = await this.http.post("/api/v3/baas/auth/challenge", {
11046
11511
  chain: ctx.chain,
11047
11512
  walletAddress: ctx.walletAddress,
11048
11513
  appId: this.appId
11049
11514
  });
11050
11515
  const signature = await ctx.signFn(challenge.message);
11051
- const result = await this.http.post("/api/auth/verify", {
11516
+ const result = await this.http.post("/api/v3/baas/auth/verify", {
11052
11517
  challengeId: challenge.challengeId,
11053
11518
  signature,
11054
11519
  publicKey: ctx.publicKey
11055
11520
  });
11056
11521
  this.http.setAuthToken(result.token);
11522
+ this.txHttp.setAuthToken(result.token);
11057
11523
  }
11058
11524
  /** Validate the current session */
11059
11525
  async validateSession() {
11060
11526
  this.requireAuth();
11061
11527
  try {
11062
- return await this.http.get("/api/auth/session");
11528
+ return await this.http.get("/api/v3/baas/auth/session");
11063
11529
  } catch (err) {
11064
11530
  throw asBaasError(err);
11065
11531
  }
@@ -11068,11 +11534,12 @@ var BaasClient = class _BaasClient {
11068
11534
  async logout() {
11069
11535
  if (this.http.getAuthToken()) {
11070
11536
  try {
11071
- await this.http.post("/api/auth/logout", {});
11537
+ await this.http.post("/api/v3/baas/auth/logout", {});
11072
11538
  } catch {
11073
11539
  }
11074
11540
  }
11075
11541
  this.http.setAuthToken(void 0);
11542
+ this.txHttp.setAuthToken(void 0);
11076
11543
  }
11077
11544
  // ========== HTTP Helpers ==========
11078
11545
  requireAuth() {