@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.
@@ -199,6 +199,14 @@ var PreparedTransactionSovereigntySchema = zod.z.discriminatedUnion("mode", [
199
199
  authorizationSet: PreparedTransactionAuthorizationSetSchema.optional()
200
200
  })
201
201
  ]);
202
+ var RuleRefSchema = zod.z.object({
203
+ /** Chain whose HCS the rule was published on (canonically 'hedera'). */
204
+ chain: ChainTypeSchema,
205
+ /** HCS topic ID the rule message was published to. */
206
+ topicId: zod.z.string().min(1),
207
+ /** HCS consensus timestamp of the rule message. */
208
+ consensusTimestamp: zod.z.string().min(1)
209
+ });
202
210
  var CreateAccountRequestSchema = zod.z.object({
203
211
  chain: ChainTypeSchema,
204
212
  initialBalance: zod.z.string(),
@@ -238,6 +246,22 @@ var CreateAccountRequestSchema = zod.z.object({
238
246
  * The owner key + TSS network key form a threshold-2 multi-sig.
239
247
  */
240
248
  appOwnerPublicKey: zod.z.string().optional(),
249
+ /**
250
+ * The entity's canonical `ruleRef` (HCS pointer to its `ValidatorRules`). When
251
+ * present, the chain adapter stamps the IMMUTABLE creation-tx rule anchor
252
+ * (`rule:<topicId>@<consensusTimestamp>:<entityType>`) — distinct from the
253
+ * mutable validator-binding memo — so the sign-gate resolves the rule on-chain
254
+ * (kind:'ref') rather than trusting the replicated binding
255
+ * (RFC 2026-06-15-onchain-rule-anchor §6.1). Absent ⇒ the degraded
256
+ * `rule:bootstrap:<entityType>` marker when `entityType` is supplied.
257
+ */
258
+ ruleRef: RuleRefSchema.optional(),
259
+ /**
260
+ * Entity-type tag stamped into the rule anchor (e.g. 'wallet', 'account').
261
+ * Supply it to enable the on-chain anchor; omit for the prior memo-less
262
+ * (legacy) behaviour.
263
+ */
264
+ entityType: zod.z.string().min(1).optional(),
241
265
  metadata: zod.z.record(zod.z.any()).optional()
242
266
  });
243
267
  zod.z.object({
@@ -325,6 +349,21 @@ var CreateTokenRequestSchema = zod.z.object({
325
349
  immutable: zod.z.boolean().default(true),
326
350
  /** See CreateAccountRequestSchema.payerAccountId — same resolution rules. */
327
351
  payerAccountId: zod.z.string().optional(),
352
+ /**
353
+ * The entity's canonical `ruleRef` (HCS pointer to its `ValidatorRules`). When
354
+ * present, the chain adapter stamps the IMMUTABLE creation-tx rule anchor
355
+ * (`rule:<topicId>@<consensusTimestamp>:<entityType>`) — distinct from the
356
+ * mutable validator-binding token memo — so the sign-gate resolves the rule
357
+ * on-chain (kind:'ref') rather than trusting the replicated binding
358
+ * (RFC 2026-06-15-onchain-rule-anchor §6.1). Absent ⇒ the degraded
359
+ * `rule:bootstrap:<entityType>` marker when `entityType` is supplied.
360
+ */
361
+ ruleRef: RuleRefSchema.optional(),
362
+ /**
363
+ * Entity-type tag stamped into the rule anchor (e.g. 'token'). Supply it to
364
+ * enable the on-chain anchor; omit for the prior memo-less behaviour.
365
+ */
366
+ entityType: zod.z.string().min(1).optional(),
328
367
  metadata: zod.z.record(zod.z.any()).optional()
329
368
  });
330
369
  zod.z.object({
@@ -1249,7 +1288,7 @@ function createHttpClient(config) {
1249
1288
  try {
1250
1289
  return await op();
1251
1290
  } catch (error) {
1252
- const refreshable = !!config.onUnauthorized && !path.startsWith("/api/auth/") && error instanceof SdkHttpError && error.statusCode === 401;
1291
+ const refreshable = !!config.onUnauthorized && !path.startsWith("/api/v3/baas/auth/") && !path.startsWith("/api/v3/auth/") && error instanceof SdkHttpError && error.statusCode === 401;
1253
1292
  if (!refreshable) throw error;
1254
1293
  if (!reauthInFlight) {
1255
1294
  reauthInFlight = Promise.resolve(config.onUnauthorized()).finally(() => {
@@ -2189,7 +2228,7 @@ var HederaTransactionsClient = class {
2189
2228
  * - `client.hedera.tss.createTopic(...)` makes the cluster sign+submit in one call.
2190
2229
  *
2191
2230
  * `tssHttp` is the validator's `/api/v3`-rooted HTTP client (different from
2192
- * the `/api/transactions` one this class uses for prepare paths). Both
2231
+ * the `/api/v3/transactions` one this class uses for prepare paths). Both
2193
2232
  * clients are required — the previous single-arg fallback to `http` was
2194
2233
  * unreachable through `SmartEngineClient` (the only call site always
2195
2234
  * passes both).
@@ -2899,15 +2938,15 @@ var AgentsClient = class {
2899
2938
  http;
2900
2939
  /** Register a new agent */
2901
2940
  async register(request) {
2902
- return this.http.post("/api/agents/register", request);
2941
+ return this.http.post("/api/v3/baas/agents/register", request);
2903
2942
  }
2904
2943
  /** Get agent details */
2905
2944
  async get(agentId) {
2906
- return this.http.get(`/api/agents/${encodePathParam(agentId)}`);
2945
+ return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}`);
2907
2946
  }
2908
2947
  /** List all agents */
2909
2948
  async list() {
2910
- return this.http.get("/api/agents");
2949
+ return this.http.get("/api/v3/baas/agents");
2911
2950
  }
2912
2951
  /**
2913
2952
  * Fund agent treasury (owner-only). Returns a
@@ -2915,60 +2954,60 @@ var AgentsClient = class {
2915
2954
  * the caller is expected to sign and submit the prepared bytes.
2916
2955
  */
2917
2956
  async fund(agentId, request) {
2918
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/fund`, request);
2957
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/fund`, request);
2919
2958
  }
2920
2959
  /**
2921
2960
  * Execute a trade (agent-wallet OR owner). Returns a
2922
2961
  * `PreparedTransactionResponse` wrapped in a `success: true` envelope.
2923
2962
  */
2924
2963
  async trade(agentId, request) {
2925
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/trade`, request);
2964
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/trade`, request);
2926
2965
  }
2927
2966
  /**
2928
2967
  * Withdraw from agent treasury (owner-only). Returns a
2929
2968
  * `PreparedTransactionResponse` wrapped in a `success: true` envelope.
2930
2969
  */
2931
2970
  async withdraw(agentId, request) {
2932
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/withdraw`, request);
2971
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/withdraw`, request);
2933
2972
  }
2934
2973
  /** Pause an agent */
2935
2974
  async pause(agentId) {
2936
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/pause`, {});
2975
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/pause`, {});
2937
2976
  }
2938
2977
  /** Resume a paused agent */
2939
2978
  async resume(agentId) {
2940
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/resume`, {});
2979
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/resume`, {});
2941
2980
  }
2942
2981
  /** Revoke an agent (permanent) */
2943
2982
  async revoke(agentId) {
2944
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/revoke`, {});
2983
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/revoke`, {});
2945
2984
  }
2946
2985
  /**
2947
2986
  * Update agent rules.
2948
2987
  *
2949
- * Server route is PATCH `/api/agents/:agentId/rules`
2988
+ * Server route is PATCH `/api/v3/baas/agents/:agentId/rules`
2950
2989
  * (`agents.controller.ts:375`). The previous PUT variant 404'd because
2951
2990
  * Nest matched the dynamic `:agentId` GET/POST handlers and rejected
2952
2991
  * the verb mismatch.
2953
2992
  */
2954
2993
  async updateRules(agentId, rules) {
2955
- return this.http.patch(`/api/agents/${encodePathParam(agentId)}/rules`, rules);
2994
+ return this.http.patch(`/api/v3/baas/agents/${encodePathParam(agentId)}/rules`, rules);
2956
2995
  }
2957
2996
  /** Get agent events */
2958
2997
  async getEvents(agentId) {
2959
- return this.http.get(`/api/agents/${encodePathParam(agentId)}/events`);
2998
+ return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}/events`);
2960
2999
  }
2961
3000
  /** Get agent balances across chains */
2962
3001
  async getBalances(agentId) {
2963
- return this.http.get(`/api/agents/${encodePathParam(agentId)}/balances`);
3002
+ return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}/balances`);
2964
3003
  }
2965
3004
  /** Approve a pending agent operation */
2966
3005
  async approve(agentId, operationId) {
2967
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/approve/${encodePathParam(operationId)}`, {});
3006
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/approve/${encodePathParam(operationId)}`, {});
2968
3007
  }
2969
3008
  /** Reject a pending agent operation */
2970
3009
  async reject(agentId, operationId) {
2971
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/reject/${encodePathParam(operationId)}`, {});
3010
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/reject/${encodePathParam(operationId)}`, {});
2972
3011
  }
2973
3012
  };
2974
3013
 
@@ -2996,7 +3035,56 @@ var DeploymentClient = class {
2996
3035
  * {@link deploy} with the pushed image tag.
2997
3036
  */
2998
3037
  async init(request) {
2999
- return this.http.post("/api/deployment/apps/init", request);
3038
+ return this.http.post("/api/v3/baas/deployment/apps/init", request);
3039
+ }
3040
+ /**
3041
+ * Issue ephemeral Harbor push credentials for a smart-app that ALREADY
3042
+ * EXISTS — the MINT-FIRST / DEPLOY-LAST credentials-push call.
3043
+ *
3044
+ * Unlike {@link init} (which historically allocated a fresh entity), this
3045
+ * takes the developer's pre-existing `appId` — the `SUBSCRIPTION_APP_ID`
3046
+ * minted by `hsuite subscribe` (`appId == DKG entityId`) — and ONLY
3047
+ * (re)provisions the per-app Harbor project + push robot. The server creates
3048
+ * no DKG entity and no subscription; it asserts the caller owns the app and
3049
+ * that its subscription is ACTIVE (402 otherwise) first.
3050
+ *
3051
+ * Returns the same `{ appId, registry }` shape as {@link init}. Single-use
3052
+ * secret discipline applies to `registry.password` exactly as in `init`.
3053
+ *
3054
+ * This is the credentials path the mint-first `hsuite deploy` uses to obtain
3055
+ * push creds for the developer's already-minted subscription app
3056
+ * (`POST /apps/:appId/credentials/push`). The `hsuite redeploy` re-push path
3057
+ * uses {@link reissuePushCredentials} instead, which targets a dedicated
3058
+ * `credentials/reissue` route with stricter SUSPENDED-app + Harbor-failure
3059
+ * handling.
3060
+ */
3061
+ async pushCredentials(appId) {
3062
+ return this.http.post(
3063
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/credentials/push`,
3064
+ {}
3065
+ );
3066
+ }
3067
+ /**
3068
+ * Reissue ephemeral Harbor push credentials for an EXISTING app, WITHOUT
3069
+ * allocating a new appId / entity. Unlike {@link init} — which historically
3070
+ * forked a fresh smart-app entity (and a fresh paid subscription) on every
3071
+ * call — this re-binds to an app the developer already owns: the `appId` is
3072
+ * echoed back unchanged and only a new single-use `registry.password` push
3073
+ * robot is minted. Same `{ appId, registry }` response shape as `init`.
3074
+ *
3075
+ * Owner-only + active-subscription gated server-side. This is the credential
3076
+ * path `hsuite redeploy` uses so a re-push does not cost a new entity +
3077
+ * subscription each run. Targets the dedicated
3078
+ * `POST /apps/:appId/credentials/reissue` route (distinct from
3079
+ * {@link pushCredentials}'s first-deploy `credentials/push`): the reissue
3080
+ * route additionally refuses SUSPENDED apps and surfaces Harbor failures
3081
+ * loudly rather than returning placeholder creds.
3082
+ */
3083
+ async reissuePushCredentials(appId) {
3084
+ return this.http.post(
3085
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/credentials/reissue`,
3086
+ {}
3087
+ );
3000
3088
  }
3001
3089
  /**
3002
3090
  * Step 3 (optional) — upload the SPA tarball.
@@ -3007,7 +3095,7 @@ var DeploymentClient = class {
3007
3095
  */
3008
3096
  async uploadFrontend(appId, bundle, filename = "bundle.tar.gz") {
3009
3097
  return this.http.upload(
3010
- `/api/deployment/apps/${encodePathParam(appId)}/frontend`,
3098
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/frontend`,
3011
3099
  bundle,
3012
3100
  filename,
3013
3101
  void 0,
@@ -3021,32 +3109,32 @@ var DeploymentClient = class {
3021
3109
  * until `runtime.runtimeState === 'RUNNING'` for the URL to be live.
3022
3110
  */
3023
3111
  async deploy(appId, request) {
3024
- return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/deploy`, request);
3112
+ return this.http.post(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/deploy`, request);
3025
3113
  }
3026
3114
  /**
3027
3115
  * Roll back to a previously-deployed image tag (must exist in
3028
3116
  * `runtime.deploymentHistory[]`).
3029
3117
  */
3030
3118
  async rollback(appId, request) {
3031
- return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/rollback`, request);
3119
+ return this.http.post(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/rollback`, request);
3032
3120
  }
3033
3121
  /**
3034
3122
  * Live combined lifecycle + runtime status of an app.
3035
3123
  */
3036
3124
  async status(appId) {
3037
- return this.http.get(`/api/deployment/apps/${encodePathParam(appId)}/status`);
3125
+ return this.http.get(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/status`);
3038
3126
  }
3039
3127
  /**
3040
3128
  * List all deployed apps for the authenticated developer.
3041
3129
  */
3042
3130
  async list() {
3043
- return this.http.get("/api/deployment/apps");
3131
+ return this.http.get("/api/v3/smart-apps");
3044
3132
  }
3045
3133
  /**
3046
3134
  * Get app details.
3047
3135
  */
3048
3136
  async get(appId) {
3049
- return this.http.get(`/api/deployment/apps/${encodePathParam(appId)}`);
3137
+ return this.http.get(`/api/v3/smart-apps/${encodePathParam(appId)}`);
3050
3138
  }
3051
3139
  /**
3052
3140
  * Update app configuration.
@@ -3056,31 +3144,31 @@ var DeploymentClient = class {
3056
3144
  * @returns The updated app info.
3057
3145
  */
3058
3146
  async update(appId, updates) {
3059
- return this.http.put(`/api/deployment/apps/${encodePathParam(appId)}`, updates);
3147
+ return this.http.put(`/api/v3/smart-apps/${encodePathParam(appId)}`, updates);
3060
3148
  }
3061
3149
  /**
3062
3150
  * Delete an app (runtime effect: namespace teardown).
3063
3151
  */
3064
3152
  async delete(appId) {
3065
- return this.http.delete(`/api/deployment/apps/${encodePathParam(appId)}`);
3153
+ return this.http.delete(`/api/v3/smart-apps/${encodePathParam(appId)}`);
3066
3154
  }
3067
3155
  /**
3068
3156
  * Suspend an app (runtime effect: scale to zero).
3069
3157
  */
3070
3158
  async suspend(appId) {
3071
- return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/suspend`, {});
3159
+ return this.http.post(`/api/v3/smart-apps/${encodePathParam(appId)}/suspend`, {});
3072
3160
  }
3073
3161
  /**
3074
3162
  * Resume a suspended app (runtime effect: scale back up).
3075
3163
  */
3076
3164
  async resume(appId) {
3077
- return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/resume`, {});
3165
+ return this.http.post(`/api/v3/smart-apps/${encodePathParam(appId)}/resume`, {});
3078
3166
  }
3079
3167
  /**
3080
3168
  * Get deployment statistics.
3081
3169
  */
3082
3170
  async getStats() {
3083
- return this.http.get("/api/deployment/stats");
3171
+ return this.http.get("/api/v3/smart-apps/stats");
3084
3172
  }
3085
3173
  /**
3086
3174
  * Register or update the developer-facing webhook URL for runtime
@@ -3101,7 +3189,7 @@ var DeploymentClient = class {
3101
3189
  * CGNAT / cloud metadata destinations (SSRF guard).
3102
3190
  */
3103
3191
  async setWebhook(appId, webhookUrl) {
3104
- return this.http.put(`/api/deployment/apps/${encodePathParam(appId)}/webhook`, {
3192
+ return this.http.put(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/webhook`, {
3105
3193
  webhookUrl
3106
3194
  });
3107
3195
  }
