@hsuite/smart-engines-sdk 3.7.0 → 3.10.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
@@ -6745,7 +6745,7 @@ function createHttpClient(config) {
6745
6745
  try {
6746
6746
  return await op();
6747
6747
  } catch (error) {
6748
- const refreshable = !!config.onUnauthorized && !path.startsWith("/api/auth/") && error instanceof SdkHttpError && error.statusCode === 401;
6748
+ const refreshable = !!config.onUnauthorized && !path.startsWith("/api/v3/baas/auth/") && !path.startsWith("/api/v3/auth/") && error instanceof SdkHttpError && error.statusCode === 401;
6749
6749
  if (!refreshable) throw error;
6750
6750
  if (!reauthInFlight) {
6751
6751
  reauthInFlight = Promise.resolve(config.onUnauthorized()).finally(() => {
@@ -7729,7 +7729,7 @@ var HederaTransactionsClient = class {
7729
7729
  * - `client.hedera.tss.createTopic(...)` makes the cluster sign+submit in one call.
7730
7730
  *
7731
7731
  * `tssHttp` is the validator's `/api/v3`-rooted HTTP client (different from
7732
- * the `/api/transactions` one this class uses for prepare paths). Both
7732
+ * the `/api/v3/transactions` one this class uses for prepare paths). Both
7733
7733
  * clients are required — the previous single-arg fallback to `http` was
7734
7734
  * unreachable through `SmartEngineClient` (the only call site always
7735
7735
  * passes both).
@@ -8531,15 +8531,15 @@ var AgentsClient = class {
8531
8531
  http;
8532
8532
  /** Register a new agent */
8533
8533
  async register(request) {
8534
- return this.http.post("/api/agents/register", request);
8534
+ return this.http.post("/api/v3/baas/agents/register", request);
8535
8535
  }
8536
8536
  /** Get agent details */
8537
8537
  async get(agentId) {
8538
- return this.http.get(`/api/agents/${encodePathParam(agentId)}`);
8538
+ return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}`);
8539
8539
  }
8540
8540
  /** List all agents */
8541
8541
  async list() {
8542
- return this.http.get("/api/agents");
8542
+ return this.http.get("/api/v3/baas/agents");
8543
8543
  }
8544
8544
  /**
8545
8545
  * Fund agent treasury (owner-only). Returns a
@@ -8547,60 +8547,60 @@ var AgentsClient = class {
8547
8547
  * the caller is expected to sign and submit the prepared bytes.
8548
8548
  */
8549
8549
  async fund(agentId, request) {
8550
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/fund`, request);
8550
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/fund`, request);
8551
8551
  }
8552
8552
  /**
8553
8553
  * Execute a trade (agent-wallet OR owner). Returns a
8554
8554
  * `PreparedTransactionResponse` wrapped in a `success: true` envelope.
8555
8555
  */
8556
8556
  async trade(agentId, request) {
8557
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/trade`, request);
8557
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/trade`, request);
8558
8558
  }
8559
8559
  /**
8560
8560
  * Withdraw from agent treasury (owner-only). Returns a
8561
8561
  * `PreparedTransactionResponse` wrapped in a `success: true` envelope.
8562
8562
  */
8563
8563
  async withdraw(agentId, request) {
8564
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/withdraw`, request);
8564
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/withdraw`, request);
8565
8565
  }
8566
8566
  /** Pause an agent */
8567
8567
  async pause(agentId) {
8568
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/pause`, {});
8568
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/pause`, {});
8569
8569
  }
8570
8570
  /** Resume a paused agent */
8571
8571
  async resume(agentId) {
8572
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/resume`, {});
8572
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/resume`, {});
8573
8573
  }
8574
8574
  /** Revoke an agent (permanent) */
8575
8575
  async revoke(agentId) {
8576
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/revoke`, {});
8576
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/revoke`, {});
8577
8577
  }
8578
8578
  /**
8579
8579
  * Update agent rules.
8580
8580
  *
8581
- * Server route is PATCH `/api/agents/:agentId/rules`
8581
+ * Server route is PATCH `/api/v3/baas/agents/:agentId/rules`
8582
8582
  * (`agents.controller.ts:375`). The previous PUT variant 404'd because
8583
8583
  * Nest matched the dynamic `:agentId` GET/POST handlers and rejected
8584
8584
  * the verb mismatch.
8585
8585
  */
8586
8586
  async updateRules(agentId, rules) {
8587
- return this.http.patch(`/api/agents/${encodePathParam(agentId)}/rules`, rules);
8587
+ return this.http.patch(`/api/v3/baas/agents/${encodePathParam(agentId)}/rules`, rules);
8588
8588
  }
8589
8589
  /** Get agent events */
8590
8590
  async getEvents(agentId) {
8591
- return this.http.get(`/api/agents/${encodePathParam(agentId)}/events`);
8591
+ return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}/events`);
8592
8592
  }
8593
8593
  /** Get agent balances across chains */
