@hsuite/smart-engines-sdk 3.6.1 → 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
@@ -78,11 +78,11 @@ var require_utils = __commonJS({
78
78
  u8Array[OriginalBuffer] = buffer;
79
79
  return u8Array;
80
80
  }
81
- var bytesToHex2 = (bytes) => {
81
+ var bytesToHex3 = (bytes) => {
82
82
  const buf = Buffer.from(bytes);
83
83
  return buf.toString("hex").toUpperCase();
84
84
  };
85
- exports.bytesToHex = bytesToHex2;
85
+ exports.bytesToHex = bytesToHex3;
86
86
  var hexToBytes2 = (hex) => {
87
87
  if (!shared_1.HEX_REGEX.test(hex)) {
88
88
  throw new Error("Invalid hex string");
@@ -479,7 +479,7 @@ var require_lib = __commonJS({
479
479
  return Uint8Array.from(res);
480
480
  }
481
481
  };
482
- var createBase58check = (sha2562) => /* @__PURE__ */ chain(checksum(4, (data) => sha2562(sha2562(data))), exports.base58);
482
+ var createBase58check = (sha2563) => /* @__PURE__ */ chain(checksum(4, (data) => sha2563(sha2563(data))), exports.base58);
483
483
  exports.createBase58check = createBase58check;
484
484
  exports.base58check = exports.createBase58check;
485
485
  var BECH_ALPHABET = /* @__PURE__ */ chain(/* @__PURE__ */ alphabet("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), /* @__PURE__ */ join(""));
@@ -3062,7 +3062,7 @@ var require_weierstrass = __commonJS({
3062
3062
  }
3063
3063
  return { seed, k2sig };
3064
3064
  }
3065
- function sign(message, secretKey, opts = {}) {
3065
+ function sign2(message, secretKey, opts = {}) {
3066
3066
  message = (0, utils_ts_1.ensureBytes)("message", message);
3067
3067
  const { seed, k2sig } = prepSig(message, secretKey, opts);
3068
3068
  const drbg = (0, utils_ts_1.createHmacDrbg)(hash.outputLen, Fn.BYTES, hmac);
@@ -3096,7 +3096,7 @@ var require_weierstrass = __commonJS({
3096
3096
  return false;
3097
3097
  return sig;
3098
3098
  }
3099
- function verify(signature, message, publicKey, opts = {}) {
3099
+ function verify2(signature, message, publicKey, opts = {}) {
3100
3100
  const { lowS, prehash, format } = validateSigOpts(opts, defaultSigOpts);
3101
3101
  publicKey = (0, utils_ts_1.ensureBytes)("publicKey", publicKey);
3102
3102
  message = validateMsgAndHash((0, utils_ts_1.ensureBytes)("message", message), prehash);
@@ -3135,8 +3135,8 @@ var require_weierstrass = __commonJS({
3135
3135
  utils,
3136
3136
  lengths,
3137
3137
  Point,
3138
- sign,
3139
- verify,
3138
+ sign: sign2,
3139
+ verify: verify2,
3140
3140
  recoverPublicKey,
3141
3141
  Signature,
3142
3142
  hash
@@ -4326,7 +4326,7 @@ var require_edwards = __commonJS({
4326
4326
  const msg = (0, utils_ts_1.concatBytes)(...msgs);
4327
4327
  return modN_LE(cHash(domain(msg, (0, utils_ts_1.ensureBytes)("context", context), !!prehash)));
4328
4328
  }
4329
- function sign(msg, secretKey, options = {}) {
4329
+ function sign2(msg, secretKey, options = {}) {
4330
4330
  msg = (0, utils_ts_1.ensureBytes)("message", msg);
4331
4331
  if (prehash)
4332
4332
  msg = prehash(msg);
@@ -4341,7 +4341,7 @@ var require_edwards = __commonJS({
4341
4341
  return (0, utils_ts_1._abytes2)(rs, lengths.signature, "result");
4342
4342
  }
4343
4343
  const verifyOpts = { zip215: true };
4344
- function verify(sig, msg, publicKey, options = verifyOpts) {
4344
+ function verify2(sig, msg, publicKey, options = verifyOpts) {
4345
4345
  const { context, zip215 } = options;
4346
4346
  const len = lengths.signature;
4347
4347
  sig = (0, utils_ts_1.ensureBytes)("signature", sig, len);
@@ -4431,8 +4431,8 @@ var require_edwards = __commonJS({
4431
4431
  return Object.freeze({
4432
4432
  keygen,
4433
4433
  getPublicKey,
4434
- sign,
4435
- verify,
4434
+ sign: sign2,
4435
+ verify: verify2,
4436
4436
  utils,
4437
4437
  Point,
4438
4438
  lengths
@@ -5053,7 +5053,7 @@ var require_dist2 = __commonJS({
5053
5053
  return (0, ripple_address_codec_1.encodeSeed)(entropy, type);
5054
5054
  }
5055
5055
  exports.generateSeed = generateSeed;
5056
- function deriveKeypair(seed, options) {
5056
+ function deriveKeypair2(seed, options) {
5057
5057
  var _a;
5058
5058
  const decoded = (0, ripple_address_codec_1.decodeSeed)(seed);
5059
5059
  const proposedAlgorithm = (_a = options === null || options === void 0 ? void 0 : options.algorithm) !== null && _a !== void 0 ? _a : decoded.type;
@@ -5067,27 +5067,27 @@ var require_dist2 = __commonJS({
5067
5067
  }
5068
5068
  return keypair;
5069
5069
  }
5070
- exports.deriveKeypair = deriveKeypair;
5071
- function sign(messageHex, privateKey) {
5070
+ exports.deriveKeypair = deriveKeypair2;
5071
+ function sign2(messageHex, privateKey) {
5072
5072
  const algorithm = (0, getAlgorithmFromKey_1.getAlgorithmFromPrivateKey)(privateKey);
5073
5073
  return getSigningScheme(algorithm).sign((0, utils_1.hexToBytes)(messageHex), privateKey);
5074
5074
  }
5075
- exports.sign = sign;
5076
- function verify(messageHex, signature, publicKey) {
5075
+ exports.sign = sign2;
5076
+ function verify2(messageHex, signature, publicKey) {
5077
5077
  const algorithm = (0, getAlgorithmFromKey_1.getAlgorithmFromPublicKey)(publicKey);
5078
5078
  return getSigningScheme(algorithm).verify((0, utils_1.hexToBytes)(messageHex), signature, publicKey);
5079
5079
  }
5080
- exports.verify = verify;
5080
+ exports.verify = verify2;
5081
5081
  function computePublicKeyHash(publicKeyBytes) {
5082
5082
  return (0, ripemd160_1.ripemd160)((0, sha256_1.sha256)(publicKeyBytes));
5083
5083
  }
5084
5084
  function deriveAddressFromBytes(publicKeyBytes) {
5085
5085
  return (0, ripple_address_codec_1.encodeAccountID)(computePublicKeyHash(publicKeyBytes));
5086
5086
  }
5087
- function deriveAddress(publicKey) {
5087
+ function deriveAddress2(publicKey) {
5088
5088
  return deriveAddressFromBytes((0, utils_1.hexToBytes)(publicKey));
5089
5089
  }
5090
- exports.deriveAddress = deriveAddress;
5090
+ exports.deriveAddress = deriveAddress2;
5091
5091
  function deriveNodeAddress(publicKey) {
5092
5092
  const generatorBytes = (0, ripple_address_codec_1.decodeNodePublic)(publicKey);
5093
5093
  const accountPublicBytes = (0, utils_2.accountPublicFromPublicGenerator)(generatorBytes);
@@ -5643,6 +5643,14 @@ var PreparedTransactionSovereigntySchema = zod.z.discriminatedUnion("mode", [
5643
5643
  authorizationSet: PreparedTransactionAuthorizationSetSchema.optional()
5644
5644
  })
5645
5645
  ]);
5646
+ var RuleRefSchema = zod.z.object({
5647
+ /** Chain whose HCS the rule was published on (canonically 'hedera'). */
5648
+ chain: ChainTypeSchema,
5649
+ /** HCS topic ID the rule message was published to. */
5650
+ topicId: zod.z.string().min(1),
5651
+ /** HCS consensus timestamp of the rule message. */
5652
+ consensusTimestamp: zod.z.string().min(1)
5653
+ });
5646
5654
  var CreateAccountRequestSchema = zod.z.object({
5647
5655
  chain: ChainTypeSchema,
5648
5656
  initialBalance: zod.z.string(),
@@ -5682,6 +5690,22 @@ var CreateAccountRequestSchema = zod.z.object({
5682
5690
  * The owner key + TSS network key form a threshold-2 multi-sig.
5683
5691
  */
5684
5692
  appOwnerPublicKey: zod.z.string().optional(),
5693
+ /**
5694
+ * The entity's canonical `ruleRef` (HCS pointer to its `ValidatorRules`). When
5695
+ * present, the chain adapter stamps the IMMUTABLE creation-tx rule anchor
5696
+ * (`rule:<topicId>@<consensusTimestamp>:<entityType>`) — distinct from the
5697
+ * mutable validator-binding memo — so the sign-gate resolves the rule on-chain
5698
+ * (kind:'ref') rather than trusting the replicated binding
5699
+ * (RFC 2026-06-15-onchain-rule-anchor §6.1). Absent ⇒ the degraded
5700
+ * `rule:bootstrap:<entityType>` marker when `entityType` is supplied.
5701
+ */
5702
+ ruleRef: RuleRefSchema.optional(),
5703
+ /**
5704
+ * Entity-type tag stamped into the rule anchor (e.g. 'wallet', 'account').
5705
+ * Supply it to enable the on-chain anchor; omit for the prior memo-less
5706
+ * (legacy) behaviour.
5707
+ */
5708
+ entityType: zod.z.string().min(1).optional(),
5685
5709
  metadata: zod.z.record(zod.z.any()).optional()
5686
5710
  });
5687
5711
  zod.z.object({
@@ -5769,6 +5793,21 @@ var CreateTokenRequestSchema = zod.z.object({
5769
5793
  immutable: zod.z.boolean().default(true),
5770
5794
  /** See CreateAccountRequestSchema.payerAccountId — same resolution rules. */
5771
5795
  payerAccountId: zod.z.string().optional(),
5796
+ /**
5797
+ * The entity's canonical `ruleRef` (HCS pointer to its `ValidatorRules`). When
5798
+ * present, the chain adapter stamps the IMMUTABLE creation-tx rule anchor
5799
+ * (`rule:<topicId>@<consensusTimestamp>:<entityType>`) — distinct from the
5800
+ * mutable validator-binding token memo — so the sign-gate resolves the rule
5801
+ * on-chain (kind:'ref') rather than trusting the replicated binding
5802
+ * (RFC 2026-06-15-onchain-rule-anchor §6.1). Absent ⇒ the degraded
5803
+ * `rule:bootstrap:<entityType>` marker when `entityType` is supplied.
5804
+ */
5805
+ ruleRef: RuleRefSchema.optional(),
5806
+ /**
5807
+ * Entity-type tag stamped into the rule anchor (e.g. 'token'). Supply it to
5808
+ * enable the on-chain anchor; omit for the prior memo-less behaviour.
5809
+ */
5810
+ entityType: zod.z.string().min(1).optional(),
5772
5811
  metadata: zod.z.record(zod.z.any()).optional()
5773
5812
  });
5774
5813
  zod.z.object({
@@ -6706,7 +6745,7 @@ function createHttpClient(config) {
6706
6745
  try {
6707
6746
  return await op();
6708
6747
  } catch (error) {
6709
- 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;
6710
6749
  if (!refreshable) throw error;
6711
6750
  if (!reauthInFlight) {
6712
6751
  reauthInFlight = Promise.resolve(config.onUnauthorized()).finally(() => {
@@ -7690,7 +7729,7 @@ var HederaTransactionsClient = class {
7690
7729
  * - `client.hedera.tss.createTopic(...)` makes the cluster sign+submit in one call.
7691
7730
  *
7692
7731
  * `tssHttp` is the validator's `/api/v3`-rooted HTTP client (different from
7693
- * the `/api/transactions` one this class uses for prepare paths). Both
7732
+ * the `/api/v3/transactions` one this class uses for prepare paths). Both
7694
7733
  * clients are required — the previous single-arg fallback to `http` was
7695
7734
  * unreachable through `SmartEngineClient` (the only call site always
7696
7735
  * passes both).
@@ -8492,15 +8531,15 @@ var AgentsClient = class {
8492
8531
  http;
8493
8532
  /** Register a new agent */
8494
8533
  async register(request) {
8495
- return this.http.post("/api/agents/register", request);
8534
+ return this.http.post("/api/v3/baas/agents/register", request);
8496
8535
  }
8497
8536
  /** Get agent details */
8498
8537
  async get(agentId) {
8499
- return this.http.get(`/api/agents/${encodePathParam(agentId)}`);
8538
+ return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}`);
8500
8539
  }
8501
8540
  /** List all agents */
8502
8541
  async list() {
8503
- return this.http.get("/api/agents");
8542
+ return this.http.get("/api/v3/baas/agents");
8504
8543
  }
8505
8544
  /**
8506
8545
  * Fund agent treasury (owner-only). Returns a
@@ -8508,60 +8547,60 @@ var AgentsClient = class {
8508
8547
  * the caller is expected to sign and submit the prepared bytes.
8509
8548
  */
8510
8549
  async fund(agentId, request) {
8511
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/fund`, request);
8550
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/fund`, request);
8512
8551
  }
8513
8552
  /**
8514
8553
  * Execute a trade (agent-wallet OR owner). Returns a
8515
8554
  * `PreparedTransactionResponse` wrapped in a `success: true` envelope.
8516
8555
  */
8517
8556
  async trade(agentId, request) {
8518
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/trade`, request);
8557
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/trade`, request);
8519
8558
  }
8520
8559
  /**
8521
8560
  * Withdraw from agent treasury (owner-only). Returns a
8522
8561
  * `PreparedTransactionResponse` wrapped in a `success: true` envelope.
8523
8562
  */
8524
8563
  async withdraw(agentId, request) {
8525
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/withdraw`, request);
8564
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/withdraw`, request);
8526
8565
  }
8527
8566
  /** Pause an agent */
8528
8567
  async pause(agentId) {
8529
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/pause`, {});
8568
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/pause`, {});
8530
8569
  }
8531
8570
  /** Resume a paused agent */
8532
8571
  async resume(agentId) {
8533
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/resume`, {});
8572
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/resume`, {});
8534
8573
  }
8535
8574
  /** Revoke an agent (permanent) */
8536
8575
  async revoke(agentId) {
8537
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/revoke`, {});
8576
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/revoke`, {});
8538
8577
  }
8539
8578
  /**
8540
8579
  * Update agent rules.
8541
8580
  *
8542
- * Server route is PATCH `/api/agents/:agentId/rules`
8581
+ * Server route is PATCH `/api/v3/baas/agents/:agentId/rules`
8543
8582
  * (`agents.controller.ts:375`). The previous PUT variant 404'd because
8544
8583
  * Nest matched the dynamic `:agentId` GET/POST handlers and rejected
8545
8584
  * the verb mismatch.
8546
8585
  */
8547
8586
  async updateRules(agentId, rules) {
8548
- return this.http.patch(`/api/agents/${encodePathParam(agentId)}/rules`, rules);
8587
+ return this.http.patch(`/api/v3/baas/agents/${encodePathParam(agentId)}/rules`, rules);
8549
8588
  }
8550
8589
  /** Get agent events */
8551
8590
  async getEvents(agentId) {
8552
- return this.http.get(`/api/agents/${encodePathParam(agentId)}/events`);
8591
+ return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}/events`);
8553
8592
  }
8554
8593
  /** Get agent balances across chains */
8555
8594
  async getBalances(agentId) {
8556
- return this.http.get(`/api/agents/${encodePathParam(agentId)}/balances`);
8595
+ return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}/balances`);
8557
8596
  }
8558
8597
  /** Approve a pending agent operation */
8559
8598
  async approve(agentId, operationId) {
8560
- 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)}`, {});
8561
8600
  }
8562
8601
  /** Reject a pending agent operation */
8563
8602
  async reject(agentId, operationId) {
8564
- 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)}`, {});
8565
8604
  }
8566
8605
  };
8567
8606
 
@@ -8589,7 +8628,56 @@ var DeploymentClient = class {
8589
8628
  * {@link deploy} with the pushed image tag.
8590
8629
  */
8591
8630
  async init(request) {
8592
- 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
+ );
8593
8681
  }
8594
8682
  /**
8595
8683
  * Step 3 (optional) — upload the SPA tarball.
@@ -8600,7 +8688,7 @@ var DeploymentClient = class {
8600
8688
  */
8601
8689
  async uploadFrontend(appId, bundle, filename = "bundle.tar.gz") {
8602
8690
  return this.http.upload(
8603
- `/api/deployment/apps/${encodePathParam(appId)}/frontend`,
8691
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/frontend`,
8604
8692
  bundle,
8605
8693
  filename,
8606
8694
  void 0,
@@ -8614,32 +8702,32 @@ var DeploymentClient = class {
8614
8702
  * until `runtime.runtimeState === 'RUNNING'` for the URL to be live.
8615
8703
  */
8616
8704
  async deploy(appId, request) {
8617
- 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);
8618
8706
  }
8619
8707
  /**
8620
8708
  * Roll back to a previously-deployed image tag (must exist in
8621
8709
  * `runtime.deploymentHistory[]`).
8622
8710
  */
8623
8711
  async rollback(appId, request) {
8624
- 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);
8625
8713
  }
8626
8714
  /**
8627
8715
  * Live combined lifecycle + runtime status of an app.
8628
8716
  */
8629
8717
  async status(appId) {
8630
- return this.http.get(`/api/deployment/apps/${encodePathParam(appId)}/status`);
8718
+ return this.http.get(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/status`);
8631
8719
  }
8632
8720
  /**
8633
8721
  * List all deployed apps for the authenticated developer.
8634
8722
  */
8635
8723
  async list() {
8636
- return this.http.get("/api/deployment/apps");
8724
+ return this.http.get("/api/v3/smart-apps");
8637
8725
  }
8638
8726
  /**
8639
8727
  * Get app details.
8640
8728
  */
8641
8729
  async get(appId) {
8642
- return this.http.get(`/api/deployment/apps/${encodePathParam(appId)}`);
8730
+ return this.http.get(`/api/v3/smart-apps/${encodePathParam(appId)}`);
8643
8731
  }
8644
8732
  /**
8645
8733
  * Update app configuration.
@@ -8649,31 +8737,31 @@ var DeploymentClient = class {
8649
8737
  * @returns The updated app info.
8650
8738
  */
8651
8739
  async update(appId, updates) {
8652
- return this.http.put(`/api/deployment/apps/${encodePathParam(appId)}`, updates);
8740
+ return this.http.put(`/api/v3/smart-apps/${encodePathParam(appId)}`, updates);
8653
8741
  }
8654
8742
  /**
8655
8743
  * Delete an app (runtime effect: namespace teardown).
8656
8744
  */
8657
8745
  async delete(appId) {
8658
- return this.http.delete(`/api/deployment/apps/${encodePathParam(appId)}`);
8746
+ return this.http.delete(`/api/v3/smart-apps/${encodePathParam(appId)}`);
8659
8747
  }
8660
8748
  /**
8661
8749
  * Suspend an app (runtime effect: scale to zero).
8662
8750
  */
8663
8751
  async suspend(appId) {
8664
- return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/suspend`, {});
8752
+ return this.http.post(`/api/v3/smart-apps/${encodePathParam(appId)}/suspend`, {});
8665
8753
  }
8666
8754
  /**
8667
8755
  * Resume a suspended app (runtime effect: scale back up).
8668
8756
  */
8669
8757
  async resume(appId) {
8670
- return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/resume`, {});
8758
+ return this.http.post(`/api/v3/smart-apps/${encodePathParam(appId)}/resume`, {});
8671
8759
  }
8672
8760
  /**
8673
8761
  * Get deployment statistics.
8674
8762
  */
8675
8763
  async getStats() {
8676
- return this.http.get("/api/deployment/stats");
8764
+ return this.http.get("/api/v3/smart-apps/stats");
8677
8765
  }
8678
8766
  /**
8679
8767
  * Register or update the developer-facing webhook URL for runtime
@@ -8694,7 +8782,7 @@ var DeploymentClient = class {
8694
8782
  * CGNAT / cloud metadata destinations (SSRF guard).
8695
8783
  */
8696
8784
  async setWebhook(appId, webhookUrl) {
8697
- return this.http.put(`/api/deployment/apps/${encodePathParam(appId)}/webhook`, {
8785
+ return this.http.put(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/webhook`, {
8698
8786
  webhookUrl
8699
8787
  });
8700
8788
  }
@@ -8710,7 +8798,7 @@ var DeploymentClient = class {
8710
8798
  * exposition format.
8711
8799
  */
8712
8800
  async getMetrics(appId) {
8713
- return this.http.getText(`/api/deployment/apps/${encodePathParam(appId)}/metrics`);
8801
+ return this.http.getText(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/metrics`);
8714
8802
  }
8715
8803
  /**
8716
8804
  * Rotate the smart-app's tenant-secret KEK.
@@ -8721,7 +8809,7 @@ var DeploymentClient = class {
8721
8809
  */
8722
8810
  async rotateKek(appId) {
8723
8811
  return this.http.post(
8724
- `/api/deployment/apps/${encodePathParam(appId)}/credentials/rotate-kek`,
8812
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/credentials/rotate-kek`,
8725
8813
  {}
8726
8814
  );
8727
8815
  }
@@ -8735,7 +8823,7 @@ var DeploymentClient = class {
8735
8823
  */
8736
8824
  async revokeKek(appId, version) {
8737
8825
  return this.http.post(
8738
- `/api/deployment/apps/${encodePathParam(appId)}/credentials/revoke-kek`,
8826
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/credentials/revoke-kek`,
8739
8827
  { version }
8740
8828
  );
8741
8829
  }
@@ -8972,7 +9060,7 @@ var SmartEngineClient = class _SmartEngineClient {
8972
9060
  baseUrl;
8973
9061
  allowInsecure;
8974
9062
  http;
8975
- /** Separate HTTP client for /api/transactions (non-v3 base path) */
9063
+ /** Separate HTTP client for /api/v3/transactions */
8976
9064
  txHttp;
8977
9065
  /** Last HTTP error (for getHttpHealth) */
8978
9066
  lastHttpError;
@@ -9033,7 +9121,7 @@ var SmartEngineClient = class _SmartEngineClient {
9033
9121
  timeout: config.timeout
9034
9122
  });
9035
9123
  this.txHttp = createHttpClient({
9036
- baseUrl: `${this.baseUrl}/api/transactions`,
9124
+ baseUrl: `${this.baseUrl}/api/v3/transactions`,
9037
9125
  apiKey: config.apiKey,
9038
9126
  authToken: config.authToken,
9039
9127
  timeout: config.timeout
@@ -9367,7 +9455,17 @@ var SmartEngineClient = class _SmartEngineClient {
9367
9455
  return this.http.get("/status");
9368
9456
  }
9369
9457
  // ========== Messaging Operations ==========
9370
- /** 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
+ */
9371
9469
  async submitMessage(chain, topicId, message) {
9372
9470
  if (message.length > 1024 * 1024) {
9373
9471
  throw new SmartEngineError2("Message too large (max 1MB)", 400);
@@ -10256,7 +10354,7 @@ var DatabaseClient = class {
10256
10354
  async insert(collection, document) {
10257
10355
  const appId = this.getAppId();
10258
10356
  return this.http.post(
10259
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}`,
10357
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}`,
10260
10358
  document
10261
10359
  );
10262
10360
  }
@@ -10274,7 +10372,7 @@ var DatabaseClient = class {
10274
10372
  if (options?.sort) params.set("sort", options.sort);
10275
10373
  const qs = params.toString();
10276
10374
  return this.http.get(
10277
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}${qs ? `?${qs}` : ""}`
10375
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}${qs ? `?${qs}` : ""}`
10278
10376
  );
10279
10377
  }
10280
10378
  /**
@@ -10283,7 +10381,7 @@ var DatabaseClient = class {
10283
10381
  async update(collection, documentId, updates) {
10284
10382
  const appId = this.getAppId();
10285
10383
  return this.http.put(
10286
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`,
10384
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`,
10287
10385
  updates
10288
10386
  );
10289
10387
  }
@@ -10293,19 +10391,19 @@ var DatabaseClient = class {
10293
10391
  async delete(collection, documentId) {
10294
10392
  const appId = this.getAppId();
10295
10393
  return this.http.delete(
10296
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`
10394
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`
10297
10395
  );
10298
10396
  }
10299
10397
  /**
10300
10398
  * List collections for the app.
10301
10399
  *
10302
- * Server route is `/api/db/:appId/collections`
10400
+ * Server route is `/api/v3/baas/db/:appId/collections`
10303
10401
  * (`database.controller.ts:106`). The previous bare-`:appId` GET 404'd
10304
10402
  * — Nest reserves that pattern for the document-find router below.
10305
10403
  */
10306
10404
  async listCollections() {
10307
10405
  const appId = this.getAppId();
10308
- return this.http.get(`/api/db/${encodePathParam(appId)}/collections`);
10406
+ return this.http.get(`/api/v3/baas/db/${encodePathParam(appId)}/collections`);
10309
10407
  }
10310
10408
  /**
10311
10409
  * Create a new collection in the database.
@@ -10315,7 +10413,7 @@ var DatabaseClient = class {
10315
10413
  */
10316
10414
  async createCollection(name) {
10317
10415
  const appId = this.getAppId();
10318
- return this.http.post(`/api/db/${encodePathParam(appId)}/collections`, { name });
10416
+ return this.http.post(`/api/v3/baas/db/${encodePathParam(appId)}/collections`, { name });
10319
10417
  }
10320
10418
  /**
10321
10419
  * Drop a collection and all its documents.
@@ -10326,7 +10424,7 @@ var DatabaseClient = class {
10326
10424
  async dropCollection(name) {
10327
10425
  const appId = this.getAppId();
10328
10426
  return this.http.delete(
10329
- `/api/db/${encodePathParam(appId)}/collections/${encodePathParam(name)}`
10427
+ `/api/v3/baas/db/${encodePathParam(appId)}/collections/${encodePathParam(name)}`
10330
10428
  );
10331
10429
  }
10332
10430
  // ========== State Proofs ==========
@@ -10335,7 +10433,7 @@ var DatabaseClient = class {
10335
10433
  */
10336
10434
  async getStateRoot() {
10337
10435
  const appId = this.getAppId();
10338
- return this.http.get(`/api/db/${encodePathParam(appId)}/state/root`);
10436
+ return this.http.get(`/api/v3/baas/db/${encodePathParam(appId)}/state/root`);
10339
10437
  }
10340
10438
  /**
10341
10439
  * Get a Merkle proof for a specific document
@@ -10343,7 +10441,7 @@ var DatabaseClient = class {
10343
10441
  async getDocumentProof(documentId) {
10344
10442
  const appId = this.getAppId();
10345
10443
  return this.http.get(
10346
- `/api/db/${encodePathParam(appId)}/${encodePathParam(documentId)}/proof`
10444
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(documentId)}/proof`
10347
10445
  );
10348
10446
  }
10349
10447
  /**
@@ -10357,7 +10455,7 @@ var DatabaseClient = class {
10357
10455
  if (options?.limit !== void 0) params.set("limit", String(options.limit));
10358
10456
  const qs = params.toString();
10359
10457
  return this.http.get(
10360
- `/api/db/${encodePathParam(appId)}/state/transitions${qs ? `?${qs}` : ""}`
10458
+ `/api/v3/baas/db/${encodePathParam(appId)}/state/transitions${qs ? `?${qs}` : ""}`
10361
10459
  );
10362
10460
  }
10363
10461
  /**
@@ -10365,7 +10463,7 @@ var DatabaseClient = class {
10365
10463
  */
10366
10464
  async getDbStats() {
10367
10465
  const appId = this.getAppId();
10368
- return this.http.get(`/api/db/${encodePathParam(appId)}/stats`);
10466
+ return this.http.get(`/api/v3/baas/db/${encodePathParam(appId)}/stats`);
10369
10467
  }
10370
10468
  };
10371
10469
 
@@ -10382,28 +10480,28 @@ var StorageClient = class {
10382
10480
  */
10383
10481
  async upload(file, filename, metadata) {
10384
10482
  const appId = this.getAppId();
10385
- 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);
10386
10484
  }
10387
10485
  /**
10388
10486
  * Download a file by CID
10389
10487
  */
10390
10488
  async download(cid) {
10391
10489
  const appId = this.getAppId();
10392
- 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)}`);
10393
10491
  }
10394
10492
  /**
10395
10493
  * Get file metadata
10396
10494
  */
10397
10495
  async getMetadata(cid) {
10398
10496
  const appId = this.getAppId();
10399
- 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)}`);
10400
10498
  }
10401
10499
  /**
10402
10500
  * Delete a file
10403
10501
  */
10404
10502
  async delete(cid) {
10405
10503
  const appId = this.getAppId();
10406
- return this.http.delete(`/api/storage/${encodePathParam(appId)}/${encodePathParam(cid)}`);
10504
+ return this.http.delete(`/api/v3/baas/storage/${encodePathParam(appId)}/${encodePathParam(cid)}`);
10407
10505
  }
10408
10506
  /**
10409
10507
  * List all files for the app.
@@ -10418,21 +10516,21 @@ var StorageClient = class {
10418
10516
  if (pagination?.limit !== void 0) params.set("limit", String(pagination.limit));
10419
10517
  if (pagination?.offset !== void 0) params.set("offset", String(pagination.offset));
10420
10518
  const qs = params.toString();
10421
- 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}` : ""}`);
10422
10520
  }
10423
10521
  /**
10424
10522
  * Get storage usage for the current app
10425
10523
  */
10426
10524
  async getUsage() {
10427
10525
  const appId = this.getAppId();
10428
- return this.http.get(`/api/storage/${encodePathParam(appId)}/usage`);
10526
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/usage`);
10429
10527
  }
10430
10528
  /**
10431
10529
  * Check if a file exists
10432
10530
  */
10433
10531
  async exists(cid) {
10434
10532
  const appId = this.getAppId();
10435
- 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)}`);
10436
10534
  }
10437
10535
  };
10438
10536
 
@@ -10449,7 +10547,7 @@ var FunctionsClient = class {
10449
10547
  */
10450
10548
  async deploy(request) {
10451
10549
  const appId = this.getAppId();
10452
- return this.http.post(`/api/functions/${encodePathParam(appId)}`, request);
10550
+ return this.http.post(`/api/v3/baas/functions/${encodePathParam(appId)}`, request);
10453
10551
  }
10454
10552
  /**
10455
10553
  * Invoke a function
@@ -10457,7 +10555,7 @@ var FunctionsClient = class {
10457
10555
  async invoke(functionId, payload) {
10458
10556
  const appId = this.getAppId();
10459
10557
  return this.http.post(
10460
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/invoke`,
10558
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/invoke`,
10461
10559
  payload ?? {}
10462
10560
  );
10463
10561
  }
@@ -10466,7 +10564,7 @@ var FunctionsClient = class {
10466
10564
  */
10467
10565
  async list() {
10468
10566
  const appId = this.getAppId();
10469
- return this.http.get(`/api/functions/${encodePathParam(appId)}`);
10567
+ return this.http.get(`/api/v3/baas/functions/${encodePathParam(appId)}`);
10470
10568
  }
10471
10569
  /**
10472
10570
  * Get function details
@@ -10474,7 +10572,7 @@ var FunctionsClient = class {
10474
10572
  async get(functionId) {
10475
10573
  const appId = this.getAppId();
10476
10574
  return this.http.get(
10477
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`
10575
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`
10478
10576
  );
10479
10577
  }
10480
10578
  /**
@@ -10483,7 +10581,7 @@ var FunctionsClient = class {
10483
10581
  async update(functionId, updates) {
10484
10582
  const appId = this.getAppId();
10485
10583
  return this.http.put(
10486
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
10584
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
10487
10585
  updates
10488
10586
  );
10489
10587
  }
@@ -10493,7 +10591,7 @@ var FunctionsClient = class {
10493
10591
  async delete(functionId) {
10494
10592
  const appId = this.getAppId();
10495
10593
  return this.http.delete(
10496
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`
10594
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`
10497
10595
  );
10498
10596
  }
10499
10597
  /**
@@ -10507,7 +10605,7 @@ var FunctionsClient = class {
10507
10605
  if (options?.level) params.set("level", options.level);
10508
10606
  const qs = params.toString();
10509
10607
  return this.http.get(
10510
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/logs${qs ? `?${qs}` : ""}`
10608
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/logs${qs ? `?${qs}` : ""}`
10511
10609
  );
10512
10610
  }
10513
10611
  /**
@@ -10515,7 +10613,7 @@ var FunctionsClient = class {
10515
10613
  */
10516
10614
  async getStats() {
10517
10615
  const appId = this.getAppId();
10518
- return this.http.get(`/api/functions/${encodePathParam(appId)}/stats`);
10616
+ return this.http.get(`/api/v3/baas/functions/${encodePathParam(appId)}/stats`);
10519
10617
  }
10520
10618
  };
10521
10619
 
@@ -10532,28 +10630,28 @@ var MessagingClient = class {
10532
10630
  */
10533
10631
  async createChannel(config) {
10534
10632
  const appId = this.getAppId();
10535
- return this.http.post(`/api/messaging/${encodePathParam(appId)}/channels`, config);
10633
+ return this.http.post(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels`, config);
10536
10634
  }
10537
10635
  /**
10538
10636
  * Delete a channel
10539
10637
  */
10540
10638
  async deleteChannel(channelId) {
10541
10639
  const appId = this.getAppId();
10542
- 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)}`);
10543
10641
  }
10544
10642
  /**
10545
10643
  * Get a channel by ID
10546
10644
  */
10547
10645
  async getChannel(channelId) {
10548
10646
  const appId = this.getAppId();
10549
- 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)}`);
10550
10648
  }
10551
10649
  /**
10552
10650
  * List all channels for the app
10553
10651
  */
10554
10652
  async listChannels() {
10555
10653
  const appId = this.getAppId();
10556
- return this.http.get(`/api/messaging/${encodePathParam(appId)}/channels`);
10654
+ return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels`);
10557
10655
  }
10558
10656
  /**
10559
10657
  * Publish a message to a channel
@@ -10561,7 +10659,7 @@ var MessagingClient = class {
10561
10659
  async publish(channel, message, metadata) {
10562
10660
  const appId = this.getAppId();
10563
10661
  return this.http.post(
10564
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/publish`,
10662
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/publish`,
10565
10663
  { data: message, metadata }
10566
10664
  );
10567
10665
  }
@@ -10576,7 +10674,7 @@ var MessagingClient = class {
10576
10674
  if (options?.after) params.set("after", options.after);
10577
10675
  const qs = params.toString();
10578
10676
  return this.http.get(
10579
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/history${qs ? `?${qs}` : ""}`
10677
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/history${qs ? `?${qs}` : ""}`
10580
10678
  );
10581
10679
  }
10582
10680
  /**
@@ -10590,7 +10688,7 @@ var MessagingClient = class {
10590
10688
  async setPresence(channel, member) {
10591
10689
  const appId = this.getAppId();
10592
10690
  return this.http.post(
10593
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`,
10691
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`,
10594
10692
  member
10595
10693
  );
10596
10694
  }
@@ -10598,7 +10696,7 @@ var MessagingClient = class {
10598
10696
  * Remove a member's presence from a channel.
10599
10697
  *
10600
10698
  * BREAKING CHANGE (SDK 3.3.0): server route is
10601
- * `/api/messaging/:appId/channels/:channel/presence/:clientId`
10699
+ * `/api/v3/baas/messaging/:appId/channels/:channel/presence/:clientId`
10602
10700
  * (`messaging.controller.ts:352`). `channel` is now the first arg and
10603
10701
  * `clientId` (not `memberId`) the second — they're the same identifier
10604
10702
  * but renamed to match the server param.
@@ -10606,7 +10704,7 @@ var MessagingClient = class {
10606
10704
  async removePresence(channel, clientId) {
10607
10705
  const appId = this.getAppId();
10608
10706
  return this.http.delete(
10609
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence/${encodePathParam(clientId)}`
10707
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence/${encodePathParam(clientId)}`
10610
10708
  );
10611
10709
  }
10612
10710
  /**
@@ -10615,7 +10713,7 @@ var MessagingClient = class {
10615
10713
  async getPresence(channel) {
10616
10714
  const appId = this.getAppId();
10617
10715
  return this.http.get(
10618
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`
10716
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`
10619
10717
  );
10620
10718
  }
10621
10719
  /**
@@ -10623,7 +10721,7 @@ var MessagingClient = class {
10623
10721
  */
10624
10722
  async getStats() {
10625
10723
  const appId = this.getAppId();
10626
- return this.http.get(`/api/messaging/${encodePathParam(appId)}/stats`);
10724
+ return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/stats`);
10627
10725
  }
10628
10726
  };
10629
10727
 
@@ -10639,21 +10737,21 @@ var CustomerSessionClient = class {
10639
10737
  * Step 1: ask the host to issue a fresh challenge for the customer to sign.
10640
10738
  */
10641
10739
  async challenge(input) {
10642
- return this.fetch("POST", "/api/customer-session/challenge", input);
10740
+ return this.fetch("POST", "/api/v3/baas/customer-session/challenge", input);
10643
10741
  }
10644
10742
  /**
10645
10743
  * Step 2: submit the customer's signed challenge. On success returns a
10646
10744
  * short-lived bearer JWT scoped to {appId, chain, address}.
10647
10745
  */
10648
10746
  async verify(req) {
10649
- return this.fetch("POST", "/api/customer-session/verify", req);
10747
+ return this.fetch("POST", "/api/v3/baas/customer-session/verify", req);
10650
10748
  }
10651
10749
  /**
10652
10750
  * Validate a customer bearer + return the decoded session info. Used by
10653
10751
  * smart-app backends to authorise incoming customer requests.
10654
10752
  */
10655
10753
  async validate(bearer) {
10656
- 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);
10657
10755
  }
10658
10756
  /**
10659
10757
  * Revoke a customer session. Idempotent.
@@ -10661,7 +10759,7 @@ var CustomerSessionClient = class {
10661
10759
  async end(bearer) {
10662
10760
  return this.fetch(
10663
10761
  "POST",
10664
- "/api/customer-session/end",
10762
+ "/api/v3/baas/customer-session/end",
10665
10763
  void 0,
10666
10764
  bearer
10667
10765
  );
@@ -10707,15 +10805,15 @@ var RulesClient = class {
10707
10805
  http;
10708
10806
  /** Publish a canonical ValidatorRules document to HCS. */
10709
10807
  async publish(rule) {
10710
- return this.http.post("/api/rules/publish", rule);
10808
+ return this.http.post("/api/v3/baas/rules/publish", rule);
10711
10809
  }
10712
10810
  /** Fetch a published rule by its HCS consensus timestamp. */
10713
10811
  async get(consensusTimestamp) {
10714
- return this.http.get(`/api/rules/${encodePathParam(consensusTimestamp)}`);
10812
+ return this.http.get(`/api/v3/baas/rules/${encodePathParam(consensusTimestamp)}`);
10715
10813
  }
10716
10814
  /** List rules owned by the authenticated entity, optionally filtered by type. */
10717
10815
  async listByOwner(filter) {
10718
- 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";
10719
10817
  return this.http.get(path);
10720
10818
  }
10721
10819
  /**
@@ -10723,44 +10821,332 @@ var RulesClient = class {
10723
10821
  * `ruleRef` (published) or `rule` (inline) must be supplied by the caller.
10724
10822
  */
10725
10823
  async simulate(params) {
10726
- return this.http.post("/api/rules/simulate", params);
10824
+ return this.http.post("/api/v3/baas/rules/simulate", params);
10727
10825
  }
10728
10826
  /** Walk the version history of a published rule. */
10729
10827
  async getVersionHistory(consensusTimestamp) {
10730
10828
  return this.http.get(
10731
- `/api/rules/${encodePathParam(consensusTimestamp)}/versions`
10829
+ `/api/v3/baas/rules/${encodePathParam(consensusTimestamp)}/versions`
10732
10830
  );
10733
10831
  }
10734
10832
  /** Deprecate a published rule (owner-only). */
10735
10833
  async deprecate(consensusTimestamp) {
10736
10834
  return this.http.post(
10737
- `/api/rules/${encodePathParam(consensusTimestamp)}/deprecate`,
10835
+ `/api/v3/baas/rules/${encodePathParam(consensusTimestamp)}/deprecate`,
10738
10836
  {}
10739
10837
  );
10740
10838
  }
10741
10839
  };
10742
10840
 
10743
10841
  // src/baas/entities/client.ts
10744
- var EntitiesClient = class {
10842
+ var EntitiesClient = class _EntitiesClient {
10745
10843
  constructor(http) {
10746
10844
  this.http = http;
10747
10845
  }
10748
10846
  http;
10749
- /** 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
+ */
10750
10922
  async createToken(req) {
10751
- 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);
10752
10950
  }
10753
- /** Create a canonical account entity bound to a published rule. */
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
+ });
10963
+ }
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
+ */
10754
11044
  async createAccount(req) {
10755
- 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);
11072
+ }
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
+ });
10756
11101
  }
10757
- /** Create a canonical topic entity bound to a published rule. */
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
+ */
10758
11113
  async createTopic(req) {
10759
- 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);
10760
11146
  }
10761
11147
  /** Create a canonical agent entity bound to a published rule. */
10762
11148
  async createAgent(req) {
10763
- return this.http.post("/api/entities/createAgent", req);
11149
+ return this.http.post("/api/v3/baas/entities/createAgent", req);
10764
11150
  }
10765
11151
  /**
10766
11152
  * Mega-helper: build a token rule with a launchpad ModuleEntry attached,
@@ -10768,15 +11154,15 @@ var EntitiesClient = class {
10768
11154
  * round-trip.
10769
11155
  */
10770
11156
  async launchpad(req) {
10771
- return this.http.post("/api/entities/launchpad", req);
11157
+ return this.http.post("/api/v3/baas/entities/launchpad", req);
10772
11158
  }
10773
11159
  /** Fetch an entity by its canonical `entityId`. */
10774
11160
  async get(entityId) {
10775
- return this.http.get(`/api/entities/${encodePathParam(entityId)}`);
11161
+ return this.http.get(`/api/v3/baas/entities/${encodePathParam(entityId)}`);
10776
11162
  }
10777
11163
  /** List entities owned by the authenticated wallet, optionally filtered by type. */
10778
11164
  async listByOwner(filter) {
10779
- 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";
10780
11166
  return this.http.get(path);
10781
11167
  }
10782
11168
  };
@@ -10789,6 +11175,13 @@ var BaasClient = class _BaasClient {
10789
11175
  timeout;
10790
11176
  allowInsecure;
10791
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;
10792
11185
  /** Last HTTP error (for getHttpHealth) */
10793
11186
  lastHttpError;
10794
11187
  /**
@@ -10817,6 +11210,14 @@ var BaasClient = class _BaasClient {
10817
11210
  rules;
10818
11211
  /** Canonical entity authoring surface (token/account/topic/agent + launchpad). */
10819
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;
10820
11221
  constructor(config) {
10821
11222
  this.allowInsecure = config.allowInsecure ?? false;
10822
11223
  this.hostUrl = validateUrl2(config.hostUrl, this.allowInsecure);
@@ -10830,7 +11231,12 @@ var BaasClient = class _BaasClient {
10830
11231
  timeout: this.timeout,
10831
11232
  // Transparent session refresh: on a 401, re-run the challenge-response
10832
11233
  // with the retained signer and retry once. No-op until authenticate() has
10833
- // 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,
10834
11240
  onUnauthorized: () => this.reauthenticate()
10835
11241
  });
10836
11242
  const getAppId = () => this.requireAppId();
@@ -10843,6 +11249,7 @@ var BaasClient = class _BaasClient {
10843
11249
  this.customerSession = new CustomerSessionClient(baseUrlWithPrefix, this.timeout);
10844
11250
  this.rules = new RulesClient(this.http);
10845
11251
  this.entities = new EntitiesClient(this.http);
11252
+ this.transactions = new TransactionsClient(this.txHttp);
10846
11253
  }
10847
11254
  /**
10848
11255
  * Connect to the Smart Engines BaaS via cluster auto-discovery.
@@ -10970,7 +11377,7 @@ var BaasClient = class _BaasClient {
10970
11377
  this.authContext = options;
10971
11378
  let challenge;
10972
11379
  try {
10973
- challenge = await this.http.post("/api/auth/challenge", {
11380
+ challenge = await this.http.post("/api/v3/baas/auth/challenge", {
10974
11381
  chain,
10975
11382
  walletAddress,
10976
11383
  appId: this.appId
@@ -10981,7 +11388,7 @@ var BaasClient = class _BaasClient {
10981
11388
  const signature = await signFn(challenge.message);
10982
11389
  let result;
10983
11390
  try {
10984
- result = await this.http.post("/api/auth/verify", {
11391
+ result = await this.http.post("/api/v3/baas/auth/verify", {
10985
11392
  challengeId: challenge.challengeId,
10986
11393
  signature,
10987
11394
  publicKey
@@ -10990,6 +11397,7 @@ var BaasClient = class _BaasClient {
10990
11397
  throw asBaasError(err);
10991
11398
  }
10992
11399
  this.http.setAuthToken(result.token);
11400
+ this.txHttp.setAuthToken(result.token);
10993
11401
  return result;
10994
11402
  }
10995
11403
  /**
@@ -10997,30 +11405,31 @@ var BaasClient = class _BaasClient {
10997
11405
  * session token. Invoked by the http client's `onUnauthorized` hook when a
10998
11406
  * request 401s because the token expired — so long-lived clients keep working
10999
11407
  * without the caller re-implementing refresh. No-op if {@link authenticate}
11000
- * 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
11001
11409
  * client's 401-retry path, so this can never recurse.
11002
11410
  */
11003
11411
  async reauthenticate() {
11004
11412
  const ctx = this.authContext;
11005
11413
  if (!ctx) return;
11006
- const challenge = await this.http.post("/api/auth/challenge", {
11414
+ const challenge = await this.http.post("/api/v3/baas/auth/challenge", {
11007
11415
  chain: ctx.chain,
11008
11416
  walletAddress: ctx.walletAddress,
11009
11417
  appId: this.appId
11010
11418
  });
11011
11419
  const signature = await ctx.signFn(challenge.message);
11012
- const result = await this.http.post("/api/auth/verify", {
11420
+ const result = await this.http.post("/api/v3/baas/auth/verify", {
11013
11421
  challengeId: challenge.challengeId,
11014
11422
  signature,
11015
11423
  publicKey: ctx.publicKey
11016
11424
  });
11017
11425
  this.http.setAuthToken(result.token);
11426
+ this.txHttp.setAuthToken(result.token);
11018
11427
  }
11019
11428
  /** Validate the current session */
11020
11429
  async validateSession() {
11021
11430
  this.requireAuth();
11022
11431
  try {
11023
- return await this.http.get("/api/auth/session");
11432
+ return await this.http.get("/api/v3/baas/auth/session");
11024
11433
  } catch (err) {
11025
11434
  throw asBaasError(err);
11026
11435
  }
@@ -11029,11 +11438,12 @@ var BaasClient = class _BaasClient {
11029
11438
  async logout() {
11030
11439
  if (this.http.getAuthToken()) {
11031
11440
  try {
11032
- await this.http.post("/api/auth/logout", {});
11441
+ await this.http.post("/api/v3/baas/auth/logout", {});
11033
11442
  } catch {
11034
11443
  }
11035
11444
  }
11036
11445
  this.http.setAuthToken(void 0);
11446
+ this.txHttp.setAuthToken(void 0);
11037
11447
  }
11038
11448
  // ========== HTTP Helpers ==========
11039
11449
  requireAuth() {
@@ -11453,6 +11863,49 @@ async function verifyPqcEnvelope(envelope, options = {}) {
11453
11863
  }
11454
11864
  return { valid: true, version, details };
11455
11865
  }
11866
+ var { deriveKeypair, deriveAddress, sign, verify } = require_dist2();
11867
+ function canonicalizeAttestation(att) {
11868
+ return JSON.stringify(att, Object.keys(att).sort());
11869
+ }
11870
+ function computeAttestationHash(att) {
11871
+ const canonical = canonicalizeAttestation(att);
11872
+ const digest = sha256.sha256(new TextEncoder().encode(canonical));
11873
+ return bytesToHex2(digest);
11874
+ }
11875
+ function signAttestation(att, xrplSeed) {
11876
+ const { publicKey, privateKey } = deriveKeypair(xrplSeed);
11877
+ const messageHex = attestationMessageHex(att);
11878
+ const signature = sign(messageHex, privateKey);
11879
+ return `${publicKey}.${signature}`;
11880
+ }
11881
+ function verifyAttestation(att, signature, walletAddress) {
11882
+ try {
11883
+ const sep = signature.indexOf(".");
11884
+ if (sep <= 0 || sep === signature.length - 1) {
11885
+ return false;
11886
+ }
11887
+ const publicKey = signature.slice(0, sep);
11888
+ const sigHex = signature.slice(sep + 1);
11889
+ if (deriveAddress(publicKey) !== walletAddress) {
11890
+ return false;
11891
+ }
11892
+ const messageHex = attestationMessageHex(att);
11893
+ return verify(messageHex, sigHex, publicKey);
11894
+ } catch {
11895
+ return false;
11896
+ }
11897
+ }
11898
+ function attestationMessageHex(att) {
11899
+ const hash = computeAttestationHash(att);
11900
+ return Buffer.from(hash, "utf-8").toString("hex").toUpperCase();
11901
+ }
11902
+ function bytesToHex2(bytes) {
11903
+ let s = "";
11904
+ for (let i = 0; i < bytes.length; i++) {
11905
+ s += bytes[i].toString(16).padStart(2, "0");
11906
+ }
11907
+ return s;
11908
+ }
11456
11909
 
11457
11910
  // src/rules/atoms/index.ts
11458
11911
  var atom = {
@@ -12957,7 +13410,9 @@ exports.atom = atom;
12957
13410
  exports.auth = auth_exports;
12958
13411
  exports.baas = baas_exports;
12959
13412
  exports.bridge = bridge_exports;
13413
+ exports.canonicalizeAttestation = canonicalizeAttestation;
12960
13414
  exports.chains = chains_exports;
13415
+ exports.computeAttestationHash = computeAttestationHash;
12961
13416
  exports.createHttpClient = createHttpClient;
12962
13417
  exports.createResilientFetchWithBreaker = createResilientFetchWithBreaker;
12963
13418
  exports.createXrplWeb3Signer = createXrplWeb3Signer;
@@ -12991,6 +13446,7 @@ exports.resilientFetch = resilientFetch;
12991
13446
  exports.resolveNetwork = resolveNetwork;
12992
13447
  exports.resources = resources_exports;
12993
13448
  exports.settlement = settlement_exports;
13449
+ exports.signAttestation = signAttestation;
12994
13450
  exports.simpleAMM = simpleAMM;
12995
13451
  exports.simpleStaking = simpleStaking;
12996
13452
  exports.soulboundNft = soulboundNft;
@@ -13006,6 +13462,7 @@ exports.utilityToken = utilityToken;
13006
13462
  exports.validate = validate;
13007
13463
  exports.validateAgentRules = validateAgentRules;
13008
13464
  exports.validateEnvelopeSchema = validateEnvelopeSchema;
13465
+ exports.verifyAttestation = verifyAttestation;
13009
13466
  exports.verifyPqcAttestation = verifyPqcAttestation;
13010
13467
  exports.verifyPqcEnvelope = verifyPqcEnvelope;
13011
13468
  exports.vestingSchedule = vestingSchedule;