@@ -3117,7 +3205,7 @@ var DeploymentClient = class {
3117
3205
  * exposition format.
3118
3206
  */
3119
3207
  async getMetrics(appId) {
3120
- return this.http.getText(`/api/deployment/apps/${encodePathParam(appId)}/metrics`);
3208
+ return this.http.getText(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/metrics`);
3121
3209
  }
3122
3210
  /**
3123
3211
  * Rotate the smart-app's tenant-secret KEK.
@@ -3128,7 +3216,7 @@ var DeploymentClient = class {
3128
3216
  */
3129
3217
  async rotateKek(appId) {
3130
3218
  return this.http.post(
3131
- `/api/deployment/apps/${encodePathParam(appId)}/credentials/rotate-kek`,
3219
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/credentials/rotate-kek`,
3132
3220
  {}
3133
3221
  );
3134
3222
  }
@@ -3142,7 +3230,7 @@ var DeploymentClient = class {
3142
3230
  */
3143
3231
  async revokeKek(appId, version) {
3144
3232
  return this.http.post(
3145
- `/api/deployment/apps/${encodePathParam(appId)}/credentials/revoke-kek`,
3233
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/credentials/revoke-kek`,
3146
3234
  { version }
3147
3235
  );
3148
3236
  }
@@ -3349,7 +3437,7 @@ var SmartEngineClient = class _SmartEngineClient {
3349
3437
  baseUrl;
3350
3438
  allowInsecure;
3351
3439
  http;
3352
- /** Separate HTTP client for /api/transactions (non-v3 base path) */
3440
+ /** Separate HTTP client for /api/v3/transactions */
3353
3441
  txHttp;
3354
3442
  /** Last HTTP error (for getHttpHealth) */
3355
3443
  lastHttpError;
@@ -3410,7 +3498,7 @@ var SmartEngineClient = class _SmartEngineClient {
3410
3498
  timeout: config.timeout
3411
3499
  });
3412
3500
  this.txHttp = createHttpClient({
3413
- baseUrl: `${this.baseUrl}/api/transactions`,
3501
+ baseUrl: `${this.baseUrl}/api/v3/transactions`,
3414
3502
  apiKey: config.apiKey,
3415
3503
  authToken: config.authToken,
3416
3504
  timeout: config.timeout
@@ -3744,7 +3832,17 @@ var SmartEngineClient = class _SmartEngineClient {
3744
3832
  return this.http.get("/status");
3745
3833
  }
3746
3834
  // ========== Messaging Operations ==========
3747
- /** Submit a message to consensus */
3835
+ /**
3836
+ * Submit a message to consensus.
3837
+ *
3838
+ * @deprecated Operator-funded message submission is RETIRED on the validator
3839
+ * under transaction sovereignty — `POST /api/v3/messages/:chain/:topicId`
3840
+ * now returns `403 Forbidden` (the operator must never front the chain fee
3841
+ * for a customer-supplied message). Use the payer-funded prepare path
3842
+ * instead: prepare a topic-message transaction via
3843
+ * `POST /api/transactions/topic/message/prepare`, then have the payer sign
3844
+ * and submit the returned bytes.
3845
+ */
3748
3846
  async submitMessage(chain, topicId, message) {
3749
3847
  if (message.length > 1024 * 1024) {
3750
3848
  throw new SmartEngineError("Message too large (max 1MB)", 400);
@@ -4121,7 +4219,7 @@ var DatabaseClient = class {
4121
4219
  async insert(collection, document) {
4122
4220
  const appId = this.getAppId();
4123
4221
  return this.http.post(
4124
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}`,
4222
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}`,
4125
4223
  document
4126
4224
  );
4127
4225
  }
@@ -4139,7 +4237,7 @@ var DatabaseClient = class {
4139
4237
  if (options?.sort) params.set("sort", options.sort);
4140
4238
  const qs = params.toString();
4141
4239
  return this.http.get(
4142
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}${qs ? `?${qs}` : ""}`
4240
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}${qs ? `?${qs}` : ""}`
4143
4241
  );
4144
4242
  }
4145
4243
  /**
@@ -4148,7 +4246,7 @@ var DatabaseClient = class {
4148
4246
  async update(collection, documentId, updates) {
4149
4247
  const appId = this.getAppId();
4150
4248
  return this.http.put(
4151
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`,
4249
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`,
4152
4250
  updates
4153
4251
  );
4154
4252
  }
@@ -4158,19 +4256,19 @@ var DatabaseClient = class {
4158
4256
  async delete(collection, documentId) {
4159
4257
  const appId = this.getAppId();
4160
4258
  return this.http.delete(
4161
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`
4259
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`
4162
4260
  );
4163
4261
  }
4164
4262
  /**
4165
4263
  * List collections for the app.
4166
4264
  *
4167
- * Server route is `/api/db/:appId/collections`
4265
+ * Server route is `/api/v3/baas/db/:appId/collections`
4168
4266
  * (`database.controller.ts:106`). The previous bare-`:appId` GET 404'd
4169
4267
  * — Nest reserves that pattern for the document-find router below.
4170
4268
  */
4171
4269
  async listCollections() {
4172
4270
  const appId = this.getAppId();
4173
- return this.http.get(`/api/db/${encodePathParam(appId)}/collections`);
4271
+ return this.http.get(`/api/v3/baas/db/${encodePathParam(appId)}/collections`);
4174
4272
  }
4175
4273
  /**
4176
4274
  * Create a new collection in the database.
@@ -4180,7 +4278,7 @@ var DatabaseClient = class {
4180
4278
  */
4181
4279
  async createCollection(name) {
4182
4280
  const appId = this.getAppId();
4183
- return this.http.post(`/api/db/${encodePathParam(appId)}/collections`, { name });
4281
+ return this.http.post(`/api/v3/baas/db/${encodePathParam(appId)}/collections`, { name });
4184
4282
  }
4185
4283
  /**
4186
4284
  * Drop a collection and all its documents.
@@ -4191,7 +4289,7 @@ var DatabaseClient = class {
4191
4289
  async dropCollection(name) {
4192
4290
  const appId = this.getAppId();
4193
4291
  return this.http.delete(
4194
- `/api/db/${encodePathParam(appId)}/collections/${encodePathParam(name)}`
4292
+ `/api/v3/baas/db/${encodePathParam(appId)}/collections/${encodePathParam(name)}`
4195
4293
  );
4196
4294
  }
4197
4295
  // ========== State Proofs ==========
@@ -4200,7 +4298,7 @@ var DatabaseClient = class {
4200
4298
  */
4201
4299
  async getStateRoot() {
4202
4300
  const appId = this.getAppId();
4203
- return this.http.get(`/api/db/${encodePathParam(appId)}/state/root`);
4301
+ return this.http.get(`/api/v3/baas/db/${encodePathParam(appId)}/state/root`);
4204
4302
  }
4205
4303
  /**
4206
4304
  * Get a Merkle proof for a specific document
@@ -4208,7 +4306,7 @@ var DatabaseClient = class {
4208
4306
  async getDocumentProof(documentId) {
4209
4307
  const appId = this.getAppId();
4210
4308
  return this.http.get(
4211
- `/api/db/${encodePathParam(appId)}/${encodePathParam(documentId)}/proof`
4309
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(documentId)}/proof`
4212
4310
  );
4213
4311
  }