8594
8594
  async getBalances(agentId) {
8595
- return this.http.get(`/api/agents/${encodePathParam(agentId)}/balances`);
8595
+ return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}/balances`);
8596
8596
  }
8597
8597
  /** Approve a pending agent operation */
8598
8598
  async approve(agentId, operationId) {
8599
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/approve/${encodePathParam(operationId)}`, {});
8599
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/approve/${encodePathParam(operationId)}`, {});
8600
8600
  }
8601
8601
  /** Reject a pending agent operation */
8602
8602
  async reject(agentId, operationId) {
8603
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/reject/${encodePathParam(operationId)}`, {});
8603
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/reject/${encodePathParam(operationId)}`, {});
8604
8604
  }
8605
8605
  };
8606
8606
 
@@ -8628,7 +8628,56 @@ var DeploymentClient = class {
8628
8628
  * {@link deploy} with the pushed image tag.
8629
8629
  */
8630
8630
  async init(request) {
8631
- return this.http.post("/api/deployment/apps/init", request);
8631
+ return this.http.post("/api/v3/baas/deployment/apps/init", request);
8632
+ }
8633
+ /**
8634
+ * Issue ephemeral Harbor push credentials for a smart-app that ALREADY
8635
+ * EXISTS — the MINT-FIRST / DEPLOY-LAST credentials-push call.
8636
+ *
8637
+ * Unlike {@link init} (which historically allocated a fresh entity), this
8638
+ * takes the developer's pre-existing `appId` — the `SUBSCRIPTION_APP_ID`
8639
+ * minted by `hsuite subscribe` (`appId == DKG entityId`) — and ONLY
8640
+ * (re)provisions the per-app Harbor project + push robot. The server creates
8641
+ * no DKG entity and no subscription; it asserts the caller owns the app and
8642
+ * that its subscription is ACTIVE (402 otherwise) first.
8643
+ *
8644
+ * Returns the same `{ appId, registry }` shape as {@link init}. Single-use
8645
+ * secret discipline applies to `registry.password` exactly as in `init`.
8646
+ *
8647
+ * This is the credentials path the mint-first `hsuite deploy` uses to obtain
8648
+ * push creds for the developer's already-minted subscription app
8649
+ * (`POST /apps/:appId/credentials/push`). The `hsuite redeploy` re-push path
8650
+ * uses {@link reissuePushCredentials} instead, which targets a dedicated
8651
+ * `credentials/reissue` route with stricter SUSPENDED-app + Harbor-failure
8652
+ * handling.
8653
+ */
8654
+ async pushCredentials(appId) {
8655
+ return this.http.post(
8656
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/credentials/push`,
8657
+ {}
8658
+ );
8659
+ }
8660
+ /**
8661
+ * Reissue ephemeral Harbor push credentials for an EXISTING app, WITHOUT
8662
+ * allocating a new appId / entity. Unlike {@link init} — which historically
8663
+ * forked a fresh smart-app entity (and a fresh paid subscription) on every
8664
+ * call — this re-binds to an app the developer already owns: the `appId` is
8665
+ * echoed back unchanged and only a new single-use `registry.password` push
8666
+ * robot is minted. Same `{ appId, registry }` response shape as `init`.
8667
+ *
8668
+ * Owner-only + active-subscription gated server-side. This is the credential
8669
+ * path `hsuite redeploy` uses so a re-push does not cost a new entity +
8670
+ * subscription each run. Targets the dedicated
8671
+ * `POST /apps/:appId/credentials/reissue` route (distinct from
8672
+ * {@link pushCredentials}'s first-deploy `credentials/push`): the reissue
8673
+ * route additionally refuses SUSPENDED apps and surfaces Harbor failures
8674
+ * loudly rather than returning placeholder creds.
8675
+ */
8676
+ async reissuePushCredentials(appId) {
8677
+ return this.http.post(
8678
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/credentials/reissue`,
8679
+ {}
8680
+ );
8632
8681
  }
8633
8682
  /**
8634
8683
  * Step 3 (optional) — upload the SPA tarball.
@@ -8639,7 +8688,7 @@ var DeploymentClient = class {
8639
8688
  */
8640
8689
  async uploadFrontend(appId, bundle, filename = "bundle.tar.gz") {
8641
8690
  return this.http.upload(
8642
- `/api/deployment/apps/${encodePathParam(appId)}/frontend`,
8691
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/frontend`,
8643
8692
  bundle,
8644
8693
  filename,
8645
8694
  void 0,
@@ -8653,32 +8702,32 @@ var DeploymentClient = class {
8653
8702
  * until `runtime.runtimeState === 'RUNNING'` for the URL to be live.
8654
8703
  */
8655
8704
  async deploy(appId, request) {
8656
- return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/deploy`, request);
8705
+ return this.http.post(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/deploy`, request);
8657
8706
  }
8658
8707
  /**
8659
8708
  * Roll back to a previously-deployed image tag (must exist in
8660
8709
  * `runtime.deploymentHistory[]`).
8661
8710
  */
8662
8711
  async rollback(appId, request) {
8663
- return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/rollback`, request);
8712
+ return this.http.post(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/rollback`, request);
8664
8713
  }
8665
8714
  /**
8666
8715
  * Live combined lifecycle + runtime status of an app.
8667
8716
  */
8668
8717
  async status(appId) {
8669
- return this.http.get(`/api/deployment/apps/${encodePathParam(appId)}/status`);
8718
+ return this.http.get(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/status`);
8670
8719
  }
8671
8720
  /**
8672
8721
  * List all deployed apps for the authenticated developer.
8673
8722
  */
8674
8723
  async list() {
8675
- return this.http.get("/api/deployment/apps");
8724
+ return this.http.get("/api/v3/smart-apps");
8676
8725
  }
8677
8726
  /**
8678
8727
  * Get app details.
8679
8728
  */
8680
8729
  async get(appId) {
8681
- return this.http.get(`/api/deployment/apps/${encodePathParam(appId)}`);
8730
+ return this.http.get(`/api/v3/smart-apps/${encodePathParam(appId)}`);
8682
8731
  }
8683
8732
  /**
8684
8733
  * Update app configuration.
@@ -8688,31 +8737,31 @@ var DeploymentClient = class {
8688
8737
  * @returns The updated app info.
8689
8738
  */
8690
8739
  async update(appId, updates) {
8691
- return this.http.put(`/api/deployment/apps/${encodePathParam(appId)}`, updates);
8740
+ return this.http.put(`/api/v3/smart-apps/${encodePathParam(appId)}`, updates);
8692
8741
  }
8693
8742
  /**
8694
8743
  * Delete an app (runtime effect: namespace teardown).
8695
8744
  */
8696
8745
  async delete(appId) {
8697
- return this.http.delete(`/api/deployment/apps/${encodePathParam(appId)}`);
8746
+ return this.http.delete(`/api/v3/smart-apps/${encodePathParam(appId)}`);
8698
8747
  }
8699
8748
  /**
8700
8749
  * Suspend an app (runtime effect: scale to zero).
8701
8750
  */
8702
8751
  async suspend(appId) {
8703
- return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/suspend`, {});
8752
+ return this.http.post(`/api/v3/smart-apps/${encodePathParam(appId)}/suspend`, {});
8704
8753
  }
8705
8754
  /**
8706
8755
  * Resume a suspended app (runtime effect: scale back up).
8707
8756
  */
8708
8757
  async resume(appId) {
8709
- return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/resume`, {});
8758
+ return this.http.post(`/api/v3/smart-apps/${encodePathParam(appId)}/resume`, {});
8710
8759
  }
8711
8760
  /**
8712
8761
  * Get deployment statistics.
8713
8762
  */
8714
8763
  async getStats() {
8715
- return this.http.get("/api/deployment/stats");
8764
+ return this.http.get("/api/v3/smart-apps/stats");
8716
8765
  }
8717
8766
  /**
8718
8767
  * Register or update the developer-facing webhook URL for runtime
@@ -8733,7 +8782,7 @@ var DeploymentClient = class {
8733
8782
  * CGNAT / cloud metadata destinations (SSRF guard).
8734
8783
  */
8735
8784
  async setWebhook(appId, webhookUrl) {
8736
- return this.http.put(`/api/deployment/apps/${encodePathParam(appId)}/webhook`, {
8785
+ return this.http.put(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/webhook`, {
8737
8786
  webhookUrl
8738
8787
  });
8739
8788
  }
@@ -8749,7 +8798,7 @@ var DeploymentClient = class {
8749
8798
  * exposition format.
8750
8799
  */
8751
8800
  async getMetrics(appId) {
8752
- return this.http.getText(`/api/deployment/apps/${encodePathParam(appId)}/metrics`);
8801
+ return this.http.getText(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/metrics`);
8753
8802
  }
8754
8803
  /**
8755
8804
  * Rotate the smart-app's tenant-secret KEK.
@@ -8760,7 +8809,7 @@ var DeploymentClient = class {
8760
8809
  */
8761
8810
  async rotateKek(appId) {
8762
8811
  return this.http.post(
8763
- `/api/deployment/apps/${encodePathParam(appId)}/credentials/rotate-kek`,
8812
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/credentials/rotate-kek`,
8764
8813
  {}
8765
8814
  );
8766
8815
  }
@@ -8774,7 +8823,7 @@ var DeploymentClient = class {
8774
8823
  */
8775
8824
  async revokeKek(appId, version) {
8776
8825
  return this.http.post(
8777
- `/api/deployment/apps/${encodePathParam(appId)}/credentials/revoke-kek`,
8826
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/credentials/revoke-kek`,
8778
8827
  { version }
8779
8828
  );
8780
8829
  }
@@ -9011,7 +9060,7 @@ var SmartEngineClient = class _SmartEngineClient {
9011
9060
  baseUrl;
9012
9061
  allowInsecure;
9013
9062
  http;
9014
- /** Separate HTTP client for /api/transactions (non-v3 base path) */
9063
+ /** Separate HTTP client for /api/v3/transactions */
9015
9064
  txHttp;
9016
9065
  /** Last HTTP error (for getHttpHealth) */
9017
9066
  lastHttpError;
@@ -9072,7 +9121,7 @@ var SmartEngineClient = class _SmartEngineClient {
9072
9121
  timeout: config.timeout
9073
9122
  });
9074
9123
  this.txHttp = createHttpClient({
9075
- baseUrl: `${this.baseUrl}/api/transactions`,
9124
+ baseUrl: `${this.baseUrl}/api/v3/transactions`,
9076
9125
  apiKey: config.apiKey,
9077
9126
  authToken: config.authToken,
9078
9127
  timeout: config.timeout
@@ -9406,7 +9455,17 @@ var SmartEngineClient = class _SmartEngineClient {
9406
9455
  return this.http.get("/status");
9407
9456
  }
9408
9457
  // ========== Messaging Operations ==========
9409
- /** Submit a message to consensus */
9458
+ /**
9459
+ * Submit a message to consensus.
9460
+ *
9461
+ * @deprecated Operator-funded message submission is RETIRED on the validator
9462
+ * under transaction sovereignty — `POST /api/v3/messages/:chain/:topicId`
9463
+ * now returns `403 Forbidden` (the operator must never front the chain fee
9464
+ * for a customer-supplied message). Use the payer-funded prepare path
9465
+ * instead: prepare a topic-message transaction via
9466
+ * `POST /api/transactions/topic/message/prepare`, then have the payer sign
9467
+ * and submit the returned bytes.
9468
+ */
9410
9469
  async submitMessage(chain, topicId, message) {
9411
9470
  if (message.length > 1024 * 1024) {
9412
9471
  throw new SmartEngineError2("Message too large (max 1MB)", 400);
@@ -10295,7 +10354,7 @@ var DatabaseClient = class {
10295
10354
  async insert(collection, document) {
10296
10355
  const appId = this.getAppId();
10297
10356
  return this.http.post(
10298
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}`,
10357
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}`,
10299
10358
  document
10300
10359
  );
10301
10360
  }
@@ -10313,7 +10372,7 @@ var DatabaseClient = class {
10313
10372
  if (options?.sort) params.set("sort", options.sort);
10314
10373
  const qs = params.toString();
10315
10374
  return this.http.get(
10316
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}${qs ? `?${qs}` : ""}`
10375
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}${qs ? `?${qs}` : ""}`
10317
10376
  );
10318
10377
  }
10319
10378
  /**
@@ -10322,7 +10381,7 @@ var DatabaseClient = class {
10322
10381
  async update(collection, documentId, updates) {
10323
10382
  const appId = this.getAppId();
10324
10383
  return this.http.put(
10325
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`,
10384
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`,
10326
10385
  updates
10327
10386
  );
10328
10387
  }
@@ -10332,19 +10391,19 @@ var DatabaseClient = class {
10332
10391
  async delete(collection, documentId) {
10333
10392
  const appId = this.getAppId();
10334
10393
  return this.http.delete(
10335
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`
10394
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`
10336
10395
  );
10337
10396
  }
10338
10397
  /**
10339
10398
  * List collections for the app.
10340
10399
  *
10341
- * Server route is `/api/db/:appId/collections`
10400
+ * Server route is `/api/v3/baas/db/:appId/collections`
10342
10401
  * (`database.controller.ts:106`). The previous bare-`:appId` GET 404'd
10343
10402
  * — Nest reserves that pattern for the document-find router below.
10344
10403
  */
10345
10404
  async listCollections() {
10346
10405
  const appId = this.getAppId();
10347
- return this.http.get(`/api/db/${encodePathParam(appId)}/collections`);
10406
+ return this.http.get(`/api/v3/baas/db/${encodePathParam(appId)}/collections`);
10348
10407
  }
10349
10408
  /**
10350
10409
  * Create a new collection in the database.
@@ -10354,7 +10413,7 @@ var DatabaseClient = class {
10354
10413
  */
10355
10414
  async createCollection(name) {
10356
10415
  const appId = this.getAppId();
10357
- return this.http.post(`/api/db/${encodePathParam(appId)}/collections`, { name });
10416
+ return this.http.post(`/api/v3/baas/db/${encodePathParam(appId)}/collections`, { name });
10358
10417
  }
10359
10418
  /**
10360
10419
  * Drop a collection and all its documents.
@@ -10365,7 +10424,7 @@ var DatabaseClient = class {
10365
10424
  async dropCollection(name) {
10366
10425
  const appId = this.getAppId();
10367
10426
  return this.http.delete(
10368
- `/api/db/${encodePathParam(appId)}/collections/${encodePathParam(name)}`
10427
+ `/api/v3/baas/db/${encodePathParam(appId)}/collections/${encodePathParam(name)}`
10369
10428
  );
10370
10429
  }
10371
10430
  // ========== State Proofs ==========
@@ -10374,7 +10433,7 @@ var DatabaseClient = class {
10374
10433
  */
10375
10434
  async getStateRoot() {
10376
10435
  const appId = this.getAppId();
10377
- return this.http.get(`/api/db/${encodePathParam(appId)}/state/root`);
10436
+ return this.http.get(`/api/v3/baas/db/${encodePathParam(appId)}/state/root`);
10378
10437
  }
10379
10438
  /**
10380
10439
  * Get a Merkle proof for a specific document
@@ -10382,7 +10441,7 @@ var DatabaseClient = class {
10382
10441
  async getDocumentProof(documentId) {
10383
10442
  const appId = this.getAppId();
10384
10443
  return this.http.get(
10385
- `/api/db/${encodePathParam(appId)}/${encodePathParam(documentId)}/proof`
10444
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(documentId)}/proof`
10386
10445
  );
10387
10446
  }
10388
10447
  /**
@@ -10396,7 +10455,7 @@ var DatabaseClient = class {
10396
10455
  if (options?.limit !== void 0) params.set("limit", String(options.limit));
10397
10456
  const qs = params.toString();
10398
10457
  return this.http.get(
10399
- `/api/db/${encodePathParam(appId)}/state/transitions${qs ? `?${qs}` : ""}`
10458
+ `/api/v3/baas/db/${encodePathParam(appId)}/state/transitions${qs ? `?${qs}` : ""}`
10400
10459
  );
10401
10460
  }
10402
10461
  /**
@@ -10404,7 +10463,7 @@ var DatabaseClient = class {
10404
10463
  */
10405
10464
  async getDbStats() {
10406
10465
  const appId = this.getAppId();
10407
- return this.http.get(`/api/db/${encodePathParam(appId)}/stats`);
10466
+ return this.http.get(`/api/v3/baas/db/${encodePathParam(appId)}/stats`);
10408
10467
  }
10409
10468
  };
10410
10469
 
@@ -10421,28 +10480,28 @@ var StorageClient = class {
10421
10480
  */
10422
10481
  async upload(file, filename, metadata) {
10423
10482
  const appId = this.getAppId();
10424
- return this.http.upload(`/api/storage/${encodePathParam(appId)}/upload`, file, filename, metadata);
10483
+ return this.http.upload(`/api/v3/baas/storage/${encodePathParam(appId)}/upload`, file, filename, metadata);
10425
10484
  }
10426
10485
  /**
10427
10486
  * Download a file by CID
10428
10487
  */
10429
10488
  async download(cid) {
10430
10489
  const appId = this.getAppId();
10431
- return this.http.get(`/api/storage/${encodePathParam(appId)}/download/${encodePathParam(cid)}`);
10490
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/download/${encodePathParam(cid)}`);
10432
10491
  }
10433
10492
  /**
10434
10493
  * Get file metadata
10435
10494
  */
10436
10495
  async getMetadata(cid) {
10437
10496
  const appId = this.getAppId();
10438
- return this.http.get(`/api/storage/${encodePathParam(appId)}/metadata/${encodePathParam(cid)}`);
10497
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/metadata/${encodePathParam(cid)}`);
10439
10498
  }
10440
10499
  /**
10441
10500
  * Delete a file
10442
10501
  */
10443
10502
  async delete(cid) {
10444
10503
  const appId = this.getAppId();
10445
- return this.http.delete(`/api/storage/${encodePathParam(appId)}/${encodePathParam(cid)}`);
10504
+ return this.http.delete(`/api/v3/baas/storage/${encodePathParam(appId)}/${encodePathParam(cid)}`);
10446
10505
  }