4214
4312
  /**
@@ -4222,7 +4320,7 @@ var DatabaseClient = class {
4222
4320
  if (options?.limit !== void 0) params.set("limit", String(options.limit));
4223
4321
  const qs = params.toString();
4224
4322
  return this.http.get(
4225
- `/api/db/${encodePathParam(appId)}/state/transitions${qs ? `?${qs}` : ""}`
4323
+ `/api/v3/baas/db/${encodePathParam(appId)}/state/transitions${qs ? `?${qs}` : ""}`
4226
4324
  );
4227
4325
  }
4228
4326
  /**
@@ -4230,7 +4328,7 @@ var DatabaseClient = class {
4230
4328
  */
4231
4329
  async getDbStats() {
4232
4330
  const appId = this.getAppId();
4233
- return this.http.get(`/api/db/${encodePathParam(appId)}/stats`);
4331
+ return this.http.get(`/api/v3/baas/db/${encodePathParam(appId)}/stats`);
4234
4332
  }
4235
4333
  };
4236
4334
 
@@ -4247,28 +4345,28 @@ var StorageClient = class {
4247
4345
  */
4248
4346
  async upload(file, filename, metadata) {
4249
4347
  const appId = this.getAppId();
4250
- return this.http.upload(`/api/storage/${encodePathParam(appId)}/upload`, file, filename, metadata);
4348
+ return this.http.upload(`/api/v3/baas/storage/${encodePathParam(appId)}/upload`, file, filename, metadata);
4251
4349
  }
4252
4350
  /**
4253
4351
  * Download a file by CID
4254
4352
  */
4255
4353
  async download(cid) {
4256
4354
  const appId = this.getAppId();
4257
- return this.http.get(`/api/storage/${encodePathParam(appId)}/download/${encodePathParam(cid)}`);
4355
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/download/${encodePathParam(cid)}`);
4258
4356
  }
4259
4357
  /**
4260
4358
  * Get file metadata
4261
4359
  */
4262
4360
  async getMetadata(cid) {
4263
4361
  const appId = this.getAppId();
4264
- return this.http.get(`/api/storage/${encodePathParam(appId)}/metadata/${encodePathParam(cid)}`);
4362
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/metadata/${encodePathParam(cid)}`);
4265
4363
  }
4266
4364
  /**
4267
4365
  * Delete a file
4268
4366
  */
4269
4367
  async delete(cid) {
4270
4368
  const appId = this.getAppId();
4271
- return this.http.delete(`/api/storage/${encodePathParam(appId)}/${encodePathParam(cid)}`);
4369
+ return this.http.delete(`/api/v3/baas/storage/${encodePathParam(appId)}/${encodePathParam(cid)}`);
4272
4370
  }
4273
4371
  /**
4274
4372
  * List all files for the app.
@@ -4283,21 +4381,21 @@ var StorageClient = class {
4283
4381
  if (pagination?.limit !== void 0) params.set("limit", String(pagination.limit));
4284
4382
  if (pagination?.offset !== void 0) params.set("offset", String(pagination.offset));
4285
4383
  const qs = params.toString();
4286
- return this.http.get(`/api/storage/${encodePathParam(appId)}/files${qs ? `?${qs}` : ""}`);
4384
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/files${qs ? `?${qs}` : ""}`);
4287
4385
  }
4288
4386
  /**
4289
4387
  * Get storage usage for the current app
4290
4388
  */
4291
4389
  async getUsage() {
4292
4390
  const appId = this.getAppId();
4293
- return this.http.get(`/api/storage/${encodePathParam(appId)}/usage`);
4391
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/usage`);
4294
4392
  }
4295
4393
  /**
4296
4394
  * Check if a file exists
4297
4395
  */
4298
4396
  async exists(cid) {
4299
4397
  const appId = this.getAppId();
4300
- return this.http.get(`/api/storage/${encodePathParam(appId)}/exists/${encodePathParam(cid)}`);
4398
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/exists/${encodePathParam(cid)}`);
4301
4399
  }
4302
4400
  };
4303
4401
 
@@ -4314,7 +4412,7 @@ var FunctionsClient = class {
4314
4412
  */
4315
4413
  async deploy(request) {
4316
4414
  const appId = this.getAppId();
4317
- return this.http.post(`/api/functions/${encodePathParam(appId)}`, request);
4415
+ return this.http.post(`/api/v3/baas/functions/${encodePathParam(appId)}`, request);
4318
4416
  }
4319
4417
  /**
4320
4418
  * Invoke a function
@@ -4322,7 +4420,7 @@ var FunctionsClient = class {
4322
4420
  async invoke(functionId, payload) {
4323
4421
  const appId = this.getAppId();
4324
4422
  return this.http.post(
4325
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/invoke`,
4423
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/invoke`,
4326
4424
  payload ?? {}
4327
4425
  );
4328
4426
  }
@@ -4331,7 +4429,7 @@ var FunctionsClient = class {
4331
4429
  */
4332
4430
  async list() {
4333
4431
  const appId = this.getAppId();
4334
- return this.http.get(`/api/functions/${encodePathParam(appId)}`);
4432
+ return this.http.get(`/api/v3/baas/functions/${encodePathParam(appId)}`);
4335
4433
  }
4336
4434
  /**
4337
4435
  * Get function details
@@ -4339,7 +4437,7 @@ var FunctionsClient = class {
4339
4437
  async get(functionId) {
4340
4438
  const appId = this.getAppId();
4341
4439
  return this.http.get(
4342
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`
4440
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`
4343
4441
  );
4344
4442
  }
4345
4443
  /**
@@ -4348,7 +4446,7 @@ var FunctionsClient = class {
4348
4446
  async update(functionId, updates) {
4349
4447
  const appId = this.getAppId();
4350
4448
  return this.http.put(
4351
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
4449
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
4352
4450
  updates
4353
4451
  );
4354
4452
  }
@@ -4358,7 +4456,7 @@ var FunctionsClient = class {
4358
4456
  async delete(functionId) {
4359
4457
  const appId = this.getAppId();
4360
4458
  return this.http.delete(
4361
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`
4459
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`
4362
4460
  );
4363
4461
  }
4364
4462
  /**
@@ -4372,7 +4470,7 @@ var FunctionsClient = class {
4372
4470
  if (options?.level) params.set("level", options.level);
4373
4471
  const qs = params.toString();
4374
4472
  return this.http.get(
4375
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/logs${qs ? `?${qs}` : ""}`
4473
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/logs${qs ? `?${qs}` : ""}`
4376
4474
  );
4377
4475
  }
4378
4476
  /**
@@ -4380,7 +4478,7 @@ var FunctionsClient = class {
4380
4478
  */
4381
4479
  async getStats() {
4382
4480
  const appId = this.getAppId();
4383
- return this.http.get(`/api/functions/${encodePathParam(appId)}/stats`);
4481
+ return this.http.get(`/api/v3/baas/functions/${encodePathParam(appId)}/stats`);
4384
4482
  }
4385
4483
  };
4386
4484
 
@@ -4397,28 +4495,28 @@ var MessagingClient = class {
4397
4495
  */
4398
4496
  async createChannel(config) {
4399
4497
  const appId = this.getAppId();
4400
- return this.http.post(`/api/messaging/${encodePathParam(appId)}/channels`, config);
4498
+ return this.http.post(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels`, config);
4401
4499
  }
4402
4500
  /**
4403
4501
  * Delete a channel
4404
4502
  */
4405
4503
  async deleteChannel(channelId) {
4406
4504
  const appId = this.getAppId();
4407
- return this.http.delete(`/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`);
4505
+ return this.http.delete(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`);
4408
4506
  }
4409
4507
  /**
4410
4508
  * Get a channel by ID
4411
4509
  */
4412
4510
  async getChannel(channelId) {
4413
4511
  const appId = this.getAppId();
4414
- return this.http.get(`/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`);
4512
+ return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`);
4415
4513
  }
4416
4514
  /**
4417
4515
  * List all channels for the app
4418
4516
  */
4419
4517
  async listChannels() {
4420
4518
  const appId = this.getAppId();
4421
- return this.http.get(`/api/messaging/${encodePathParam(appId)}/channels`);
4519
+ return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels`);
4422
4520
  }