10447
10506
  /**
10448
10507
  * List all files for the app.
@@ -10457,21 +10516,21 @@ var StorageClient = class {
10457
10516
  if (pagination?.limit !== void 0) params.set("limit", String(pagination.limit));
10458
10517
  if (pagination?.offset !== void 0) params.set("offset", String(pagination.offset));
10459
10518
  const qs = params.toString();
10460
- return this.http.get(`/api/storage/${encodePathParam(appId)}/files${qs ? `?${qs}` : ""}`);
10519
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/files${qs ? `?${qs}` : ""}`);
10461
10520
  }
10462
10521
  /**
10463
10522
  * Get storage usage for the current app
10464
10523
  */
10465
10524
  async getUsage() {
10466
10525
  const appId = this.getAppId();
10467
- return this.http.get(`/api/storage/${encodePathParam(appId)}/usage`);
10526
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/usage`);
10468
10527
  }
10469
10528
  /**
10470
10529
  * Check if a file exists
10471
10530
  */
10472
10531
  async exists(cid) {
10473
10532
  const appId = this.getAppId();
10474
- return this.http.get(`/api/storage/${encodePathParam(appId)}/exists/${encodePathParam(cid)}`);
10533
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/exists/${encodePathParam(cid)}`);
10475
10534
  }
10476
10535
  };
10477
10536
 
@@ -10488,7 +10547,7 @@ var FunctionsClient = class {
10488
10547
  */
10489
10548
  async deploy(request) {
10490
10549
  const appId = this.getAppId();
10491
- return this.http.post(`/api/functions/${encodePathParam(appId)}`, request);
10550
+ return this.http.post(`/api/v3/baas/functions/${encodePathParam(appId)}`, request);
10492
10551
  }
10493
10552
  /**
10494
10553
  * Invoke a function
@@ -10496,7 +10555,7 @@ var FunctionsClient = class {
10496
10555
  async invoke(functionId, payload) {
10497
10556
  const appId = this.getAppId();
10498
10557
  return this.http.post(
10499
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/invoke`,
10558
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/invoke`,
10500
10559
  payload ?? {}
10501
10560
  );
10502
10561
  }
@@ -10505,7 +10564,7 @@ var FunctionsClient = class {
10505
10564
  */
10506
10565
  async list() {
10507
10566
  const appId = this.getAppId();
10508
- return this.http.get(`/api/functions/${encodePathParam(appId)}`);
10567
+ return this.http.get(`/api/v3/baas/functions/${encodePathParam(appId)}`);
10509
10568
  }
10510
10569
  /**
10511
10570
  * Get function details
@@ -10513,7 +10572,7 @@ var FunctionsClient = class {
10513
10572
  async get(functionId) {
10514
10573
  const appId = this.getAppId();
10515
10574
  return this.http.get(
10516
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`
10575
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`
10517
10576
  );
10518
10577
  }
10519
10578
  /**
@@ -10522,7 +10581,7 @@ var FunctionsClient = class {
10522
10581
  async update(functionId, updates) {
10523
10582
  const appId = this.getAppId();
10524
10583
  return this.http.put(
10525
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
10584
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
10526
10585
  updates
10527
10586
  );
10528
10587
  }
@@ -10532,7 +10591,7 @@ var FunctionsClient = class {
10532
10591
  async delete(functionId) {
10533
10592
  const appId = this.getAppId();
10534
10593
  return this.http.delete(
10535
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`
10594
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`
10536
10595
  );
10537
10596
  }
10538
10597
  /**
@@ -10546,7 +10605,7 @@ var FunctionsClient = class {
10546
10605
  if (options?.level) params.set("level", options.level);
10547
10606
  const qs = params.toString();
10548
10607
  return this.http.get(
10549
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/logs${qs ? `?${qs}` : ""}`
10608
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/logs${qs ? `?${qs}` : ""}`
10550
10609
  );
10551
10610
  }
10552
10611
  /**
@@ -10554,7 +10613,7 @@ var FunctionsClient = class {
10554
10613
  */
10555
10614
  async getStats() {
10556
10615
  const appId = this.getAppId();
10557
- return this.http.get(`/api/functions/${encodePathParam(appId)}/stats`);
10616
+ return this.http.get(`/api/v3/baas/functions/${encodePathParam(appId)}/stats`);
10558
10617
  }
10559
10618
  };
10560
10619
 
@@ -10571,28 +10630,28 @@ var MessagingClient = class {
10571
10630
  */
10572
10631
  async createChannel(config) {
10573
10632
  const appId = this.getAppId();
10574
- return this.http.post(`/api/messaging/${encodePathParam(appId)}/channels`, config);
10633
+ return this.http.post(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels`, config);
10575
10634
  }
10576
10635
  /**
10577
10636
  * Delete a channel
10578
10637
  */
10579
10638
  async deleteChannel(channelId) {
10580
10639
  const appId = this.getAppId();
10581
- return this.http.delete(`/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`);
10640
+ return this.http.delete(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`);
10582
10641
  }
10583
10642
  /**
10584
10643
  * Get a channel by ID
10585
10644
  */
10586
10645
  async getChannel(channelId) {
10587
10646
  const appId = this.getAppId();
10588
- return this.http.get(`/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`);
10647
+ return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`);
10589
10648
  }
10590
10649
  /**
10591
10650
  * List all channels for the app
10592
10651
  */
10593
10652
  async listChannels() {
10594
10653
  const appId = this.getAppId();
10595
- return this.http.get(`/api/messaging/${encodePathParam(appId)}/channels`);
10654
+ return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels`);
10596
10655
  }
10597
10656
  /**
10598
10657
  * Publish a message to a channel
@@ -10600,7 +10659,7 @@ var MessagingClient = class {
10600
10659
  async publish(channel, message, metadata) {
10601
10660
  const appId = this.getAppId();
10602
10661
  return this.http.post(
10603
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/publish`,
10662
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/publish`,
10604
10663
  { data: message, metadata }
10605
10664
  );
10606
10665
  }
@@ -10615,7 +10674,7 @@ var MessagingClient = class {
10615
10674
  if (options?.after) params.set("after", options.after);
10616
10675
  const qs = params.toString();
10617
10676
  return this.http.get(
10618
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/history${qs ? `?${qs}` : ""}`
10677
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/history${qs ? `?${qs}` : ""}`
10619
10678
  );
10620
10679
  }
10621
10680
  /**
@@ -10629,7 +10688,7 @@ var MessagingClient = class {
10629
10688
  async setPresence(channel, member) {
10630
10689
  const appId = this.getAppId();
10631
10690
  return this.http.post(
10632
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`,
10691
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`,
10633
10692
  member
10634
10693
  );
10635
10694
  }
@@ -10637,7 +10696,7 @@ var MessagingClient = class {
10637
10696
  * Remove a member's presence from a channel.
10638
10697
  *
10639
10698
  * BREAKING CHANGE (SDK 3.3.0): server route is
10640
- * `/api/messaging/:appId/channels/:channel/presence/:clientId`
10699
+ * `/api/v3/baas/messaging/:appId/channels/:channel/presence/:clientId`
10641
10700
  * (`messaging.controller.ts:352`). `channel` is now the first arg and
10642
10701
  * `clientId` (not `memberId`) the second — they're the same identifier
10643
10702
  * but renamed to match the server param.
@@ -10645,7 +10704,7 @@ var MessagingClient = class {
10645
10704
  async removePresence(channel, clientId) {
10646
10705
  const appId = this.getAppId();
10647
10706
  return this.http.delete(
10648
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence/${encodePathParam(clientId)}`
10707
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence/${encodePathParam(clientId)}`
10649
10708
  );
10650
10709
  }
10651
10710
  /**
@@ -10654,7 +10713,7 @@ var MessagingClient = class {
10654
10713
  async getPresence(channel) {
10655
10714
  const appId = this.getAppId();
10656
10715
  return this.http.get(
10657
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`
10716
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`
10658
10717
  );
10659
10718
  }
10660
10719
  /**
@@ -10662,7 +10721,7 @@ var MessagingClient = class {
10662
10721
  */