4423
4521
  /**
4424
4522
  * Publish a message to a channel
@@ -4426,7 +4524,7 @@ var MessagingClient = class {
4426
4524
  async publish(channel, message, metadata) {
4427
4525
  const appId = this.getAppId();
4428
4526
  return this.http.post(
4429
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/publish`,
4527
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/publish`,
4430
4528
  { data: message, metadata }
4431
4529
  );
4432
4530
  }
@@ -4441,7 +4539,7 @@ var MessagingClient = class {
4441
4539
  if (options?.after) params.set("after", options.after);
4442
4540
  const qs = params.toString();
4443
4541
  return this.http.get(
4444
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/history${qs ? `?${qs}` : ""}`
4542
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/history${qs ? `?${qs}` : ""}`
4445
4543
  );
4446
4544
  }
4447
4545
  /**
@@ -4455,7 +4553,7 @@ var MessagingClient = class {
4455
4553
  async setPresence(channel, member) {
4456
4554
  const appId = this.getAppId();
4457
4555
  return this.http.post(
4458
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`,
4556
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`,
4459
4557
  member
4460
4558
  );
4461
4559
  }
@@ -4463,7 +4561,7 @@ var MessagingClient = class {
4463
4561
  * Remove a member's presence from a channel.
4464
4562
  *
4465
4563
  * BREAKING CHANGE (SDK 3.3.0): server route is
4466
- * `/api/messaging/:appId/channels/:channel/presence/:clientId`
4564
+ * `/api/v3/baas/messaging/:appId/channels/:channel/presence/:clientId`
4467
4565
  * (`messaging.controller.ts:352`). `channel` is now the first arg and
4468
4566
  * `clientId` (not `memberId`) the second — they're the same identifier
4469
4567
  * but renamed to match the server param.
@@ -4471,7 +4569,7 @@ var MessagingClient = class {
4471
4569
  async removePresence(channel, clientId) {
4472
4570
  const appId = this.getAppId();
4473
4571
  return this.http.delete(
4474
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence/${encodePathParam(clientId)}`
4572
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence/${encodePathParam(clientId)}`
4475
4573
  );
4476
4574
  }
4477
4575
  /**
@@ -4480,7 +4578,7 @@ var MessagingClient = class {
4480
4578
  async getPresence(channel) {
4481
4579
  const appId = this.getAppId();
4482
4580
  return this.http.get(
4483
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`
4581
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`
4484
4582
  );
4485
4583
  }
4486
4584
  /**
@@ -4488,7 +4586,7 @@ var MessagingClient = class {
4488
4586
  */