10663
10722
  async getStats() {
10664
10723
  const appId = this.getAppId();
10665
- return this.http.get(`/api/messaging/${encodePathParam(appId)}/stats`);
10724
+ return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/stats`);
10666
10725
  }
10667
10726
  };
10668
10727
 
@@ -10678,21 +10737,21 @@ var CustomerSessionClient = class {
10678
10737
  * Step 1: ask the host to issue a fresh challenge for the customer to sign.
10679
10738
  */
10680
10739
  async challenge(input) {
10681
- return this.fetch("POST", "/api/customer-session/challenge", input);
10740
+ return this.fetch("POST", "/api/v3/baas/customer-session/challenge", input);
10682
10741
  }
10683
10742
  /**
10684
10743
  * Step 2: submit the customer's signed challenge. On success returns a
10685
10744
  * short-lived bearer JWT scoped to {appId, chain, address}.
10686
10745
  */
10687
10746
  async verify(req) {
10688
- return this.fetch("POST", "/api/customer-session/verify", req);
10747
+ return this.fetch("POST", "/api/v3/baas/customer-session/verify", req);
10689
10748
  }
10690
10749
  /**
10691
10750
  * Validate a customer bearer + return the decoded session info. Used by
10692
10751
  * smart-app backends to authorise incoming customer requests.
10693
10752
  */
10694
10753
  async validate(bearer) {
10695
- return this.fetch("GET", "/api/customer-session/validate", void 0, bearer);
10754
+ return this.fetch("GET", "/api/v3/baas/customer-session/validate", void 0, bearer);
10696
10755
  }
10697
10756
  /**
10698
10757
  * Revoke a customer session. Idempotent.
@@ -10700,7 +10759,7 @@ var CustomerSessionClient = class {
10700
10759
  async end(bearer) {
10701
10760
  return this.fetch(
10702
10761
  "POST",
10703
- "/api/customer-session/end",
10762
+ "/api/v3/baas/customer-session/end",
10704
10763
  void 0,
10705
10764
  bearer
10706
10765
  );
@@ -10746,15 +10805,15 @@ var RulesClient = class {
10746
10805
  http;
10747
10806
  /** Publish a canonical ValidatorRules document to HCS. */
10748
10807
  async publish(rule) {
10749
- return this.http.post("/api/rules/publish", rule);
10808
+ return this.http.post("/api/v3/baas/rules/publish", rule);
10750
10809
  }
10751
10810
  /** Fetch a published rule by its HCS consensus timestamp. */
10752
10811
  async get(consensusTimestamp) {
10753
- return this.http.get(`/api/rules/${encodePathParam(consensusTimestamp)}`);
10812
+ return this.http.get(`/api/v3/baas/rules/${encodePathParam(consensusTimestamp)}`);
10754
10813
  }
10755
10814
  /** List rules owned by the authenticated entity, optionally filtered by type. */
10756
10815
  async listByOwner(filter) {
10757
- const path = filter?.type ? `/api/rules?type=${encodeURIComponent(filter.type)}` : "/api/rules";
10816
+ const path = filter?.type ? `/api/v3/baas/rules?type=${encodeURIComponent(filter.type)}` : "/api/v3/baas/rules";
10758
10817
  return this.http.get(path);
10759
10818
  }
10760
10819
  /**
@@ -10762,44 +10821,332 @@ var RulesClient = class {
10762
10821
  * `ruleRef` (published) or `rule` (inline) must be supplied by the caller.
10763
10822
  */
10764
10823
  async simulate(params) {
10765
- return this.http.post("/api/rules/simulate", params);
10824
+ return this.http.post("/api/v3/baas/rules/simulate", params);
10766
10825
  }
10767
10826
  /** Walk the version history of a published rule. */
10768
10827
  async getVersionHistory(consensusTimestamp) {
10769
10828
  return this.http.get(
10770
- `/api/rules/${encodePathParam(consensusTimestamp)}/versions`
10829
+ `/api/v3/baas/rules/${encodePathParam(consensusTimestamp)}/versions`
10771
10830
  );
10772
10831
  }
10773
10832
  /** Deprecate a published rule (owner-only). */
10774
10833
  async deprecate(consensusTimestamp) {
10775
10834
  return this.http.post(
10776
- `/api/rules/${encodePathParam(consensusTimestamp)}/deprecate`,
10835
+ `/api/v3/baas/rules/${encodePathParam(consensusTimestamp)}/deprecate`,
10777
10836
  {}
10778
10837
  );
10779
10838
  }
10780
10839
  };
10781
10840
 
10782
10841
  // src/baas/entities/client.ts
10783
- var EntitiesClient = class {
10842
+ var EntitiesClient = class _EntitiesClient {
10784
10843
  constructor(http) {
10785
10844
  this.http = http;
10786
10845
  }
10787
10846
  http;
10788
- /** Create a canonical token entity bound to a published rule. */
10847
+ /**
10848
+ * Chains whose token-create routes through the payer-funded 3-step (prepare →
10849
+ * fund → execute), mirroring `createAccount`. Hedera = real HTS TokenCreate
10850
+ * (admin/supply = the per-entity DKG slot-pubkey KeyList; treasury = the
10851
+ * entity's own account; `0.0.X` token id is network-assigned, resolved from the
10852
+ * receipt via the threaded `createTxId`). Cardano/Solana/Polkadot = the
10853
+ * AUTHORITY entity (the entity IS the policy/mint/Assets-admin multisig — same
10854
+ * address as an account; the asset MINT itself is a later operate-tab payer
10855
+ * call). XRPL/Stellar token = an ISSUER ACCOUNT (reuses the account preparer) +
10856
+ * issuer flags set at finalize: XRPL relays the funding Payment then finalizes
10857
+ * (issuer-flag AccountSets + SignerListSet + disable-master); Stellar relays the
10858
+ * CreateAccount then finalizes (SetOptions install incl. issuer setFlags +
10859
+ * master lock). Every OTHER chain (EVM) stays on the legacy synchronous path.
10860
+ */
10861
+ static PAYER_FUNDED_TOKEN_CHAINS = /* @__PURE__ */ new Set([
10862
+ "hedera",
10863
+ "cardano",
10864
+ "solana",
10865
+ "polkadot",
10866
+ "xrpl",
10867
+ "stellar"
10868
+ ]);
10869
+ /**
10870
+ * PREPARE half of the payer-funded token-create flow.
10871
+ *
10872
+ * POSTs `/api/v3/baas/entities/prepare-create` with `entityType: 'token'`. The cluster
10873
+ * runs the per-entity DKG, builds the payer-funded create (Hedera: TokenCreate
10874
+ * keyed by the slot-pubkey KeyList with the entity account as treasury;
10875
+ * Cardano/Solana/Polkadot: funds/provisions the authority multisig), and returns
10876
+ * the prepared blob. The prepared `transactionId` is the `createTxId` for
10877
+ * execute (Hedera).
10878
+ */
10879
+ async prepareCreateToken(req) {
10880
+ return this.http.post("/api/v3/baas/entities/prepare-create", {
10881
+ entityType: "token",
10882
+ ...req
10883
+ });
10884
+ }
10885
+ /**
10886
+ * EXECUTE half of the payer-funded token-create flow.
10887
+ *
10888
+ * POSTs `/api/v3/baas/entities/execute-create` with `entityType: 'token'`. For Hedera,
10889
+ * pass `createTxId` (the prepared create's `transactionId`) so the validator
10890
+ * resolves the network-assigned `0.0.X` token id from the receipt and stamps
10891
+ * `chainAccounts.hedera`. For the authority-entity chains (cardano/solana/
10892
+ * polkadot) execute just verifies the binding and echoes the stamped authority
10893
+ * address (no `createTxId` needed).
10894
+ */
10895
+ async executeCreateToken(req) {
10896
+ const { createTxId, signedFundingBlob, ...rest } = req;
10897
+ return this.http.post("/api/v3/baas/entities/execute-create", {
10898
+ ...rest,
10899
+ ...createTxId !== void 0 ? { createTxId } : {},
10900
+ ...signedFundingBlob !== void 0 ? { signedFundingBlob } : {},
10901
+ entityType: "token"
10902
+ });
10903
+ }
10904
+ /**
10905
+ * Create a canonical token entity bound to a published rule.
10906
+ *
10907
+ * Dispatches by `chain` (mirrors `createAccount`):
10908
+ * - **Hedera / Cardano / Solana / Polkadot** = payer-funded 3-step (prepare →
10909
+ * caller funds via `fundWith` → execute). Hedera resolves the network-assigned
10910
+ * `0.0.X` token id from the receipt (threads `createTxId`); the authority-
10911
+ * entity chains verify/echo the stamped authority address. `fundWith` is
10912
+ * REQUIRED; to drive the steps manually call `prepareCreateToken` /
10913
+ * `executeCreateToken` directly.
10914
+ * - **XRPL / Stellar** = payer-funded too (account-model issuer): `fundWith`
10915
+ * REQUIRED; the caller's signed funding blob is RELAYED to the validator,
10916
+ * which submits it then finalizes the issuer multisig (master-locked). NO
10917
+ * issuer flags are set at create — issuer auth flags / DefaultRipple / clawback
10918
+ * are an operate-tab, rules-validated concern.
10919
+ * - **EVM / other** = legacy synchronous `POST /api/v3/baas/entities/createToken`
10920
+ * (payer-funded-only fields ignored) until it migrates.
10921
+ */
10789
10922
  async createToken(req) {
10790
- return this.http.post("/api/entities/createToken", req);
10923
+ if (_EntitiesClient.PAYER_FUNDED_TOKEN_CHAINS.has(req.chain)) {
10924
+ const { fundWith, ...prepReq } = req;
10925
+ const prep = await this.prepareCreateToken(prepReq);
10926
+ if (!fundWith) {
10927
+ throw new Error(
10928
+ `createToken(${req.chain}): pass fundWith (sign+submit the prepared create tx), or call prepareCreateToken/executeCreateToken directly`
10929
+ );
10930
+ }
10931
+ const funded = await fundWith(prep.prepared, {
10932
+ address: prep.address,
10933
+ reserveRequirement: prep.reserveRequirement
10934
+ });
10935
+ return this.executeCreateToken({
10936
+ entityId: prep.entityId,
10937
+ chain: req.chain,
10938
+ securityMode: req.securityMode,
10939
+ signedFundingBlob: _EntitiesClient.FUNDING_BLOB_RELAY_CHAINS.has(req.chain) ? funded?.signedFundingBlob : void 0,
10940
+ createTxId: req.chain === "hedera" ? prep.prepared?.[0]?.transactionId : void 0
10941
+ });
10942
+ }
10943
+ const {
10944
+ fundWith: _ignoredFundWith,
10945
+ payerAccountId: _ignoredPayer,
10946
+ securityMode: _ignoredSecurityMode,
10947
+ ...legacyReq
10948
+ } = req;
10949
+ return this.http.post("/api/v3/baas/entities/createToken", legacyReq);
10950
+ }
10951
+ /**
10952
+ * PREPARE half of the payer-funded account-create flow.
10953
+ *
10954
+ * POSTs `/api/v3/baas/entities/prepare-create`. The cluster runs the per-entity DKG
10955
+ * (persists the binding, submits nothing on-chain) and returns the unsigned
10956
+ * payer-funding `Payment`(s) the caller signs + submits with their own wallet.
10957
+ */
10958
+ async prepareCreateAccount(req) {
10959
+ return this.http.post("/api/v3/baas/entities/prepare-create", {
10960
+ entityType: "account",
10961
+ ...req
10962
+ });
10791
10963
  }
10792
- /** Create a canonical account entity bound to a published rule. */
10964
+ /**
10965
+ * EXECUTE half of the payer-funded account-create flow.
10966
+ *
10967
+ * POSTs `/api/v3/baas/entities/execute-create`. The entity already exists (its DKG
10968
+ * ran during prepare); pass `signedFundingBlob` for the validator to submit
10969
+ * the payer's signed funding `Payment` (XRPL only), or omit it when the caller
10970
+ * already submitted the funding tx themselves (then execute just finalizes /
10971
+ * verifies).
10972
+ *
10973
+ * `createTxId` is the HEDERA thread: a Hedera AccountCreate gets its
10974
+ * network-assigned `0.0.X` id only from the on-chain receipt after the payer
10975
+ * submits. The caller threads the prepared create's `transactionId` (from
10976
+ * `prepared[0].transactionId`) back here so the validator resolves the id from
10977
+ * the receipt server-side. Ignored for non-Hedera chains.
10978
+ */
10979
+ async executeCreateAccount(req) {
10980
+ const { createTxId, ...rest } = req;
10981
+ return this.http.post("/api/v3/baas/entities/execute-create", {
10982
+ ...rest,
10983
+ ...createTxId !== void 0 ? { createTxId } : {}
10984
+ });
10985
+ }
10986
+ /**
10987
+ * Chains whose account-create routes through the payer-funded 3-step
10988
+ * (prepare → fund → execute). All are ledgers where the validators never pay:
10989
+ * XRPL funds a reserve; Bitcoin funds a P2WSH UTXO; Cardano funds a
10990
+ * native-script enterprise address above min-UTXO; Polkadot funds a
10991
+ * pallet_multisig SS58 above the existential deposit; Solana funds a Squads
10992
+ * multisig PDA (deterministic from the createKey) via a payer-paid
10993
+ * `multisigCreateV2` — the payer's submission IS the create (no separate
10994
+ * finalizer). Hedera is create-WITH-KEY: the payer submits an AccountCreate
10995
+ * whose controlling key is the per-entity DKG slot-pubkey KeyList, so the
10996
+ * payer's submit IS the create; its `0.0.X` id is network-assigned (resolved
10997
+ * from the receipt at execute-create via the threaded `createTxId`). Stellar is
10998
+ * account-MODEL (like XRPL): the payer funds the entity's slot-0 `G...` master
10999
+ * via a CreateAccount, the validator RELAYS the signed funding blob, then
11000
+ * execute-create finalizes on-chain (threshold-signs a SetOptions installing
11001
+ * the validator chain-key multisig + locking the master). EVM stays on the
11002
+ * legacy synchronous create until it migrates.
11003
+ */
11004
+ static PAYER_FUNDED_CREATE_CHAINS = /* @__PURE__ */ new Set([
11005
+ "xrpl",
11006
+ "bitcoin",
11007
+ "cardano",
11008
+ "polkadot",
11009
+ "solana",
11010
+ "hedera",
11011
+ "stellar"
11012
+ ]);
11013
+ /**
11014
+ * Chains whose execute-create RELAYS the payer's signed funding blob for the
11015
+ * validator to submit (then finalizes on-chain). Both are account-model ledgers
11016
+ * with a validator-side finalize step: XRPL (SignerListSet + disable-master),
11017
+ * Stellar (SetOptions install + master lock). Every OTHER payer-funded chain
11018
+ * has the PAYER submit the funding tx directly with their own wallet — their
11019
+ * execute-create REJECTS a non-undefined `signedFundingBlob` (400), so the blob
11020
+ * is omitted for them.
11021
+ */
11022
+ static FUNDING_BLOB_RELAY_CHAINS = /* @__PURE__ */ new Set(["xrpl", "stellar"]);
11023
+ /**
11024
+ * Create a canonical account entity bound to a published rule.
11025
+ *
11026
+ * Dispatches by `chain`:
11027
+ * - **XRPL / Stellar / Bitcoin / Cardano / Polkadot / Solana / Hedera** =
11028
+ * payer-funded 3-step (prepare → fund → execute). The cluster runs the
11029
+ * per-entity DKG and returns the unsigned payer-funding tx(s); the
11030
+ * caller-supplied `fundWith` callback signs + submits (or just signs) the
11031
+ * funding tx with their OWN wallet — the SDK never holds the customer's chain
11032
+ * key nor opens a network connection — then `executeCreateAccount` finalizes
11033
+ * (XRPL + Stellar finalize on-chain after relaying the funding blob; the
11034
+ * deterministic ledgers + Solana verify/stamp the binding; Hedera resolves
11035
+ * the network-assigned id from the receipt). `fundWith` is REQUIRED on these
11036
+ * chains; to drive the steps manually call `prepareCreateAccount` /
11037
+ * `executeCreateAccount` directly.
11038
+ * - **other chains** (EVM) = legacy synchronous create — a single
11039
+ * `POST /api/v3/baas/entities/createAccount`, unchanged from pre-3.9.0. These chains
11040
+ * migrate to the payer-funded flow in a later phase; until then the
11041
+ * payer-funded-only fields (`fundWith` / `payerAccountId` / `securityMode`)
11042
+ * are ignored.
11043
+ */
10793
11044
  async createAccount(req) {
10794
- return this.http.post("/api/entities/createAccount", req);
11045
+ if (_EntitiesClient.PAYER_FUNDED_CREATE_CHAINS.has(req.chain)) {
11046
+ const { fundWith, ...prepReq } = req;
11047
+ const prep = await this.prepareCreateAccount(prepReq);
11048
+ if (!fundWith) {
11049
+ throw new Error(
11050
+ `createAccount(${req.chain}): pass fundWith (sign+submit the prepared funding tx), or call prepareCreateAccount/executeCreateAccount directly`
11051
+ );
11052
+ }
11053
+ const funded = await fundWith(prep.prepared, {
11054
+ address: prep.address,
11055
+ reserveRequirement: prep.reserveRequirement
11056
+ });
11057
+ return this.executeCreateAccount({
11058
+ entityId: prep.entityId,
11059
+ chain: req.chain,
11060
+ securityMode: req.securityMode,
11061
+ signedFundingBlob: _EntitiesClient.FUNDING_BLOB_RELAY_CHAINS.has(req.chain) ? funded?.signedFundingBlob : void 0,
11062
+ createTxId: req.chain === "hedera" ? prep.prepared?.[0]?.transactionId : void 0
11063
+ });
11064
+ }
11065
+ const {
11066
+ fundWith: _ignoredFundWith,
11067
+ payerAccountId: _ignoredPayer,
11068
+ securityMode: _ignoredSecurityMode,
11069
+ ...legacyReq
11070
+ } = req;
11071
+ return this.http.post("/api/v3/baas/entities/createAccount", legacyReq);
10795
11072
  }
10796
- /** Create a canonical topic entity bound to a published rule. */
11073
+ /**
11074
+ * PREPARE half of the payer-funded topic-create flow (Hedera).
11075
+ *
11076
+ * POSTs `/api/v3/baas/entities/prepare-create` with `entityType: 'topic'`. The cluster
11077
+ * runs the per-entity DKG (persists the binding), builds the payer-funded
11078
+ * TopicCreate keyed by the slot-pubkey KeyList, attaches the validator admin
11079
+ * threshold sig, and returns the prepared blob for the caller to add the fee
11080
+ * sig + submit. The prepared `transactionId` is the `createTxId` for execute.
11081
+ */
11082
+ async prepareCreateTopic(req) {
11083
+ return this.http.post("/api/v3/baas/entities/prepare-create", {
11084
+ entityType: "topic",
11085
+ ...req
11086
+ });
11087
+ }
11088
+ /**
11089
+ * EXECUTE half of the payer-funded topic-create flow (Hedera).
11090
+ *
11091
+ * POSTs `/api/v3/baas/entities/execute-create` with `entityType: 'topic'`. The topic
11092
+ * already exists once the payer submitted the create tx; pass `createTxId` (the
11093
+ * prepared create's `transactionId`) so the validator resolves the network-
11094
+ * assigned `0.0.X` topic id from the receipt and stamps `chainAccounts.hedera`.
11095
+ */
11096
+ async executeCreateTopic(req) {
11097
+ return this.http.post("/api/v3/baas/entities/execute-create", {
11098
+ ...req,
11099
+ entityType: "topic"
11100
+ });
11101
+ }
11102
+ /**
11103
+ * Create a canonical topic entity bound to a published rule.
11104
+ *
11105
+ * Dispatches by `chain`:
11106
+ * - **Hedera** = payer-funded 3-step (prepare → caller submits the TopicCreate
11107
+ * via `fundWith` → execute resolves the `0.0.X` topic id from the receipt).
11108
+ * `fundWith` is REQUIRED; to drive the steps manually call
11109
+ * `prepareCreateTopic` / `executeCreateTopic` directly.
11110
+ * - **other chains** = legacy synchronous `POST /api/v3/baas/entities/createTopic`
11111
+ * (topics are a Hedera primitive; the legacy path is unchanged).
11112
+ */
10797
11113
  async createTopic(req) {
10798
- return this.http.post("/api/entities/createTopic", req);
11114
+ if (req.chain === "hedera") {
11115
+ const { fundWith, ...prepReq } = req;
11116
+ const prep = await this.prepareCreateTopic(prepReq);
11117
+ if (!fundWith) {
11118
+ throw new Error(
11119
+ "createTopic(hedera): pass fundWith (sign+submit the prepared TopicCreate), or call prepareCreateTopic/executeCreateTopic directly"
11120
+ );
11121
+ }
11122
+ await fundWith(prep.prepared, {
11123
+ address: prep.address,
11124
+ reserveRequirement: prep.reserveRequirement
11125
+ });
11126
+ const createTxId = prep.prepared?.[0]?.transactionId;
11127
+ if (!createTxId) {
11128
+ throw new Error(
11129
+ "createTopic(hedera): prepared TopicCreate carries no transactionId \u2014 cannot resolve the topic id from the receipt"
11130
+ );
11131
+ }
11132
+ return this.executeCreateTopic({
11133
+ entityId: prep.entityId,
11134
+ chain: req.chain,
11135
+ createTxId,
11136
+ securityMode: req.securityMode
11137
+ });
11138
+ }
11139
+ const {
11140
+ fundWith: _ignoredFundWith,
11141
+ payerAccountId: _ignoredPayer,
11142
+ securityMode: _ignoredSecurityMode,
11143
+ ...legacyReq
11144
+ } = req;
11145
+ return this.http.post("/api/v3/baas/entities/createTopic", legacyReq);
10799
11146
  }
10800
11147
  /** Create a canonical agent entity bound to a published rule. */
10801
11148
  async createAgent(req) {
10802
- return this.http.post("/api/entities/createAgent", req);
11149
+ return this.http.post("/api/v3/baas/entities/createAgent", req);
10803
11150
  }
10804
11151
  /**
10805
11152
  * Mega-helper: build a token rule with a launchpad ModuleEntry attached,
@@ -10807,15 +11154,15 @@ var EntitiesClient = class {
10807
11154
  * round-trip.
10808
11155
  */
10809
11156
  async launchpad(req) {
10810
- return this.http.post("/api/entities/launchpad", req);
11157
+ return this.http.post("/api/v3/baas/entities/launchpad", req);
10811
11158
  }
10812
11159
  /** Fetch an entity by its canonical `entityId`. */
10813
11160
  async get(entityId) {
10814
- return this.http.get(`/api/entities/${encodePathParam(entityId)}`);
11161
+ return this.http.get(`/api/v3/baas/entities/${encodePathParam(entityId)}`);
10815
11162
  }
10816
11163
  /** List entities owned by the authenticated wallet, optionally filtered by type. */
10817
11164
  async listByOwner(filter) {
10818
- const path = filter?.type ? `/api/entities?type=${encodeURIComponent(filter.type)}` : "/api/entities";
11165
+ const path = filter?.type ? `/api/v3/baas/entities?type=${encodeURIComponent(filter.type)}` : "/api/v3/baas/entities";
10819
11166
  return this.http.get(path);
10820
11167
  }
10821
11168
  };
@@ -10828,6 +11175,13 @@ var BaasClient = class _BaasClient {
10828
11175
  timeout;
10829
11176
  allowInsecure;
10830
11177
  http;
11178
+ /**
11179
+ * Validator-routed HTTP client for the `/api/v3/transactions/*` prepare/execute
11180
+ * surface — a SIBLING of `/host`, NOT under the `pathPrefix`. Rooted at the
11181
+ * raw gateway/ingress origin (`hostUrl`) so transactions reach the validator
11182
+ * even when BaaS traffic is gateway-routed at `/host/*`.
11183
+ */
11184
+ txHttp;
10831
11185
  /** Last HTTP error (for getHttpHealth) */
10832
11186
  lastHttpError;
10833
11187
  /**
@@ -10856,6 +11210,14 @@ var BaasClient = class _BaasClient {
10856
11210
  rules;
10857
11211
  /** Canonical entity authoring surface (token/account/topic/agent + launchpad). */
10858
11212
  entities;
11213
+ /**
11214
+ * Validator-routed transaction prepare/execute (sovereignty model). The
11215
+ * prepare endpoints accept an explicit `payerAccountId` for the session-less
11216
+ * payer path, OR carry the web3-auth session token for the JWT-wallet payer
11217
+ * path (kept in sync with the main client's token — see {@link authenticate}).
11218
+ * Targets `/api/v3/transactions/*`, a sibling of the `/host` BaaS surface.
11219
+ */
11220
+ transactions;
10859
11221
  constructor(config) {
10860
11222
  this.allowInsecure = config.allowInsecure ?? false;
10861
11223
  this.hostUrl = validateUrl2(config.hostUrl, this.allowInsecure);
@@ -10869,7 +11231,12 @@ var BaasClient = class _BaasClient {
10869
11231
  timeout: this.timeout,
10870
11232
  // Transparent session refresh: on a 401, re-run the challenge-response
10871
11233
  // with the retained signer and retry once. No-op until authenticate() has
10872
- // been called (authContext set). Excludes /api/auth/* (see http client).
11234
+ // been called (authContext set). Excludes /api/v3/{,baas/}auth/* (see http client).
11235
+ onUnauthorized: () => this.reauthenticate()
11236
+ });
11237
+ this.txHttp = createHttpClient({
11238
+ baseUrl: `${this.hostUrl.replace(/\/$/, "")}/api/v3/transactions`,
11239
+ timeout: this.timeout,
10873
11240
  onUnauthorized: () => this.reauthenticate()
10874
11241
  });
10875
11242
  const getAppId = () => this.requireAppId();
@@ -10882,6 +11249,7 @@ var BaasClient = class _BaasClient {
10882
11249
  this.customerSession = new CustomerSessionClient(baseUrlWithPrefix, this.timeout);
10883
11250
  this.rules = new RulesClient(this.http);
10884
11251
  this.entities = new EntitiesClient(this.http);
11252
+ this.transactions = new TransactionsClient(this.txHttp);
10885
11253
  }
10886
11254
  /**
10887
11255
  * Connect to the Smart Engines BaaS via cluster auto-discovery.
@@ -11009,7 +11377,7 @@ var BaasClient = class _BaasClient {
11009
11377
  this.authContext = options;
11010
11378
  let challenge;
11011
11379
  try {
11012
- challenge = await this.http.post("/api/auth/challenge", {
11380
+ challenge = await this.http.post("/api/v3/baas/auth/challenge", {
11013
11381
  chain,
11014
11382
  walletAddress,
11015
11383
  appId: this.appId
@@ -11020,7 +11388,7 @@ var BaasClient = class _BaasClient {
11020
11388
  const signature = await signFn(challenge.message);
11021
11389
  let result;
11022
11390
  try {
11023
- result = await this.http.post("/api/auth/verify", {
11391
+ result = await this.http.post("/api/v3/baas/auth/verify", {
11024
11392
  challengeId: challenge.challengeId,
11025
11393
  signature,
11026
11394
  publicKey
@@ -11029,6 +11397,7 @@ var BaasClient = class _BaasClient {
11029
11397
  throw asBaasError(err);
11030
11398
  }
11031
11399
  this.http.setAuthToken(result.token);
11400
+ this.txHttp.setAuthToken(result.token);
11032
11401
  return result;
11033
11402
  }
11034
11403
  /**
@@ -11036,30 +11405,31 @@ var BaasClient = class _BaasClient {
11036
11405
  * session token. Invoked by the http client's `onUnauthorized` hook when a
11037
11406
  * request 401s because the token expired — so long-lived clients keep working
11038
11407
  * 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
11408
+ * was never called. The `/api/v3/baas/auth/*` calls below are excluded from the http
11040
11409
  * client's 401-retry path, so this can never recurse.
11041
11410
  */
11042
11411
  async reauthenticate() {
11043
11412
  const ctx = this.authContext;
11044
11413
  if (!ctx) return;
11045
- const challenge = await this.http.post("/api/auth/challenge", {
11414
+ const challenge = await this.http.post("/api/v3/baas/auth/challenge", {
11046
11415
  chain: ctx.chain,
11047
11416
  walletAddress: ctx.walletAddress,
11048
11417
  appId: this.appId
11049
11418
  });
11050
11419
  const signature = await ctx.signFn(challenge.message);
11051
- const result = await this.http.post("/api/auth/verify", {
11420
+ const result = await this.http.post("/api/v3/baas/auth/verify", {
11052
11421
  challengeId: challenge.challengeId,
11053
11422
  signature,
11054
11423
  publicKey: ctx.publicKey
11055
11424
  });
11056
11425
  this.http.setAuthToken(result.token);
11426
+ this.txHttp.setAuthToken(result.token);
11057
11427
  }
11058
11428
  /** Validate the current session */
11059
11429
  async validateSession() {
11060
11430
  this.requireAuth();
11061
11431
  try {
11062
- return await this.http.get("/api/auth/session");
11432
+ return await this.http.get("/api/v3/baas/auth/session");
11063
11433
  } catch (err) {
11064
11434
  throw asBaasError(err);
11065
11435
  }
@@ -11068,11 +11438,12 @@ var BaasClient = class _BaasClient {
11068
11438
  async logout() {
11069
11439
  if (this.http.getAuthToken()) {
11070
11440
  try {
11071
- await this.http.post("/api/auth/logout", {});
11441
+ await this.http.post("/api/v3/baas/auth/logout", {});
11072
11442
  } catch {
11073
11443
  }
11074
11444
  }
11075
11445
  this.http.setAuthToken(void 0);
11446
+ this.txHttp.setAuthToken(void 0);
11076
11447
  }
11077
11448
  // ========== HTTP Helpers ==========
11078
11449
  requireAuth() {