4489
4587
  async getStats() {
4490
4588
  const appId = this.getAppId();
4491
- return this.http.get(`/api/messaging/${encodePathParam(appId)}/stats`);
4589
+ return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/stats`);
4492
4590
  }
4493
4591
  };
4494
4592
 
@@ -4504,21 +4602,21 @@ var CustomerSessionClient = class {
4504
4602
  * Step 1: ask the host to issue a fresh challenge for the customer to sign.
4505
4603
  */
4506
4604
  async challenge(input) {
4507
- return this.fetch("POST", "/api/customer-session/challenge", input);
4605
+ return this.fetch("POST", "/api/v3/baas/customer-session/challenge", input);
4508
4606
  }
4509
4607
  /**
4510
4608
  * Step 2: submit the customer's signed challenge. On success returns a
4511
4609
  * short-lived bearer JWT scoped to {appId, chain, address}.
4512
4610
  */
4513
4611
  async verify(req) {
4514
- return this.fetch("POST", "/api/customer-session/verify", req);
4612
+ return this.fetch("POST", "/api/v3/baas/customer-session/verify", req);
4515
4613
  }
4516
4614
  /**
4517
4615
  * Validate a customer bearer + return the decoded session info. Used by
4518
4616
  * smart-app backends to authorise incoming customer requests.
4519
4617
  */
4520
4618
  async validate(bearer) {
4521
- return this.fetch("GET", "/api/customer-session/validate", void 0, bearer);
4619
+ return this.fetch("GET", "/api/v3/baas/customer-session/validate", void 0, bearer);
4522
4620
  }
4523
4621
  /**
4524
4622
  * Revoke a customer session. Idempotent.
@@ -4526,7 +4624,7 @@ var CustomerSessionClient = class {
4526
4624
  async end(bearer) {
4527
4625
  return this.fetch(
4528
4626
  "POST",
4529
- "/api/customer-session/end",
4627
+ "/api/v3/baas/customer-session/end",
4530
4628
  void 0,
4531
4629
  bearer
4532
4630
  );
@@ -4572,15 +4670,15 @@ var RulesClient = class {
4572
4670
  http;
4573
4671
  /** Publish a canonical ValidatorRules document to HCS. */
4574
4672
  async publish(rule) {
4575
- return this.http.post("/api/rules/publish", rule);
4673
+ return this.http.post("/api/v3/baas/rules/publish", rule);
4576
4674
  }
4577
4675
  /** Fetch a published rule by its HCS consensus timestamp. */
4578
4676
  async get(consensusTimestamp) {
4579
- return this.http.get(`/api/rules/${encodePathParam(consensusTimestamp)}`);
4677
+ return this.http.get(`/api/v3/baas/rules/${encodePathParam(consensusTimestamp)}`);
4580
4678
  }
4581
4679
  /** List rules owned by the authenticated entity, optionally filtered by type. */
4582
4680
  async listByOwner(filter) {
4583
- const path = filter?.type ? `/api/rules?type=${encodeURIComponent(filter.type)}` : "/api/rules";
4681
+ const path = filter?.type ? `/api/v3/baas/rules?type=${encodeURIComponent(filter.type)}` : "/api/v3/baas/rules";
4584
4682
  return this.http.get(path);
4585
4683
  }
4586
4684
  /**
@@ -4588,44 +4686,332 @@ var RulesClient = class {
4588
4686
  * `ruleRef` (published) or `rule` (inline) must be supplied by the caller.
4589
4687
  */
4590
4688
  async simulate(params) {
4591
- return this.http.post("/api/rules/simulate", params);
4689
+ return this.http.post("/api/v3/baas/rules/simulate", params);
4592
4690
  }
4593
4691
  /** Walk the version history of a published rule. */
4594
4692
  async getVersionHistory(consensusTimestamp) {
4595
4693
  return this.http.get(
4596
- `/api/rules/${encodePathParam(consensusTimestamp)}/versions`
4694
+ `/api/v3/baas/rules/${encodePathParam(consensusTimestamp)}/versions`
4597
4695
  );
4598
4696
  }
4599
4697
  /** Deprecate a published rule (owner-only). */
4600
4698
  async deprecate(consensusTimestamp) {
4601
4699
  return this.http.post(
4602
- `/api/rules/${encodePathParam(consensusTimestamp)}/deprecate`,
4700
+ `/api/v3/baas/rules/${encodePathParam(consensusTimestamp)}/deprecate`,
4603
4701
  {}
4604
4702
  );
4605
4703
  }
4606
4704
  };
4607
4705
 
4608
4706
  // src/baas/entities/client.ts
4609
- var EntitiesClient = class {
4707
+ var EntitiesClient = class _EntitiesClient {
4610
4708
  constructor(http) {
4611
4709
  this.http = http;
4612
4710
  }
4613
4711
  http;
4614
- /** Create a canonical token entity bound to a published rule. */
4712
+ /**
4713
+ * Chains whose token-create routes through the payer-funded 3-step (prepare →
4714
+ * fund → execute), mirroring `createAccount`. Hedera = real HTS TokenCreate
4715
+ * (admin/supply = the per-entity DKG slot-pubkey KeyList; treasury = the
4716
+ * entity's own account; `0.0.X` token id is network-assigned, resolved from the
4717
+ * receipt via the threaded `createTxId`). Cardano/Solana/Polkadot = the
4718
+ * AUTHORITY entity (the entity IS the policy/mint/Assets-admin multisig — same
4719
+ * address as an account; the asset MINT itself is a later operate-tab payer
4720
+ * call). XRPL/Stellar token = an ISSUER ACCOUNT (reuses the account preparer) +
4721
+ * issuer flags set at finalize: XRPL relays the funding Payment then finalizes
4722
+ * (issuer-flag AccountSets + SignerListSet + disable-master); Stellar relays the
4723
+ * CreateAccount then finalizes (SetOptions install incl. issuer setFlags +
4724
+ * master lock). Every OTHER chain (EVM) stays on the legacy synchronous path.
4725
+ */
4726
+ static PAYER_FUNDED_TOKEN_CHAINS = /* @__PURE__ */ new Set([
4727
+ "hedera",
4728
+ "cardano",
4729
+ "solana",
4730
+ "polkadot",
4731
+ "xrpl",
4732
+ "stellar"
4733
+ ]);
4734
+ /**
4735
+ * PREPARE half of the payer-funded token-create flow.
4736
+ *
4737
+ * POSTs `/api/v3/baas/entities/prepare-create` with `entityType: 'token'`. The cluster
4738
+ * runs the per-entity DKG, builds the payer-funded create (Hedera: TokenCreate
4739
+ * keyed by the slot-pubkey KeyList with the entity account as treasury;
4740
+ * Cardano/Solana/Polkadot: funds/provisions the authority multisig), and returns
4741
+ * the prepared blob. The prepared `transactionId` is the `createTxId` for
4742
+ * execute (Hedera).
4743
+ */
4744
+ async prepareCreateToken(req) {
4745
+ return this.http.post("/api/v3/baas/entities/prepare-create", {
4746
+ entityType: "token",
4747
+ ...req
4748
+ });
4749
+ }
4750
+ /**
4751
+ * EXECUTE half of the payer-funded token-create flow.
4752
+ *
4753
+ * POSTs `/api/v3/baas/entities/execute-create` with `entityType: 'token'`. For Hedera,
4754
+ * pass `createTxId` (the prepared create's `transactionId`) so the validator
4755
+ * resolves the network-assigned `0.0.X` token id from the receipt and stamps
4756
+ * `chainAccounts.hedera`. For the authority-entity chains (cardano/solana/
4757
+ * polkadot) execute just verifies the binding and echoes the stamped authority
4758
+ * address (no `createTxId` needed).
4759
+ */
4760
+ async executeCreateToken(req) {
4761
+ const { createTxId, signedFundingBlob, ...rest } = req;
4762
+ return this.http.post("/api/v3/baas/entities/execute-create", {
4763
+ ...rest,
4764
+ ...createTxId !== void 0 ? { createTxId } : {},
4765
+ ...signedFundingBlob !== void 0 ? { signedFundingBlob } : {},
4766
+ entityType: "token"
4767
+ });
4768
+ }
4769
+ /**
4770
+ * Create a canonical token entity bound to a published rule.
4771
+ *
4772
+ * Dispatches by `chain` (mirrors `createAccount`):
4773
+ * - **Hedera / Cardano / Solana / Polkadot** = payer-funded 3-step (prepare →
4774
+ * caller funds via `fundWith` → execute). Hedera resolves the network-assigned
4775
+ * `0.0.X` token id from the receipt (threads `createTxId`); the authority-
4776
+ * entity chains verify/echo the stamped authority address. `fundWith` is
4777
+ * REQUIRED; to drive the steps manually call `prepareCreateToken` /
4778
+ * `executeCreateToken` directly.
4779
+ * - **XRPL / Stellar** = payer-funded too (account-model issuer): `fundWith`
4780
+ * REQUIRED; the caller's signed funding blob is RELAYED to the validator,
4781
+ * which submits it then finalizes the issuer multisig (master-locked). NO
4782
+ * issuer flags are set at create — issuer auth flags / DefaultRipple / clawback
4783
+ * are an operate-tab, rules-validated concern.
4784
+ * - **EVM / other** = legacy synchronous `POST /api/v3/baas/entities/createToken`
4785
+ * (payer-funded-only fields ignored) until it migrates.
4786
+ */
4615
4787
  async createToken(req) {
4616
- return this.http.post("/api/entities/createToken", req);
4788
+ if (_EntitiesClient.PAYER_FUNDED_TOKEN_CHAINS.has(req.chain)) {
4789
+ const { fundWith, ...prepReq } = req;
4790
+ const prep = await this.prepareCreateToken(prepReq);
4791
+ if (!fundWith) {
4792
+ throw new Error(
4793
+ `createToken(${req.chain}): pass fundWith (sign+submit the prepared create tx), or call prepareCreateToken/executeCreateToken directly`
4794
+ );
4795
+ }
4796
+ const funded = await fundWith(prep.prepared, {
4797
+ address: prep.address,
4798
+ reserveRequirement: prep.reserveRequirement
4799
+ });
4800
+ return this.executeCreateToken({
4801
+ entityId: prep.entityId,
4802
+ chain: req.chain,
4803
+ securityMode: req.securityMode,
4804
+ signedFundingBlob: _EntitiesClient.FUNDING_BLOB_RELAY_CHAINS.has(req.chain) ? funded?.signedFundingBlob : void 0,
4805
+ createTxId: req.chain === "hedera" ? prep.prepared?.[0]?.transactionId : void 0
4806
+ });
4807
+ }
4808
+ const {
4809
+ fundWith: _ignoredFundWith,
4810
+ payerAccountId: _ignoredPayer,
4811
+ securityMode: _ignoredSecurityMode,
4812
+ ...legacyReq
4813
+ } = req;
4814
+ return this.http.post("/api/v3/baas/entities/createToken", legacyReq);
4617
4815
  }
4618
- /** Create a canonical account entity bound to a published rule. */
4816
+ /**
4817
+ * PREPARE half of the payer-funded account-create flow.
4818
+ *
4819
+ * POSTs `/api/v3/baas/entities/prepare-create`. The cluster runs the per-entity DKG
4820
+ * (persists the binding, submits nothing on-chain) and returns the unsigned
4821
+ * payer-funding `Payment`(s) the caller signs + submits with their own wallet.
4822
+ */
4823
+ async prepareCreateAccount(req) {
4824
+ return this.http.post("/api/v3/baas/entities/prepare-create", {
4825
+ entityType: "account",
4826
+ ...req
4827
+ });
4828
+ }
4829
+ /**
4830
+ * EXECUTE half of the payer-funded account-create flow.
4831
+ *
4832
+ * POSTs `/api/v3/baas/entities/execute-create`. The entity already exists (its DKG
4833
+ * ran during prepare); pass `signedFundingBlob` for the validator to submit
4834
+ * the payer's signed funding `Payment` (XRPL only), or omit it when the caller
4835
+ * already submitted the funding tx themselves (then execute just finalizes /
4836
+ * verifies).
4837
+ *
4838
+ * `createTxId` is the HEDERA thread: a Hedera AccountCreate gets its
4839
+ * network-assigned `0.0.X` id only from the on-chain receipt after the payer
4840
+ * submits. The caller threads the prepared create's `transactionId` (from
4841
+ * `prepared[0].transactionId`) back here so the validator resolves the id from
4842
+ * the receipt server-side. Ignored for non-Hedera chains.
4843
+ */
4844
+ async executeCreateAccount(req) {
4845
+ const { createTxId, ...rest } = req;
4846
+ return this.http.post("/api/v3/baas/entities/execute-create", {
4847
+ ...rest,
4848
+ ...createTxId !== void 0 ? { createTxId } : {}
4849
+ });
4850
+ }
4851
+ /**
4852
+ * Chains whose account-create routes through the payer-funded 3-step
4853
+ * (prepare → fund → execute). All are ledgers where the validators never pay:
4854
+ * XRPL funds a reserve; Bitcoin funds a P2WSH UTXO; Cardano funds a
4855
+ * native-script enterprise address above min-UTXO; Polkadot funds a
4856
+ * pallet_multisig SS58 above the existential deposit; Solana funds a Squads
4857
+ * multisig PDA (deterministic from the createKey) via a payer-paid
4858
+ * `multisigCreateV2` — the payer's submission IS the create (no separate
4859
+ * finalizer). Hedera is create-WITH-KEY: the payer submits an AccountCreate
4860
+ * whose controlling key is the per-entity DKG slot-pubkey KeyList, so the
4861
+ * payer's submit IS the create; its `0.0.X` id is network-assigned (resolved
4862
+ * from the receipt at execute-create via the threaded `createTxId`). Stellar is
4863
+ * account-MODEL (like XRPL): the payer funds the entity's slot-0 `G...` master
4864
+ * via a CreateAccount, the validator RELAYS the signed funding blob, then
4865
+ * execute-create finalizes on-chain (threshold-signs a SetOptions installing
4866
+ * the validator chain-key multisig + locking the master). EVM stays on the
4867
+ * legacy synchronous create until it migrates.
4868
+ */
4869
+ static PAYER_FUNDED_CREATE_CHAINS = /* @__PURE__ */ new Set([
4870
+ "xrpl",
4871
+ "bitcoin",
4872
+ "cardano",
4873
+ "polkadot",
4874
+ "solana",
4875
+ "hedera",
4876
+ "stellar"
4877
+ ]);
4878
+ /**
4879
+ * Chains whose execute-create RELAYS the payer's signed funding blob for the
4880
+ * validator to submit (then finalizes on-chain). Both are account-model ledgers
4881
+ * with a validator-side finalize step: XRPL (SignerListSet + disable-master),
4882
+ * Stellar (SetOptions install + master lock). Every OTHER payer-funded chain
4883
+ * has the PAYER submit the funding tx directly with their own wallet — their
4884
+ * execute-create REJECTS a non-undefined `signedFundingBlob` (400), so the blob
4885
+ * is omitted for them.
4886
+ */
4887
+ static FUNDING_BLOB_RELAY_CHAINS = /* @__PURE__ */ new Set(["xrpl", "stellar"]);
4888
+ /**
4889
+ * Create a canonical account entity bound to a published rule.
4890
+ *
4891
+ * Dispatches by `chain`:
4892
+ * - **XRPL / Stellar / Bitcoin / Cardano / Polkadot / Solana / Hedera** =
4893
+ * payer-funded 3-step (prepare → fund → execute). The cluster runs the
4894
+ * per-entity DKG and returns the unsigned payer-funding tx(s); the
4895
+ * caller-supplied `fundWith` callback signs + submits (or just signs) the
4896
+ * funding tx with their OWN wallet — the SDK never holds the customer's chain
4897
+ * key nor opens a network connection — then `executeCreateAccount` finalizes
4898
+ * (XRPL + Stellar finalize on-chain after relaying the funding blob; the
4899
+ * deterministic ledgers + Solana verify/stamp the binding; Hedera resolves
4900
+ * the network-assigned id from the receipt). `fundWith` is REQUIRED on these
4901
+ * chains; to drive the steps manually call `prepareCreateAccount` /
4902
+ * `executeCreateAccount` directly.
4903
+ * - **other chains** (EVM) = legacy synchronous create — a single
4904
+ * `POST /api/v3/baas/entities/createAccount`, unchanged from pre-3.9.0. These chains
4905
+ * migrate to the payer-funded flow in a later phase; until then the
4906
+ * payer-funded-only fields (`fundWith` / `payerAccountId` / `securityMode`)
4907
+ * are ignored.
4908
+ */
4619
4909
  async createAccount(req) {
4620
- return this.http.post("/api/entities/createAccount", req);
4910
+ if (_EntitiesClient.PAYER_FUNDED_CREATE_CHAINS.has(req.chain)) {
4911
+ const { fundWith, ...prepReq } = req;
4912
+ const prep = await this.prepareCreateAccount(prepReq);
4913
+ if (!fundWith) {
4914
+ throw new Error(
4915
+ `createAccount(${req.chain}): pass fundWith (sign+submit the prepared funding tx), or call prepareCreateAccount/executeCreateAccount directly`
4916
+ );
4917
+ }
4918
+ const funded = await fundWith(prep.prepared, {
4919
+ address: prep.address,
4920
+ reserveRequirement: prep.reserveRequirement
4921
+ });
4922
+ return this.executeCreateAccount({
4923
+ entityId: prep.entityId,
4924
+ chain: req.chain,
4925
+ securityMode: req.securityMode,
4926
+ signedFundingBlob: _EntitiesClient.FUNDING_BLOB_RELAY_CHAINS.has(req.chain) ? funded?.signedFundingBlob : void 0,
4927
+ createTxId: req.chain === "hedera" ? prep.prepared?.[0]?.transactionId : void 0
4928
+ });
4929
+ }
4930
+ const {
4931
+ fundWith: _ignoredFundWith,
4932
+ payerAccountId: _ignoredPayer,
4933
+ securityMode: _ignoredSecurityMode,
4934
+ ...legacyReq
4935
+ } = req;
4936
+ return this.http.post("/api/v3/baas/entities/createAccount", legacyReq);
4937
+ }
4938
+ /**
4939
+ * PREPARE half of the payer-funded topic-create flow (Hedera).
4940
+ *
4941
+ * POSTs `/api/v3/baas/entities/prepare-create` with `entityType: 'topic'`. The cluster
4942
+ * runs the per-entity DKG (persists the binding), builds the payer-funded
4943
+ * TopicCreate keyed by the slot-pubkey KeyList, attaches the validator admin
4944
+ * threshold sig, and returns the prepared blob for the caller to add the fee
4945
+ * sig + submit. The prepared `transactionId` is the `createTxId` for execute.
4946
+ */
4947
+ async prepareCreateTopic(req) {
4948
+ return this.http.post("/api/v3/baas/entities/prepare-create", {
4949
+ entityType: "topic",
4950
+ ...req
4951
+ });
4952
+ }
4953
+ /**
4954
+ * EXECUTE half of the payer-funded topic-create flow (Hedera).
4955
+ *
4956
+ * POSTs `/api/v3/baas/entities/execute-create` with `entityType: 'topic'`. The topic
4957
+ * already exists once the payer submitted the create tx; pass `createTxId` (the
4958
+ * prepared create's `transactionId`) so the validator resolves the network-
4959
+ * assigned `0.0.X` topic id from the receipt and stamps `chainAccounts.hedera`.
4960
+ */
4961
+ async executeCreateTopic(req) {
4962
+ return this.http.post("/api/v3/baas/entities/execute-create", {
4963
+ ...req,
4964
+ entityType: "topic"
4965
+ });
4621
4966
  }
4622
- /** Create a canonical topic entity bound to a published rule. */
4967
+ /**
4968
+ * Create a canonical topic entity bound to a published rule.
4969
+ *
4970
+ * Dispatches by `chain`:
4971
+ * - **Hedera** = payer-funded 3-step (prepare → caller submits the TopicCreate
4972
+ * via `fundWith` → execute resolves the `0.0.X` topic id from the receipt).
4973
+ * `fundWith` is REQUIRED; to drive the steps manually call
4974
+ * `prepareCreateTopic` / `executeCreateTopic` directly.
4975
+ * - **other chains** = legacy synchronous `POST /api/v3/baas/entities/createTopic`
4976
+ * (topics are a Hedera primitive; the legacy path is unchanged).
4977
+ */
4623
4978
  async createTopic(req) {
4624
- return this.http.post("/api/entities/createTopic", req);
4979
+ if (req.chain === "hedera") {
4980
+ const { fundWith, ...prepReq } = req;
4981
+ const prep = await this.prepareCreateTopic(prepReq);
4982
+ if (!fundWith) {
4983
+ throw new Error(
4984
+ "createTopic(hedera): pass fundWith (sign+submit the prepared TopicCreate), or call prepareCreateTopic/executeCreateTopic directly"
4985
+ );
4986
+ }
4987
+ await fundWith(prep.prepared, {
4988
+ address: prep.address,
4989
+ reserveRequirement: prep.reserveRequirement
4990
+ });
4991
+ const createTxId = prep.prepared?.[0]?.transactionId;
4992
+ if (!createTxId) {
4993
+ throw new Error(
4994
+ "createTopic(hedera): prepared TopicCreate carries no transactionId \u2014 cannot resolve the topic id from the receipt"
4995
+ );
4996
+ }
4997
+ return this.executeCreateTopic({
4998
+ entityId: prep.entityId,
4999
+ chain: req.chain,
5000
+ createTxId,
5001
+ securityMode: req.securityMode
5002
+ });
5003
+ }
5004
+ const {
5005
+ fundWith: _ignoredFundWith,
5006
+ payerAccountId: _ignoredPayer,
5007
+ securityMode: _ignoredSecurityMode,
5008
+ ...legacyReq
5009
+ } = req;
5010
+ return this.http.post("/api/v3/baas/entities/createTopic", legacyReq);
4625
5011
  }
4626
5012
  /** Create a canonical agent entity bound to a published rule. */
4627
5013
  async createAgent(req) {
4628
- return this.http.post("/api/entities/createAgent", req);
5014
+ return this.http.post("/api/v3/baas/entities/createAgent", req);
4629
5015
  }
4630
5016
  /**
4631
5017
  * Mega-helper: build a token rule with a launchpad ModuleEntry attached,
@@ -4633,15 +5019,15 @@ var EntitiesClient = class {
4633
5019
  * round-trip.
4634
5020
  */
4635
5021
  async launchpad(req) {
4636
- return this.http.post("/api/entities/launchpad", req);
5022
+ return this.http.post("/api/v3/baas/entities/launchpad", req);
4637
5023
  }
4638
5024
  /** Fetch an entity by its canonical `entityId`. */
4639
5025
  async get(entityId) {
4640
- return this.http.get(`/api/entities/${encodePathParam(entityId)}`);
5026
+ return this.http.get(`/api/v3/baas/entities/${encodePathParam(entityId)}`);
4641
5027
  }
4642
5028
  /** List entities owned by the authenticated wallet, optionally filtered by type. */
4643
5029
  async listByOwner(filter) {
4644
- const path = filter?.type ? `/api/entities?type=${encodeURIComponent(filter.type)}` : "/api/entities";
5030
+ const path = filter?.type ? `/api/v3/baas/entities?type=${encodeURIComponent(filter.type)}` : "/api/v3/baas/entities";
4645
5031
  return this.http.get(path);
4646
5032
  }
4647
5033
  };
@@ -4654,6 +5040,13 @@ var BaasClient = class _BaasClient {
4654
5040
  timeout;
4655
5041
  allowInsecure;
4656
5042
  http;
5043
+ /**
5044
+ * Validator-routed HTTP client for the `/api/v3/transactions/*` prepare/execute
5045
+ * surface — a SIBLING of `/host`, NOT under the `pathPrefix`. Rooted at the
5046
+ * raw gateway/ingress origin (`hostUrl`) so transactions reach the validator
5047
+ * even when BaaS traffic is gateway-routed at `/host/*`.
5048
+ */
5049
+ txHttp;
4657
5050
  /** Last HTTP error (for getHttpHealth) */
4658
5051
  lastHttpError;
4659
5052
  /**
@@ -4682,6 +5075,14 @@ var BaasClient = class _BaasClient {
4682
5075
  rules;
4683
5076
  /** Canonical entity authoring surface (token/account/topic/agent + launchpad). */
4684
5077
  entities;
5078
+ /**
5079
+ * Validator-routed transaction prepare/execute (sovereignty model). The
5080
+ * prepare endpoints accept an explicit `payerAccountId` for the session-less
5081
+ * payer path, OR carry the web3-auth session token for the JWT-wallet payer
5082
+ * path (kept in sync with the main client's token — see {@link authenticate}).
5083
+ * Targets `/api/v3/transactions/*`, a sibling of the `/host` BaaS surface.
5084
+ */
5085
+ transactions;
4685
5086
  constructor(config) {
4686
5087
  this.allowInsecure = config.allowInsecure ?? false;
4687
5088
  this.hostUrl = validateUrl2(config.hostUrl, this.allowInsecure);
@@ -4695,7 +5096,12 @@ var BaasClient = class _BaasClient {
4695
5096
  timeout: this.timeout,
4696
5097
  // Transparent session refresh: on a 401, re-run the challenge-response
4697
5098
  // with the retained signer and retry once. No-op until authenticate() has
4698
- // been called (authContext set). Excludes /api/auth/* (see http client).
5099
+ // been called (authContext set). Excludes /api/v3/{,baas/}auth/* (see http client).
5100
+ onUnauthorized: () => this.reauthenticate()
5101
+ });
5102
+ this.txHttp = createHttpClient({
5103
+ baseUrl: `${this.hostUrl.replace(/\/$/, "")}/api/v3/transactions`,
5104
+ timeout: this.timeout,
4699
5105
  onUnauthorized: () => this.reauthenticate()
4700
5106
  });
4701
5107
  const getAppId = () => this.requireAppId();
@@ -4708,6 +5114,7 @@ var BaasClient = class _BaasClient {
4708
5114
  this.customerSession = new CustomerSessionClient(baseUrlWithPrefix, this.timeout);
4709
5115
  this.rules = new RulesClient(this.http);
4710
5116
  this.entities = new EntitiesClient(this.http);
5117
+ this.transactions = new TransactionsClient(this.txHttp);
4711
5118
  }
4712
5119
  /**
4713
5120
  * Connect to the Smart Engines BaaS via cluster auto-discovery.
@@ -4835,7 +5242,7 @@ var BaasClient = class _BaasClient {
4835
5242
  this.authContext = options;
4836
5243
  let challenge;
4837
5244
  try {
4838
- challenge = await this.http.post("/api/auth/challenge", {
5245
+ challenge = await this.http.post("/api/v3/baas/auth/challenge", {
4839
5246
  chain,
4840
5247
  walletAddress,
4841
5248
  appId: this.appId
@@ -4846,7 +5253,7 @@ var BaasClient = class _BaasClient {
4846
5253
  const signature = await signFn(challenge.message);
4847
5254
  let result;
4848
5255
  try {
4849
- result = await this.http.post("/api/auth/verify", {
5256
+ result = await this.http.post("/api/v3/baas/auth/verify", {
4850
5257
  challengeId: challenge.challengeId,
4851
5258
  signature,
4852
5259
  publicKey
@@ -4855,6 +5262,7 @@ var BaasClient = class _BaasClient {
4855
5262
  throw asBaasError(err);
4856
5263
  }
4857
5264
  this.http.setAuthToken(result.token);
5265
+ this.txHttp.setAuthToken(result.token);
4858
5266
  return result;
4859
5267
  }
4860
5268
  /**
@@ -4862,30 +5270,31 @@ var BaasClient = class _BaasClient {
4862
5270
  * session token. Invoked by the http client's `onUnauthorized` hook when a
4863
5271
  * request 401s because the token expired — so long-lived clients keep working
4864
5272
  * without the caller re-implementing refresh. No-op if {@link authenticate}
4865
- * was never called. The `/api/auth/*` calls below are excluded from the http
5273
+ * was never called. The `/api/v3/baas/auth/*` calls below are excluded from the http
4866
5274
  * client's 401-retry path, so this can never recurse.
4867
5275
  */
4868
5276
  async reauthenticate() {
4869
5277
  const ctx = this.authContext;
4870
5278
  if (!ctx) return;
4871
- const challenge = await this.http.post("/api/auth/challenge", {
5279
+ const challenge = await this.http.post("/api/v3/baas/auth/challenge", {
4872
5280
  chain: ctx.chain,
4873
5281
  walletAddress: ctx.walletAddress,
4874
5282
  appId: this.appId
4875
5283
  });
4876
5284
  const signature = await ctx.signFn(challenge.message);
4877
- const result = await this.http.post("/api/auth/verify", {
5285
+ const result = await this.http.post("/api/v3/baas/auth/verify", {
4878
5286
  challengeId: challenge.challengeId,
4879
5287
  signature,
4880
5288
  publicKey: ctx.publicKey
4881
5289
  });
4882
5290
  this.http.setAuthToken(result.token);
5291
+ this.txHttp.setAuthToken(result.token);
4883
5292
  }
4884
5293
  /** Validate the current session */
4885
5294
  async validateSession() {
4886
5295
  this.requireAuth();
4887
5296
  try {
4888
- return await this.http.get("/api/auth/session");
5297
+ return await this.http.get("/api/v3/baas/auth/session");
4889
5298
  } catch (err) {
4890
5299
  throw asBaasError(err);
4891
5300
  }
@@ -4894,11 +5303,12 @@ var BaasClient = class _BaasClient {
4894
5303
  async logout() {
4895
5304
  if (this.http.getAuthToken()) {
4896
5305
  try {
4897
- await this.http.post("/api/auth/logout", {});
5306
+ await this.http.post("/api/v3/baas/auth/logout", {});
4898
5307
  } catch {
4899
5308
  }
4900
5309
  }
4901
5310
  this.http.setAuthToken(void 0);
5311
+ this.txHttp.setAuthToken(void 0);
4902
5312
  }
4903
5313
  // ========== HTTP Helpers ==========
4904
5314
  requireAuth() {