@hsuite/smart-engines-sdk 3.7.0 → 3.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1152,7 +1152,7 @@ var SdkHttpError = class extends Error {
1152
1152
  };
1153
1153
  function createHttpClient(config) {
1154
1154
  const timeout = config.timeout ?? 3e4;
1155
- function getHeaders(contentType) {
1155
+ function getHeaders(contentType, opts) {
1156
1156
  const headers = {};
1157
1157
  if (contentType) {
1158
1158
  headers["Content-Type"] = contentType;
@@ -1163,6 +1163,12 @@ function createHttpClient(config) {
1163
1163
  if (config.apiKey) {
1164
1164
  headers["X-API-Key"] = config.apiKey;
1165
1165
  }
1166
+ if (opts?.customerToken) {
1167
+ headers["X-Customer-Session-Token"] = opts.customerToken;
1168
+ }
1169
+ if (opts?.headers) {
1170
+ Object.assign(headers, opts.headers);
1171
+ }
1166
1172
  return headers;
1167
1173
  }
1168
1174
  function setAuthToken(token) {
@@ -1171,14 +1177,14 @@ function createHttpClient(config) {
1171
1177
  function getAuthToken() {
1172
1178
  return config.authToken;
1173
1179
  }
1174
- async function request(method, path, body) {
1180
+ async function request(method, path, body, opts) {
1175
1181
  const url = `${config.baseUrl}${path}`;
1176
1182
  const controller = new AbortController();
1177
1183
  const timeoutId = setTimeout(() => controller.abort(), timeout);
1178
1184
  try {
1179
1185
  const init = {
1180
1186
  method,
1181
- headers: getHeaders("application/json"),
1187
+ headers: getHeaders("application/json", opts),
1182
1188
  signal: controller.signal
1183
1189
  };
1184
1190
  if (body !== void 0) {
@@ -1207,14 +1213,14 @@ function createHttpClient(config) {
1207
1213
  throw new SdkHttpError(`Network error: ${err.message}`, 0, error);
1208
1214
  }
1209
1215
  }
1210
- async function getText(path) {
1216
+ async function getText(path, opts) {
1211
1217
  const url = `${config.baseUrl}${path}`;
1212
1218
  const controller = new AbortController();
1213
1219
  const timeoutId = setTimeout(() => controller.abort(), timeout);
1214
1220
  try {
1215
1221
  const response = await fetch(url, {
1216
1222
  method: "GET",
1217
- headers: getHeaders(),
1223
+ headers: getHeaders(void 0, opts),
1218
1224
  signal: controller.signal
1219
1225
  });
1220
1226
  clearTimeout(timeoutId);
@@ -1237,7 +1243,37 @@ function createHttpClient(config) {
1237
1243
  throw new SdkHttpError(`Network error: ${err.message}`, 0, error);
1238
1244
  }
1239
1245
  }
1240
- async function upload(path, file, filename, metadata, fieldName = "file") {
1246
+ async function getBinary(path, opts) {
1247
+ const url = `${config.baseUrl}${path}`;
1248
+ const controller = new AbortController();
1249
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
1250
+ try {
1251
+ const response = await fetch(url, {
1252
+ method: "GET",
1253
+ headers: getHeaders(void 0, opts),
1254
+ signal: controller.signal
1255
+ });
1256
+ clearTimeout(timeoutId);
1257
+ if (!response.ok) {
1258
+ const errBody = await response.json().catch(() => ({}));
1259
+ throw new SdkHttpError(
1260
+ errBody.message || `API error: ${response.status} ${response.statusText}`,
1261
+ response.status,
1262
+ errBody
1263
+ );
1264
+ }
1265
+ return new Uint8Array(await response.arrayBuffer());
1266
+ } catch (error) {
1267
+ clearTimeout(timeoutId);
1268
+ if (error instanceof SdkHttpError) throw error;
1269
+ const err = error;
1270
+ if (err.name === "AbortError") {
1271
+ throw new SdkHttpError("Request timeout", 408);
1272
+ }
1273
+ throw new SdkHttpError(`Network error: ${err.message}`, 0, error);
1274
+ }
1275
+ }
1276
+ async function upload(path, file, filename, metadata, fieldName = "file", opts) {
1241
1277
  const url = `${config.baseUrl}${path}`;
1242
1278
  const controller = new AbortController();
1243
1279
  const timeoutId = setTimeout(() => controller.abort(), timeout * 2);
@@ -1257,6 +1293,12 @@ function createHttpClient(config) {
1257
1293
  if (config.apiKey) {
1258
1294
  headers["X-API-Key"] = config.apiKey;
1259
1295
  }
1296
+ if (opts?.customerToken) {
1297
+ headers["X-Customer-Session-Token"] = opts.customerToken;
1298
+ }
1299
+ if (opts?.headers) {
1300
+ Object.assign(headers, opts.headers);
1301
+ }
1260
1302
  const response = await fetch(url, {
1261
1303
  method: "POST",
1262
1304
  headers,
@@ -1288,7 +1330,7 @@ function createHttpClient(config) {
1288
1330
  try {
1289
1331
  return await op();
1290
1332
  } catch (error) {
1291
- const refreshable = !!config.onUnauthorized && !path.startsWith("/api/auth/") && error instanceof SdkHttpError && error.statusCode === 401;
1333
+ const refreshable = !!config.onUnauthorized && !path.startsWith("/api/v3/baas/auth/") && !path.startsWith("/api/v3/auth/") && error instanceof SdkHttpError && error.statusCode === 401;
1292
1334
  if (!refreshable) throw error;
1293
1335
  if (!reauthInFlight) {
1294
1336
  reauthInFlight = Promise.resolve(config.onUnauthorized()).finally(() => {
@@ -1304,13 +1346,14 @@ function createHttpClient(config) {
1304
1346
  }
1305
1347
  }
1306
1348
  const client = {
1307
- post: (path, body) => withAuthRetry(path, () => request("POST", path, body)),
1308
- get: (path) => withAuthRetry(path, () => request("GET", path)),
1309
- put: (path, body) => withAuthRetry(path, () => request("PUT", path, body)),
1310
- patch: (path, body) => withAuthRetry(path, () => request("PATCH", path, body)),
1311
- delete: (path) => withAuthRetry(path, () => request("DELETE", path)),
1312
- getText: (path) => withAuthRetry(path, () => getText(path)),
1313
- upload: ((path, file, filename, metadata, fieldName) => withAuthRetry(path, () => upload(path, file, filename, metadata, fieldName))),
1349
+ post: (path, body, opts) => withAuthRetry(path, () => request("POST", path, body, opts)),
1350
+ get: (path, opts) => withAuthRetry(path, () => request("GET", path, void 0, opts)),
1351
+ put: (path, body, opts) => withAuthRetry(path, () => request("PUT", path, body, opts)),
1352
+ patch: (path, body, opts) => withAuthRetry(path, () => request("PATCH", path, body, opts)),
1353
+ delete: (path, opts) => withAuthRetry(path, () => request("DELETE", path, void 0, opts)),
1354
+ getText: (path, opts) => withAuthRetry(path, () => getText(path, opts)),
1355
+ getBinary: (path, opts) => withAuthRetry(path, () => getBinary(path, opts)),
1356
+ upload: ((path, file, filename, metadata, fieldName, opts) => withAuthRetry(path, () => upload(path, file, filename, metadata, fieldName, opts))),
1314
1357
  setAuthToken,
1315
1358
  getAuthToken
1316
1359
  };
@@ -2228,7 +2271,7 @@ var HederaTransactionsClient = class {
2228
2271
  * - `client.hedera.tss.createTopic(...)` makes the cluster sign+submit in one call.
2229
2272
  *
2230
2273
  * `tssHttp` is the validator's `/api/v3`-rooted HTTP client (different from
2231
- * the `/api/transactions` one this class uses for prepare paths). Both
2274
+ * the `/api/v3/transactions` one this class uses for prepare paths). Both
2232
2275
  * clients are required — the previous single-arg fallback to `http` was
2233
2276
  * unreachable through `SmartEngineClient` (the only call site always
2234
2277
  * passes both).
@@ -2937,77 +2980,85 @@ var AgentsClient = class {
2937
2980
  }
2938
2981
  http;
2939
2982
  /** Register a new agent */
2940
- async register(request) {
2941
- return this.http.post("/api/agents/register", request);
2983
+ async register(request, opts) {
2984
+ return this.http.post("/api/v3/baas/agents/register", request, opts);
2942
2985
  }
2943
2986
  /** Get agent details */
2944
- async get(agentId) {
2945
- return this.http.get(`/api/agents/${encodePathParam(agentId)}`);
2987
+ async get(agentId, opts) {
2988
+ return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}`, opts);
2946
2989
  }
2947
2990
  /** List all agents */
2948
- async list() {
2949
- return this.http.get("/api/agents");
2991
+ async list(opts) {
2992
+ return this.http.get("/api/v3/baas/agents", opts);
2950
2993
  }
2951
2994
  /**
2952
2995
  * Fund agent treasury (owner-only). Returns a
2953
2996
  * `PreparedTransactionResponse` wrapped in a `success: true` envelope —
2954
2997
  * the caller is expected to sign and submit the prepared bytes.
2955
2998
  */
2956
- async fund(agentId, request) {
2957
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/fund`, request);
2999
+ async fund(agentId, request, opts) {
3000
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/fund`, request, opts);
2958
3001
  }
2959
3002
  /**
2960
3003
  * Execute a trade (agent-wallet OR owner). Returns a
2961
3004
  * `PreparedTransactionResponse` wrapped in a `success: true` envelope.
2962
3005
  */
2963
- async trade(agentId, request) {
2964
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/trade`, request);
3006
+ async trade(agentId, request, opts) {
3007
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/trade`, request, opts);
2965
3008
  }
2966
3009
  /**
2967
3010
  * Withdraw from agent treasury (owner-only). Returns a
2968
3011
  * `PreparedTransactionResponse` wrapped in a `success: true` envelope.
2969
3012
  */
2970
- async withdraw(agentId, request) {
2971
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/withdraw`, request);
3013
+ async withdraw(agentId, request, opts) {
3014
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/withdraw`, request, opts);
3015
+ }
3016
+ /**
3017
+ * Execute a generic, declared capability (agent-wallet OR owner). The
3018
+ * chain-agnostic general form of an agent action: the capability may settle
3019
+ * on-chain, act off-chain, or both. Returns the ordered step results.
3020
+ */
3021
+ async execute(agentId, request, opts) {
3022
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/execute`, request, opts);
2972
3023
  }
2973
3024
  /** Pause an agent */
2974
- async pause(agentId) {
2975
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/pause`, {});
3025
+ async pause(agentId, opts) {
3026
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/pause`, {}, opts);
2976
3027
  }
2977
3028
  /** Resume a paused agent */
2978
- async resume(agentId) {
2979
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/resume`, {});
3029
+ async resume(agentId, opts) {
3030
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/resume`, {}, opts);
2980
3031
  }
2981
3032
  /** Revoke an agent (permanent) */
2982
- async revoke(agentId) {
2983
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/revoke`, {});
3033
+ async revoke(agentId, opts) {
3034
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/revoke`, {}, opts);
2984
3035
  }
2985
3036
  /**
2986
3037
  * Update agent rules.
2987
3038
  *
2988
- * Server route is PATCH `/api/agents/:agentId/rules`
3039
+ * Server route is PATCH `/api/v3/baas/agents/:agentId/rules`
2989
3040
  * (`agents.controller.ts:375`). The previous PUT variant 404'd because
2990
3041
  * Nest matched the dynamic `:agentId` GET/POST handlers and rejected
2991
3042
  * the verb mismatch.
2992
3043
  */
2993
- async updateRules(agentId, rules) {
2994
- return this.http.patch(`/api/agents/${encodePathParam(agentId)}/rules`, rules);
3044
+ async updateRules(agentId, rules, opts) {
3045
+ return this.http.patch(`/api/v3/baas/agents/${encodePathParam(agentId)}/rules`, rules, opts);
2995
3046
  }
2996
3047
  /** Get agent events */
2997
- async getEvents(agentId) {
2998
- return this.http.get(`/api/agents/${encodePathParam(agentId)}/events`);
3048
+ async getEvents(agentId, opts) {
3049
+ return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}/events`, opts);
2999
3050
  }
3000
3051
  /** Get agent balances across chains */
3001
- async getBalances(agentId) {
3002
- return this.http.get(`/api/agents/${encodePathParam(agentId)}/balances`);
3052
+ async getBalances(agentId, opts) {
3053
+ return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}/balances`, opts);
3003
3054
  }
3004
3055
  /** Approve a pending agent operation */
3005
- async approve(agentId, operationId) {
3006
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/approve/${encodePathParam(operationId)}`, {});
3056
+ async approve(agentId, operationId, opts) {
3057
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/approve/${encodePathParam(operationId)}`, {}, opts);
3007
3058
  }
3008
3059
  /** Reject a pending agent operation */
3009
- async reject(agentId, operationId) {
3010
- return this.http.post(`/api/agents/${encodePathParam(agentId)}/reject/${encodePathParam(operationId)}`, {});
3060
+ async reject(agentId, operationId, opts) {
3061
+ return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/reject/${encodePathParam(operationId)}`, {}, opts);
3011
3062
  }
3012
3063
  };
3013
3064
 
@@ -3035,7 +3086,56 @@ var DeploymentClient = class {
3035
3086
  * {@link deploy} with the pushed image tag.
3036
3087
  */
3037
3088
  async init(request) {
3038
- return this.http.post("/api/deployment/apps/init", request);
3089
+ return this.http.post("/api/v3/baas/deployment/apps/init", request);
3090
+ }
3091
+ /**
3092
+ * Issue ephemeral Harbor push credentials for a smart-app that ALREADY
3093
+ * EXISTS — the MINT-FIRST / DEPLOY-LAST credentials-push call.
3094
+ *
3095
+ * Unlike {@link init} (which historically allocated a fresh entity), this
3096
+ * takes the developer's pre-existing `appId` — the `SUBSCRIPTION_APP_ID`
3097
+ * minted by `hsuite subscribe` (`appId == DKG entityId`) — and ONLY
3098
+ * (re)provisions the per-app Harbor project + push robot. The server creates
3099
+ * no DKG entity and no subscription; it asserts the caller owns the app and
3100
+ * that its subscription is ACTIVE (402 otherwise) first.
3101
+ *
3102
+ * Returns the same `{ appId, registry }` shape as {@link init}. Single-use
3103
+ * secret discipline applies to `registry.password` exactly as in `init`.
3104
+ *
3105
+ * This is the credentials path the mint-first `hsuite deploy` uses to obtain
3106
+ * push creds for the developer's already-minted subscription app
3107
+ * (`POST /apps/:appId/credentials/push`). The `hsuite redeploy` re-push path
3108
+ * uses {@link reissuePushCredentials} instead, which targets a dedicated
3109
+ * `credentials/reissue` route with stricter SUSPENDED-app + Harbor-failure
3110
+ * handling.
3111
+ */
3112
+ async pushCredentials(appId) {
3113
+ return this.http.post(
3114
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/credentials/push`,
3115
+ {}
3116
+ );
3117
+ }
3118
+ /**
3119
+ * Reissue ephemeral Harbor push credentials for an EXISTING app, WITHOUT
3120
+ * allocating a new appId / entity. Unlike {@link init} — which historically
3121
+ * forked a fresh smart-app entity (and a fresh paid subscription) on every
3122
+ * call — this re-binds to an app the developer already owns: the `appId` is
3123
+ * echoed back unchanged and only a new single-use `registry.password` push
3124
+ * robot is minted. Same `{ appId, registry }` response shape as `init`.
3125
+ *
3126
+ * Owner-only + active-subscription gated server-side. This is the credential
3127
+ * path `hsuite redeploy` uses so a re-push does not cost a new entity +
3128
+ * subscription each run. Targets the dedicated
3129
+ * `POST /apps/:appId/credentials/reissue` route (distinct from
3130
+ * {@link pushCredentials}'s first-deploy `credentials/push`): the reissue
3131
+ * route additionally refuses SUSPENDED apps and surfaces Harbor failures
3132
+ * loudly rather than returning placeholder creds.
3133
+ */
3134
+ async reissuePushCredentials(appId) {
3135
+ return this.http.post(
3136
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/credentials/reissue`,
3137
+ {}
3138
+ );
3039
3139
  }
3040
3140
  /**
3041
3141
  * Step 3 (optional) — upload the SPA tarball.
@@ -3046,7 +3146,7 @@ var DeploymentClient = class {
3046
3146
  */
3047
3147
  async uploadFrontend(appId, bundle, filename = "bundle.tar.gz") {
3048
3148
  return this.http.upload(
3049
- `/api/deployment/apps/${encodePathParam(appId)}/frontend`,
3149
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/frontend`,
3050
3150
  bundle,
3051
3151
  filename,
3052
3152
  void 0,
@@ -3060,32 +3160,32 @@ var DeploymentClient = class {
3060
3160
  * until `runtime.runtimeState === 'RUNNING'` for the URL to be live.
3061
3161
  */
3062
3162
  async deploy(appId, request) {
3063
- return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/deploy`, request);
3163
+ return this.http.post(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/deploy`, request);
3064
3164
  }
3065
3165
  /**
3066
3166
  * Roll back to a previously-deployed image tag (must exist in
3067
3167
  * `runtime.deploymentHistory[]`).
3068
3168
  */
3069
3169
  async rollback(appId, request) {
3070
- return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/rollback`, request);
3170
+ return this.http.post(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/rollback`, request);
3071
3171
  }
3072
3172
  /**
3073
3173
  * Live combined lifecycle + runtime status of an app.
3074
3174
  */
3075
3175
  async status(appId) {
3076
- return this.http.get(`/api/deployment/apps/${encodePathParam(appId)}/status`);
3176
+ return this.http.get(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/status`);
3077
3177
  }
3078
3178
  /**
3079
3179
  * List all deployed apps for the authenticated developer.
3080
3180
  */
3081
3181
  async list() {
3082
- return this.http.get("/api/deployment/apps");
3182
+ return this.http.get("/api/v3/smart-apps");
3083
3183
  }
3084
3184
  /**
3085
3185
  * Get app details.
3086
3186
  */
3087
3187
  async get(appId) {
3088
- return this.http.get(`/api/deployment/apps/${encodePathParam(appId)}`);
3188
+ return this.http.get(`/api/v3/smart-apps/${encodePathParam(appId)}`);
3089
3189
  }
3090
3190
  /**
3091
3191
  * Update app configuration.
@@ -3095,31 +3195,31 @@ var DeploymentClient = class {
3095
3195
  * @returns The updated app info.
3096
3196
  */
3097
3197
  async update(appId, updates) {
3098
- return this.http.put(`/api/deployment/apps/${encodePathParam(appId)}`, updates);
3198
+ return this.http.put(`/api/v3/smart-apps/${encodePathParam(appId)}`, updates);
3099
3199
  }
3100
3200
  /**
3101
3201
  * Delete an app (runtime effect: namespace teardown).
3102
3202
  */
3103
3203
  async delete(appId) {
3104
- return this.http.delete(`/api/deployment/apps/${encodePathParam(appId)}`);
3204
+ return this.http.delete(`/api/v3/smart-apps/${encodePathParam(appId)}`);
3105
3205
  }
3106
3206
  /**
3107
3207
  * Suspend an app (runtime effect: scale to zero).
3108
3208
  */
3109
3209
  async suspend(appId) {
3110
- return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/suspend`, {});
3210
+ return this.http.post(`/api/v3/smart-apps/${encodePathParam(appId)}/suspend`, {});
3111
3211
  }
3112
3212
  /**
3113
3213
  * Resume a suspended app (runtime effect: scale back up).
3114
3214
  */
3115
3215
  async resume(appId) {
3116
- return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/resume`, {});
3216
+ return this.http.post(`/api/v3/smart-apps/${encodePathParam(appId)}/resume`, {});
3117
3217
  }
3118
3218
  /**
3119
3219
  * Get deployment statistics.
3120
3220
  */
3121
3221
  async getStats() {
3122
- return this.http.get("/api/deployment/stats");
3222
+ return this.http.get("/api/v3/smart-apps/stats");
3123
3223
  }
3124
3224
  /**
3125
3225
  * Register or update the developer-facing webhook URL for runtime
@@ -3140,7 +3240,7 @@ var DeploymentClient = class {
3140
3240
  * CGNAT / cloud metadata destinations (SSRF guard).
3141
3241
  */
3142
3242
  async setWebhook(appId, webhookUrl) {
3143
- return this.http.put(`/api/deployment/apps/${encodePathParam(appId)}/webhook`, {
3243
+ return this.http.put(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/webhook`, {
3144
3244
  webhookUrl
3145
3245
  });
3146
3246
  }
@@ -3156,7 +3256,7 @@ var DeploymentClient = class {
3156
3256
  * exposition format.
3157
3257
  */
3158
3258
  async getMetrics(appId) {
3159
- return this.http.getText(`/api/deployment/apps/${encodePathParam(appId)}/metrics`);
3259
+ return this.http.getText(`/api/v3/baas/deployment/apps/${encodePathParam(appId)}/metrics`);
3160
3260
  }
3161
3261
  /**
3162
3262
  * Rotate the smart-app's tenant-secret KEK.
@@ -3167,7 +3267,7 @@ var DeploymentClient = class {
3167
3267
  */
3168
3268
  async rotateKek(appId) {
3169
3269
  return this.http.post(
3170
- `/api/deployment/apps/${encodePathParam(appId)}/credentials/rotate-kek`,
3270
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/credentials/rotate-kek`,
3171
3271
  {}
3172
3272
  );
3173
3273
  }
@@ -3181,7 +3281,7 @@ var DeploymentClient = class {
3181
3281
  */
3182
3282
  async revokeKek(appId, version) {
3183
3283
  return this.http.post(
3184
- `/api/deployment/apps/${encodePathParam(appId)}/credentials/revoke-kek`,
3284
+ `/api/v3/baas/deployment/apps/${encodePathParam(appId)}/credentials/revoke-kek`,
3185
3285
  { version }
3186
3286
  );
3187
3287
  }
@@ -3388,7 +3488,7 @@ var SmartEngineClient = class _SmartEngineClient {
3388
3488
  baseUrl;
3389
3489
  allowInsecure;
3390
3490
  http;
3391
- /** Separate HTTP client for /api/transactions (non-v3 base path) */
3491
+ /** Separate HTTP client for /api/v3/transactions */
3392
3492
  txHttp;
3393
3493
  /** Last HTTP error (for getHttpHealth) */
3394
3494
  lastHttpError;
@@ -3449,7 +3549,7 @@ var SmartEngineClient = class _SmartEngineClient {
3449
3549
  timeout: config.timeout
3450
3550
  });
3451
3551
  this.txHttp = createHttpClient({
3452
- baseUrl: `${this.baseUrl}/api/transactions`,
3552
+ baseUrl: `${this.baseUrl}/api/v3/transactions`,
3453
3553
  apiKey: config.apiKey,
3454
3554
  authToken: config.authToken,
3455
3555
  timeout: config.timeout
@@ -3783,7 +3883,17 @@ var SmartEngineClient = class _SmartEngineClient {
3783
3883
  return this.http.get("/status");
3784
3884
  }
3785
3885
  // ========== Messaging Operations ==========
3786
- /** Submit a message to consensus */
3886
+ /**
3887
+ * Submit a message to consensus.
3888
+ *
3889
+ * @deprecated Operator-funded message submission is RETIRED on the validator
3890
+ * under transaction sovereignty — `POST /api/v3/messages/:chain/:topicId`
3891
+ * now returns `403 Forbidden` (the operator must never front the chain fee
3892
+ * for a customer-supplied message). Use the payer-funded prepare path
3893
+ * instead: prepare a topic-message transaction via
3894
+ * `POST /api/transactions/topic/message/prepare`, then have the payer sign
3895
+ * and submit the returned bytes.
3896
+ */
3787
3897
  async submitMessage(chain, topicId, message) {
3788
3898
  if (message.length > 1024 * 1024) {
3789
3899
  throw new SmartEngineError("Message too large (max 1MB)", 400);
@@ -4160,7 +4270,7 @@ var DatabaseClient = class {
4160
4270
  async insert(collection, document) {
4161
4271
  const appId = this.getAppId();
4162
4272
  return this.http.post(
4163
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}`,
4273
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}`,
4164
4274
  document
4165
4275
  );
4166
4276
  }
@@ -4178,7 +4288,7 @@ var DatabaseClient = class {
4178
4288
  if (options?.sort) params.set("sort", options.sort);
4179
4289
  const qs = params.toString();
4180
4290
  return this.http.get(
4181
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}${qs ? `?${qs}` : ""}`
4291
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}${qs ? `?${qs}` : ""}`
4182
4292
  );
4183
4293
  }
4184
4294
  /**
@@ -4187,7 +4297,7 @@ var DatabaseClient = class {
4187
4297
  async update(collection, documentId, updates) {
4188
4298
  const appId = this.getAppId();
4189
4299
  return this.http.put(
4190
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`,
4300
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`,
4191
4301
  updates
4192
4302
  );
4193
4303
  }
@@ -4197,19 +4307,19 @@ var DatabaseClient = class {
4197
4307
  async delete(collection, documentId) {
4198
4308
  const appId = this.getAppId();
4199
4309
  return this.http.delete(
4200
- `/api/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`
4310
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(collection)}/${encodePathParam(documentId)}`
4201
4311
  );
4202
4312
  }
4203
4313
  /**
4204
4314
  * List collections for the app.
4205
4315
  *
4206
- * Server route is `/api/db/:appId/collections`
4316
+ * Server route is `/api/v3/baas/db/:appId/collections`
4207
4317
  * (`database.controller.ts:106`). The previous bare-`:appId` GET 404'd
4208
4318
  * — Nest reserves that pattern for the document-find router below.
4209
4319
  */
4210
4320
  async listCollections() {
4211
4321
  const appId = this.getAppId();
4212
- return this.http.get(`/api/db/${encodePathParam(appId)}/collections`);
4322
+ return this.http.get(`/api/v3/baas/db/${encodePathParam(appId)}/collections`);
4213
4323
  }
4214
4324
  /**
4215
4325
  * Create a new collection in the database.
@@ -4219,7 +4329,7 @@ var DatabaseClient = class {
4219
4329
  */
4220
4330
  async createCollection(name) {
4221
4331
  const appId = this.getAppId();
4222
- return this.http.post(`/api/db/${encodePathParam(appId)}/collections`, { name });
4332
+ return this.http.post(`/api/v3/baas/db/${encodePathParam(appId)}/collections`, { name });
4223
4333
  }
4224
4334
  /**
4225
4335
  * Drop a collection and all its documents.
@@ -4230,7 +4340,7 @@ var DatabaseClient = class {
4230
4340
  async dropCollection(name) {
4231
4341
  const appId = this.getAppId();
4232
4342
  return this.http.delete(
4233
- `/api/db/${encodePathParam(appId)}/collections/${encodePathParam(name)}`
4343
+ `/api/v3/baas/db/${encodePathParam(appId)}/collections/${encodePathParam(name)}`
4234
4344
  );
4235
4345
  }
4236
4346
  // ========== State Proofs ==========
@@ -4239,7 +4349,7 @@ var DatabaseClient = class {
4239
4349
  */
4240
4350
  async getStateRoot() {
4241
4351
  const appId = this.getAppId();
4242
- return this.http.get(`/api/db/${encodePathParam(appId)}/state/root`);
4352
+ return this.http.get(`/api/v3/baas/db/${encodePathParam(appId)}/state/root`);
4243
4353
  }
4244
4354
  /**
4245
4355
  * Get a Merkle proof for a specific document
@@ -4247,7 +4357,7 @@ var DatabaseClient = class {
4247
4357
  async getDocumentProof(documentId) {
4248
4358
  const appId = this.getAppId();
4249
4359
  return this.http.get(
4250
- `/api/db/${encodePathParam(appId)}/${encodePathParam(documentId)}/proof`
4360
+ `/api/v3/baas/db/${encodePathParam(appId)}/${encodePathParam(documentId)}/proof`
4251
4361
  );
4252
4362
  }
4253
4363
  /**
@@ -4261,7 +4371,7 @@ var DatabaseClient = class {
4261
4371
  if (options?.limit !== void 0) params.set("limit", String(options.limit));
4262
4372
  const qs = params.toString();
4263
4373
  return this.http.get(
4264
- `/api/db/${encodePathParam(appId)}/state/transitions${qs ? `?${qs}` : ""}`
4374
+ `/api/v3/baas/db/${encodePathParam(appId)}/state/transitions${qs ? `?${qs}` : ""}`
4265
4375
  );
4266
4376
  }
4267
4377
  /**
@@ -4269,7 +4379,7 @@ var DatabaseClient = class {
4269
4379
  */
4270
4380
  async getDbStats() {
4271
4381
  const appId = this.getAppId();
4272
- return this.http.get(`/api/db/${encodePathParam(appId)}/stats`);
4382
+ return this.http.get(`/api/v3/baas/db/${encodePathParam(appId)}/stats`);
4273
4383
  }
4274
4384
  };
4275
4385
 
@@ -4284,30 +4394,31 @@ var StorageClient = class {
4284
4394
  /**
4285
4395
  * Upload a file to storage
4286
4396
  */
4287
- async upload(file, filename, metadata) {
4397
+ async upload(file, filename, metadata, opts) {
4288
4398
  const appId = this.getAppId();
4289
- return this.http.upload(`/api/storage/${encodePathParam(appId)}/upload`, file, filename, metadata);
4399
+ return this.http.upload(`/api/v3/baas/storage/${encodePathParam(appId)}/upload`, file, filename, metadata, void 0, opts);
4290
4400
  }
4291
4401
  /**
4292
- * Download a file by CID
4402
+ * Download a file by CID. Returns the raw file bytes as a `Uint8Array`
4403
+ * (binary-safe — never JSON-parsed or text-decoded).
4293
4404
  */
4294
- async download(cid) {
4405
+ async download(cid, opts) {
4295
4406
  const appId = this.getAppId();
4296
- return this.http.get(`/api/storage/${encodePathParam(appId)}/download/${encodePathParam(cid)}`);
4407
+ return this.http.getBinary(`/api/v3/baas/storage/${encodePathParam(appId)}/download/${encodePathParam(cid)}`, opts);
4297
4408
  }
4298
4409
  /**
4299
4410
  * Get file metadata
4300
4411
  */
4301
- async getMetadata(cid) {
4412
+ async getMetadata(cid, opts) {
4302
4413
  const appId = this.getAppId();
4303
- return this.http.get(`/api/storage/${encodePathParam(appId)}/metadata/${encodePathParam(cid)}`);
4414
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/metadata/${encodePathParam(cid)}`, opts);
4304
4415
  }
4305
4416
  /**
4306
4417
  * Delete a file
4307
4418
  */
4308
- async delete(cid) {
4419
+ async delete(cid, opts) {
4309
4420
  const appId = this.getAppId();
4310
- return this.http.delete(`/api/storage/${encodePathParam(appId)}/${encodePathParam(cid)}`);
4421
+ return this.http.delete(`/api/v3/baas/storage/${encodePathParam(appId)}/${encodePathParam(cid)}`, opts);
4311
4422
  }
4312
4423
  /**
4313
4424
  * List all files for the app.
@@ -4316,27 +4427,27 @@ var StorageClient = class {
4316
4427
  * `offset` for pagination).
4317
4428
  * @returns The file list and total count.
4318
4429
  */
4319
- async listFiles(pagination) {
4430
+ async listFiles(pagination, opts) {
4320
4431
  const appId = this.getAppId();
4321
4432
  const params = new URLSearchParams();
4322
4433
  if (pagination?.limit !== void 0) params.set("limit", String(pagination.limit));
4323
4434
  if (pagination?.offset !== void 0) params.set("offset", String(pagination.offset));
4324
4435
  const qs = params.toString();
4325
- return this.http.get(`/api/storage/${encodePathParam(appId)}/files${qs ? `?${qs}` : ""}`);
4436
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/files${qs ? `?${qs}` : ""}`, opts);
4326
4437
  }
4327
4438
  /**
4328
4439
  * Get storage usage for the current app
4329
4440
  */
4330
- async getUsage() {
4441
+ async getUsage(opts) {
4331
4442
  const appId = this.getAppId();
4332
- return this.http.get(`/api/storage/${encodePathParam(appId)}/usage`);
4443
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/usage`, opts);
4333
4444
  }
4334
4445
  /**
4335
4446
  * Check if a file exists
4336
4447
  */
4337
- async exists(cid) {
4448
+ async exists(cid, opts) {
4338
4449
  const appId = this.getAppId();
4339
- return this.http.get(`/api/storage/${encodePathParam(appId)}/exists/${encodePathParam(cid)}`);
4450
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/exists/${encodePathParam(cid)}`, opts);
4340
4451
  }
4341
4452
  };
4342
4453
 
@@ -4349,61 +4460,99 @@ var FunctionsClient = class {
4349
4460
  http;
4350
4461
  getAppId;
4351
4462
  /**
4352
- * Deploy a new function
4353
- */
4354
- async deploy(request) {
4463
+ * Build the Ed25519 signed-code envelope the host mandates for every deploy
4464
+ * and eval. A fresh ephemeral keypair is generated per call, so no long-lived
4465
+ * signing key is held anywhere — each artifact carries its own signature.
4466
+ *
4467
+ * Scheme (must match the host verifier): `hash = sha256(code)` (hex),
4468
+ * `message = "<hash>:<timestamp>"`, signed Ed25519; `publicKey` is SPKI-DER
4469
+ * (base64). `crypto` is imported lazily so this never pulls Node built-ins
4470
+ * into a browser bundle that doesn't sign code.
4471
+ */
4472
+ async signCode(code) {
4473
+ const { generateKeyPairSync, createHash, sign } = await import('crypto');
4474
+ const { publicKey, privateKey } = generateKeyPairSync("ed25519");
4475
+ const hash = createHash("sha256").update(code, "utf8").digest("hex");
4476
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
4477
+ const signature = sign(null, Buffer.from(`${hash}:${timestamp}`, "utf8"), privateKey).toString("base64");
4478
+ const publicKeyDer = publicKey.export({ format: "der", type: "spki" }).toString("base64");
4479
+ return { code, hash, timestamp, signature, publicKey: publicKeyDer };
4480
+ }
4481
+ /**
4482
+ * Deploy a new function. If `signedCode` is omitted it is auto-built from
4483
+ * `request.code` via {@link signCode} — the host requires it, so the default
4484
+ * is to sign rather than 400. Pass your own envelope to override.
4485
+ */
4486
+ async deploy(request, opts) {
4355
4487
  const appId = this.getAppId();
4356
- return this.http.post(`/api/functions/${encodePathParam(appId)}`, request);
4488
+ const signedCode = request.signedCode ?? await this.signCode(request.code);
4489
+ return this.http.post(`/api/v3/baas/functions/${encodePathParam(appId)}`, { ...request, signedCode }, opts);
4357
4490
  }
4358
4491
  /**
4359
4492
  * Invoke a function
4360
4493
  */
4361
- async invoke(functionId, payload) {
4494
+ async invoke(functionId, payload, opts) {
4362
4495
  const appId = this.getAppId();
4363
4496
  return this.http.post(
4364
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/invoke`,
4365
- payload ?? {}
4497
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/invoke`,
4498
+ payload ?? {},
4499
+ opts
4366
4500
  );
4367
4501
  }
4502
+ /**
4503
+ * Evaluate signed code once (ephemeral) — no persistent deploy.
4504
+ *
4505
+ * For throwaway / AI-generated snippets. The host runs it in the same hardened
4506
+ * isolate and discards it; metered + quota'd like a normal invocation. As with
4507
+ * {@link deploy}, `signedCode` is auto-built from `request.code` when omitted.
4508
+ */
4509
+ async eval(request, opts) {
4510
+ const appId = this.getAppId();
4511
+ const signedCode = request.signedCode ?? await this.signCode(request.code);
4512
+ return this.http.post(`/api/v3/baas/functions/${encodePathParam(appId)}/eval`, { ...request, signedCode }, opts);
4513
+ }
4368
4514
  /**
4369
4515
  * List all functions for the current app
4370
4516
  */
4371
- async list() {
4517
+ async list(opts) {
4372
4518
  const appId = this.getAppId();
4373
- return this.http.get(`/api/functions/${encodePathParam(appId)}`);
4519
+ return this.http.get(`/api/v3/baas/functions/${encodePathParam(appId)}`, opts);
4374
4520
  }
4375
4521
  /**
4376
4522
  * Get function details
4377
4523
  */
4378
- async get(functionId) {
4524
+ async get(functionId, opts) {
4379
4525
  const appId = this.getAppId();
4380
4526
  return this.http.get(
4381
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`
4527
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
4528
+ opts
4382
4529
  );
4383
4530
  }
4384
4531
  /**
4385
4532
  * Update a function
4386
4533
  */
4387
- async update(functionId, updates) {
4534
+ async update(functionId, updates, opts) {
4388
4535
  const appId = this.getAppId();
4389
4536
  return this.http.put(
4390
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
4391
- updates
4537
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
4538
+ updates,
4539
+ opts
4392
4540
  );
4393
4541
  }
4394
4542
  /**
4395
4543
  * Delete a function
4396
4544
  */
4397
- async delete(functionId) {
4545
+ async delete(functionId, opts) {
4398
4546
  const appId = this.getAppId();
4399
4547
  return this.http.delete(
4400
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`
4548
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
4549
+ opts
4401
4550
  );
4402
4551
  }
4403
4552
  /**
4404
4553
  * Get function execution logs
4405
4554
  */
4406
- async getLogs(functionId, options) {
4555
+ async getLogs(functionId, options, opts) {
4407
4556
  const appId = this.getAppId();
4408
4557
  const params = new URLSearchParams();
4409
4558
  if (options?.limit !== void 0) params.set("limit", String(options.limit));
@@ -4411,15 +4560,16 @@ var FunctionsClient = class {
4411
4560
  if (options?.level) params.set("level", options.level);
4412
4561
  const qs = params.toString();
4413
4562
  return this.http.get(
4414
- `/api/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/logs${qs ? `?${qs}` : ""}`
4563
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/logs${qs ? `?${qs}` : ""}`,
4564
+ opts
4415
4565
  );
4416
4566
  }
4417
4567
  /**
4418
4568
  * Get function statistics for an app
4419
4569
  */
4420
- async getStats() {
4570
+ async getStats(opts) {
4421
4571
  const appId = this.getAppId();
4422
- return this.http.get(`/api/functions/${encodePathParam(appId)}/stats`);
4572
+ return this.http.get(`/api/v3/baas/functions/${encodePathParam(appId)}/stats`, opts);
4423
4573
  }
4424
4574
  };
4425
4575
 
@@ -4434,45 +4584,46 @@ var MessagingClient = class {
4434
4584
  /**
4435
4585
  * Create a new channel
4436
4586
  */
4437
- async createChannel(config) {
4587
+ async createChannel(config, opts) {
4438
4588
  const appId = this.getAppId();
4439
- return this.http.post(`/api/messaging/${encodePathParam(appId)}/channels`, config);
4589
+ return this.http.post(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels`, config, opts);
4440
4590
  }
4441
4591
  /**
4442
4592
  * Delete a channel
4443
4593
  */
4444
- async deleteChannel(channelId) {
4594
+ async deleteChannel(channelId, opts) {
4445
4595
  const appId = this.getAppId();
4446
- return this.http.delete(`/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`);
4596
+ return this.http.delete(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`, opts);
4447
4597
  }
4448
4598
  /**
4449
4599
  * Get a channel by ID
4450
4600
  */
4451
- async getChannel(channelId) {
4601
+ async getChannel(channelId, opts) {
4452
4602
  const appId = this.getAppId();
4453
- return this.http.get(`/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`);
4603
+ return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`, opts);
4454
4604
  }
4455
4605
  /**
4456
4606
  * List all channels for the app
4457
4607
  */
4458
- async listChannels() {
4608
+ async listChannels(opts) {
4459
4609
  const appId = this.getAppId();
4460
- return this.http.get(`/api/messaging/${encodePathParam(appId)}/channels`);
4610
+ return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels`, opts);
4461
4611
  }
4462
4612
  /**
4463
4613
  * Publish a message to a channel
4464
4614
  */
4465
- async publish(channel, message, metadata) {
4615
+ async publish(channel, message, metadata, opts) {
4466
4616
  const appId = this.getAppId();
4467
4617
  return this.http.post(
4468
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/publish`,
4469
- { data: message, metadata }
4618
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/publish`,
4619
+ { data: message, metadata },
4620
+ opts
4470
4621
  );
4471
4622
  }
4472
4623
  /**
4473
4624
  * Get message history for a channel
4474
4625
  */
4475
- async getHistory(channel, options) {
4626
+ async getHistory(channel, options, opts) {
4476
4627
  const appId = this.getAppId();
4477
4628
  const params = new URLSearchParams();
4478
4629
  if (options?.limit !== void 0) params.set("limit", String(options.limit));
@@ -4480,7 +4631,8 @@ var MessagingClient = class {
4480
4631
  if (options?.after) params.set("after", options.after);
4481
4632
  const qs = params.toString();
4482
4633
  return this.http.get(
4483
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/history${qs ? `?${qs}` : ""}`
4634
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/history${qs ? `?${qs}` : ""}`,
4635
+ opts
4484
4636
  );
4485
4637
  }
4486
4638
  /**
@@ -4491,43 +4643,46 @@ var MessagingClient = class {
4491
4643
  * `setPresence(member)` hit a non-existent appId-scoped route and 404'd
4492
4644
  * in production. The channel is now the first argument.
4493
4645
  */
4494
- async setPresence(channel, member) {
4646
+ async setPresence(channel, member, opts) {
4495
4647
  const appId = this.getAppId();
4496
4648
  return this.http.post(
4497
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`,
4498
- member
4649
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`,
4650
+ member,
4651
+ opts
4499
4652
  );
4500
4653
  }
4501
4654
  /**
4502
4655
  * Remove a member's presence from a channel.
4503
4656
  *
4504
4657
  * BREAKING CHANGE (SDK 3.3.0): server route is
4505
- * `/api/messaging/:appId/channels/:channel/presence/:clientId`
4658
+ * `/api/v3/baas/messaging/:appId/channels/:channel/presence/:clientId`
4506
4659
  * (`messaging.controller.ts:352`). `channel` is now the first arg and
4507
4660
  * `clientId` (not `memberId`) the second — they're the same identifier
4508
4661
  * but renamed to match the server param.
4509
4662
  */
4510
- async removePresence(channel, clientId) {
4663
+ async removePresence(channel, clientId, opts) {
4511
4664
  const appId = this.getAppId();
4512
4665
  return this.http.delete(
4513
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence/${encodePathParam(clientId)}`
4666
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence/${encodePathParam(clientId)}`,
4667
+ opts
4514
4668
  );
4515
4669
  }
4516
4670
  /**
4517
4671
  * Get presence info for a channel
4518
4672
  */
4519
- async getPresence(channel) {
4673
+ async getPresence(channel, opts) {
4520
4674
  const appId = this.getAppId();
4521
4675
  return this.http.get(
4522
- `/api/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`
4676
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`,
4677
+ opts
4523
4678
  );
4524
4679
  }
4525
4680
  /**
4526
4681
  * Get messaging statistics
4527
4682
  */
4528
- async getStats() {
4683
+ async getStats(opts) {
4529
4684
  const appId = this.getAppId();
4530
- return this.http.get(`/api/messaging/${encodePathParam(appId)}/stats`);
4685
+ return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/stats`, opts);
4531
4686
  }
4532
4687
  };
4533
4688
 
@@ -4543,21 +4698,21 @@ var CustomerSessionClient = class {
4543
4698
  * Step 1: ask the host to issue a fresh challenge for the customer to sign.
4544
4699
  */
4545
4700
  async challenge(input) {
4546
- return this.fetch("POST", "/api/customer-session/challenge", input);
4701
+ return this.fetch("POST", "/api/v3/baas/customer-session/challenge", input);
4547
4702
  }
4548
4703
  /**
4549
4704
  * Step 2: submit the customer's signed challenge. On success returns a
4550
4705
  * short-lived bearer JWT scoped to {appId, chain, address}.
4551
4706
  */
4552
4707
  async verify(req) {
4553
- return this.fetch("POST", "/api/customer-session/verify", req);
4708
+ return this.fetch("POST", "/api/v3/baas/customer-session/verify", req);
4554
4709
  }
4555
4710
  /**
4556
4711
  * Validate a customer bearer + return the decoded session info. Used by
4557
4712
  * smart-app backends to authorise incoming customer requests.
4558
4713
  */
4559
4714
  async validate(bearer) {
4560
- return this.fetch("GET", "/api/customer-session/validate", void 0, bearer);
4715
+ return this.fetch("GET", "/api/v3/baas/customer-session/validate", void 0, bearer);
4561
4716
  }
4562
4717
  /**
4563
4718
  * Revoke a customer session. Idempotent.
@@ -4565,7 +4720,7 @@ var CustomerSessionClient = class {
4565
4720
  async end(bearer) {
4566
4721
  return this.fetch(
4567
4722
  "POST",
4568
- "/api/customer-session/end",
4723
+ "/api/v3/baas/customer-session/end",
4569
4724
  void 0,
4570
4725
  bearer
4571
4726
  );
@@ -4611,15 +4766,15 @@ var RulesClient = class {
4611
4766
  http;
4612
4767
  /** Publish a canonical ValidatorRules document to HCS. */
4613
4768
  async publish(rule) {
4614
- return this.http.post("/api/rules/publish", rule);
4769
+ return this.http.post("/api/v3/baas/rules/publish", rule);
4615
4770
  }
4616
4771
  /** Fetch a published rule by its HCS consensus timestamp. */
4617
4772
  async get(consensusTimestamp) {
4618
- return this.http.get(`/api/rules/${encodePathParam(consensusTimestamp)}`);
4773
+ return this.http.get(`/api/v3/baas/rules/${encodePathParam(consensusTimestamp)}`);
4619
4774
  }
4620
4775
  /** List rules owned by the authenticated entity, optionally filtered by type. */
4621
4776
  async listByOwner(filter) {
4622
- const path = filter?.type ? `/api/rules?type=${encodeURIComponent(filter.type)}` : "/api/rules";
4777
+ const path = filter?.type ? `/api/v3/baas/rules?type=${encodeURIComponent(filter.type)}` : "/api/v3/baas/rules";
4623
4778
  return this.http.get(path);
4624
4779
  }
4625
4780
  /**
@@ -4627,44 +4782,332 @@ var RulesClient = class {
4627
4782
  * `ruleRef` (published) or `rule` (inline) must be supplied by the caller.
4628
4783
  */
4629
4784
  async simulate(params) {
4630
- return this.http.post("/api/rules/simulate", params);
4785
+ return this.http.post("/api/v3/baas/rules/simulate", params);
4631
4786
  }
4632
4787
  /** Walk the version history of a published rule. */
4633
4788
  async getVersionHistory(consensusTimestamp) {
4634
4789
  return this.http.get(
4635
- `/api/rules/${encodePathParam(consensusTimestamp)}/versions`
4790
+ `/api/v3/baas/rules/${encodePathParam(consensusTimestamp)}/versions`
4636
4791
  );
4637
4792
  }
4638
4793
  /** Deprecate a published rule (owner-only). */
4639
4794
  async deprecate(consensusTimestamp) {
4640
4795
  return this.http.post(
4641
- `/api/rules/${encodePathParam(consensusTimestamp)}/deprecate`,
4796
+ `/api/v3/baas/rules/${encodePathParam(consensusTimestamp)}/deprecate`,
4642
4797
  {}
4643
4798
  );
4644
4799
  }
4645
4800
  };
4646
4801
 
4647
4802
  // src/baas/entities/client.ts
4648
- var EntitiesClient = class {
4803
+ var EntitiesClient = class _EntitiesClient {
4649
4804
  constructor(http) {
4650
4805
  this.http = http;
4651
4806
  }
4652
4807
  http;
4653
- /** Create a canonical token entity bound to a published rule. */
4808
+ /**
4809
+ * Chains whose token-create routes through the payer-funded 3-step (prepare →
4810
+ * fund → execute), mirroring `createAccount`. Hedera = real HTS TokenCreate
4811
+ * (admin/supply = the per-entity DKG slot-pubkey KeyList; treasury = the
4812
+ * entity's own account; `0.0.X` token id is network-assigned, resolved from the
4813
+ * receipt via the threaded `createTxId`). Cardano/Solana/Polkadot = the
4814
+ * AUTHORITY entity (the entity IS the policy/mint/Assets-admin multisig — same
4815
+ * address as an account; the asset MINT itself is a later operate-tab payer
4816
+ * call). XRPL/Stellar token = an ISSUER ACCOUNT (reuses the account preparer) +
4817
+ * issuer flags set at finalize: XRPL relays the funding Payment then finalizes
4818
+ * (issuer-flag AccountSets + SignerListSet + disable-master); Stellar relays the
4819
+ * CreateAccount then finalizes (SetOptions install incl. issuer setFlags +
4820
+ * master lock). Every OTHER chain (EVM) stays on the legacy synchronous path.
4821
+ */
4822
+ static PAYER_FUNDED_TOKEN_CHAINS = /* @__PURE__ */ new Set([
4823
+ "hedera",
4824
+ "cardano",
4825
+ "solana",
4826
+ "polkadot",
4827
+ "xrpl",
4828
+ "stellar"
4829
+ ]);
4830
+ /**
4831
+ * PREPARE half of the payer-funded token-create flow.
4832
+ *
4833
+ * POSTs `/api/v3/baas/entities/prepare-create` with `entityType: 'token'`. The cluster
4834
+ * runs the per-entity DKG, builds the payer-funded create (Hedera: TokenCreate
4835
+ * keyed by the slot-pubkey KeyList with the entity account as treasury;
4836
+ * Cardano/Solana/Polkadot: funds/provisions the authority multisig), and returns
4837
+ * the prepared blob. The prepared `transactionId` is the `createTxId` for
4838
+ * execute (Hedera).
4839
+ */
4840
+ async prepareCreateToken(req) {
4841
+ return this.http.post("/api/v3/baas/entities/prepare-create", {
4842
+ entityType: "token",
4843
+ ...req
4844
+ });
4845
+ }
4846
+ /**
4847
+ * EXECUTE half of the payer-funded token-create flow.
4848
+ *
4849
+ * POSTs `/api/v3/baas/entities/execute-create` with `entityType: 'token'`. For Hedera,
4850
+ * pass `createTxId` (the prepared create's `transactionId`) so the validator
4851
+ * resolves the network-assigned `0.0.X` token id from the receipt and stamps
4852
+ * `chainAccounts.hedera`. For the authority-entity chains (cardano/solana/
4853
+ * polkadot) execute just verifies the binding and echoes the stamped authority
4854
+ * address (no `createTxId` needed).
4855
+ */
4856
+ async executeCreateToken(req) {
4857
+ const { createTxId, signedFundingBlob, ...rest } = req;
4858
+ return this.http.post("/api/v3/baas/entities/execute-create", {
4859
+ ...rest,
4860
+ ...createTxId !== void 0 ? { createTxId } : {},
4861
+ ...signedFundingBlob !== void 0 ? { signedFundingBlob } : {},
4862
+ entityType: "token"
4863
+ });
4864
+ }
4865
+ /**
4866
+ * Create a canonical token entity bound to a published rule.
4867
+ *
4868
+ * Dispatches by `chain` (mirrors `createAccount`):
4869
+ * - **Hedera / Cardano / Solana / Polkadot** = payer-funded 3-step (prepare →
4870
+ * caller funds via `fundWith` → execute). Hedera resolves the network-assigned
4871
+ * `0.0.X` token id from the receipt (threads `createTxId`); the authority-
4872
+ * entity chains verify/echo the stamped authority address. `fundWith` is
4873
+ * REQUIRED; to drive the steps manually call `prepareCreateToken` /
4874
+ * `executeCreateToken` directly.
4875
+ * - **XRPL / Stellar** = payer-funded too (account-model issuer): `fundWith`
4876
+ * REQUIRED; the caller's signed funding blob is RELAYED to the validator,
4877
+ * which submits it then finalizes the issuer multisig (master-locked). NO
4878
+ * issuer flags are set at create — issuer auth flags / DefaultRipple / clawback
4879
+ * are an operate-tab, rules-validated concern.
4880
+ * - **EVM / other** = legacy synchronous `POST /api/v3/baas/entities/createToken`
4881
+ * (payer-funded-only fields ignored) until it migrates.
4882
+ */
4654
4883
  async createToken(req) {
4655
- return this.http.post("/api/entities/createToken", req);
4884
+ if (_EntitiesClient.PAYER_FUNDED_TOKEN_CHAINS.has(req.chain)) {
4885
+ const { fundWith, ...prepReq } = req;
4886
+ const prep = await this.prepareCreateToken(prepReq);
4887
+ if (!fundWith) {
4888
+ throw new Error(
4889
+ `createToken(${req.chain}): pass fundWith (sign+submit the prepared create tx), or call prepareCreateToken/executeCreateToken directly`
4890
+ );
4891
+ }
4892
+ const funded = await fundWith(prep.prepared, {
4893
+ address: prep.address,
4894
+ reserveRequirement: prep.reserveRequirement
4895
+ });
4896
+ return this.executeCreateToken({
4897
+ entityId: prep.entityId,
4898
+ chain: req.chain,
4899
+ securityMode: req.securityMode,
4900
+ signedFundingBlob: _EntitiesClient.FUNDING_BLOB_RELAY_CHAINS.has(req.chain) ? funded?.signedFundingBlob : void 0,
4901
+ createTxId: req.chain === "hedera" ? prep.prepared?.[0]?.transactionId : void 0
4902
+ });
4903
+ }
4904
+ const {
4905
+ fundWith: _ignoredFundWith,
4906
+ payerAccountId: _ignoredPayer,
4907
+ securityMode: _ignoredSecurityMode,
4908
+ ...legacyReq
4909
+ } = req;
4910
+ return this.http.post("/api/v3/baas/entities/createToken", legacyReq);
4911
+ }
4912
+ /**
4913
+ * PREPARE half of the payer-funded account-create flow.
4914
+ *
4915
+ * POSTs `/api/v3/baas/entities/prepare-create`. The cluster runs the per-entity DKG
4916
+ * (persists the binding, submits nothing on-chain) and returns the unsigned
4917
+ * payer-funding `Payment`(s) the caller signs + submits with their own wallet.
4918
+ */
4919
+ async prepareCreateAccount(req) {
4920
+ return this.http.post("/api/v3/baas/entities/prepare-create", {
4921
+ entityType: "account",
4922
+ ...req
4923
+ });
4924
+ }
4925
+ /**
4926
+ * EXECUTE half of the payer-funded account-create flow.
4927
+ *
4928
+ * POSTs `/api/v3/baas/entities/execute-create`. The entity already exists (its DKG
4929
+ * ran during prepare); pass `signedFundingBlob` for the validator to submit
4930
+ * the payer's signed funding `Payment` (XRPL only), or omit it when the caller
4931
+ * already submitted the funding tx themselves (then execute just finalizes /
4932
+ * verifies).
4933
+ *
4934
+ * `createTxId` is the HEDERA thread: a Hedera AccountCreate gets its
4935
+ * network-assigned `0.0.X` id only from the on-chain receipt after the payer
4936
+ * submits. The caller threads the prepared create's `transactionId` (from
4937
+ * `prepared[0].transactionId`) back here so the validator resolves the id from
4938
+ * the receipt server-side. Ignored for non-Hedera chains.
4939
+ */
4940
+ async executeCreateAccount(req) {
4941
+ const { createTxId, ...rest } = req;
4942
+ return this.http.post("/api/v3/baas/entities/execute-create", {
4943
+ ...rest,
4944
+ ...createTxId !== void 0 ? { createTxId } : {}
4945
+ });
4656
4946
  }
4657
- /** Create a canonical account entity bound to a published rule. */
4947
+ /**
4948
+ * Chains whose account-create routes through the payer-funded 3-step
4949
+ * (prepare → fund → execute). All are ledgers where the validators never pay:
4950
+ * XRPL funds a reserve; Bitcoin funds a P2WSH UTXO; Cardano funds a
4951
+ * native-script enterprise address above min-UTXO; Polkadot funds a
4952
+ * pallet_multisig SS58 above the existential deposit; Solana funds a Squads
4953
+ * multisig PDA (deterministic from the createKey) via a payer-paid
4954
+ * `multisigCreateV2` — the payer's submission IS the create (no separate
4955
+ * finalizer). Hedera is create-WITH-KEY: the payer submits an AccountCreate
4956
+ * whose controlling key is the per-entity DKG slot-pubkey KeyList, so the
4957
+ * payer's submit IS the create; its `0.0.X` id is network-assigned (resolved
4958
+ * from the receipt at execute-create via the threaded `createTxId`). Stellar is
4959
+ * account-MODEL (like XRPL): the payer funds the entity's slot-0 `G...` master
4960
+ * via a CreateAccount, the validator RELAYS the signed funding blob, then
4961
+ * execute-create finalizes on-chain (threshold-signs a SetOptions installing
4962
+ * the validator chain-key multisig + locking the master). EVM stays on the
4963
+ * legacy synchronous create until it migrates.
4964
+ */
4965
+ static PAYER_FUNDED_CREATE_CHAINS = /* @__PURE__ */ new Set([
4966
+ "xrpl",
4967
+ "bitcoin",
4968
+ "cardano",
4969
+ "polkadot",
4970
+ "solana",
4971
+ "hedera",
4972
+ "stellar"
4973
+ ]);
4974
+ /**
4975
+ * Chains whose execute-create RELAYS the payer's signed funding blob for the
4976
+ * validator to submit (then finalizes on-chain). Both are account-model ledgers
4977
+ * with a validator-side finalize step: XRPL (SignerListSet + disable-master),
4978
+ * Stellar (SetOptions install + master lock). Every OTHER payer-funded chain
4979
+ * has the PAYER submit the funding tx directly with their own wallet — their
4980
+ * execute-create REJECTS a non-undefined `signedFundingBlob` (400), so the blob
4981
+ * is omitted for them.
4982
+ */
4983
+ static FUNDING_BLOB_RELAY_CHAINS = /* @__PURE__ */ new Set(["xrpl", "stellar"]);
4984
+ /**
4985
+ * Create a canonical account entity bound to a published rule.
4986
+ *
4987
+ * Dispatches by `chain`:
4988
+ * - **XRPL / Stellar / Bitcoin / Cardano / Polkadot / Solana / Hedera** =
4989
+ * payer-funded 3-step (prepare → fund → execute). The cluster runs the
4990
+ * per-entity DKG and returns the unsigned payer-funding tx(s); the
4991
+ * caller-supplied `fundWith` callback signs + submits (or just signs) the
4992
+ * funding tx with their OWN wallet — the SDK never holds the customer's chain
4993
+ * key nor opens a network connection — then `executeCreateAccount` finalizes
4994
+ * (XRPL + Stellar finalize on-chain after relaying the funding blob; the
4995
+ * deterministic ledgers + Solana verify/stamp the binding; Hedera resolves
4996
+ * the network-assigned id from the receipt). `fundWith` is REQUIRED on these
4997
+ * chains; to drive the steps manually call `prepareCreateAccount` /
4998
+ * `executeCreateAccount` directly.
4999
+ * - **other chains** (EVM) = legacy synchronous create — a single
5000
+ * `POST /api/v3/baas/entities/createAccount`, unchanged from pre-3.9.0. These chains
5001
+ * migrate to the payer-funded flow in a later phase; until then the
5002
+ * payer-funded-only fields (`fundWith` / `payerAccountId` / `securityMode`)
5003
+ * are ignored.
5004
+ */
4658
5005
  async createAccount(req) {
4659
- return this.http.post("/api/entities/createAccount", req);
5006
+ if (_EntitiesClient.PAYER_FUNDED_CREATE_CHAINS.has(req.chain)) {
5007
+ const { fundWith, ...prepReq } = req;
5008
+ const prep = await this.prepareCreateAccount(prepReq);
5009
+ if (!fundWith) {
5010
+ throw new Error(
5011
+ `createAccount(${req.chain}): pass fundWith (sign+submit the prepared funding tx), or call prepareCreateAccount/executeCreateAccount directly`
5012
+ );
5013
+ }
5014
+ const funded = await fundWith(prep.prepared, {
5015
+ address: prep.address,
5016
+ reserveRequirement: prep.reserveRequirement
5017
+ });
5018
+ return this.executeCreateAccount({
5019
+ entityId: prep.entityId,
5020
+ chain: req.chain,
5021
+ securityMode: req.securityMode,
5022
+ signedFundingBlob: _EntitiesClient.FUNDING_BLOB_RELAY_CHAINS.has(req.chain) ? funded?.signedFundingBlob : void 0,
5023
+ createTxId: req.chain === "hedera" ? prep.prepared?.[0]?.transactionId : void 0
5024
+ });
5025
+ }
5026
+ const {
5027
+ fundWith: _ignoredFundWith,
5028
+ payerAccountId: _ignoredPayer,
5029
+ securityMode: _ignoredSecurityMode,
5030
+ ...legacyReq
5031
+ } = req;
5032
+ return this.http.post("/api/v3/baas/entities/createAccount", legacyReq);
5033
+ }
5034
+ /**
5035
+ * PREPARE half of the payer-funded topic-create flow (Hedera).
5036
+ *
5037
+ * POSTs `/api/v3/baas/entities/prepare-create` with `entityType: 'topic'`. The cluster
5038
+ * runs the per-entity DKG (persists the binding), builds the payer-funded
5039
+ * TopicCreate keyed by the slot-pubkey KeyList, attaches the validator admin
5040
+ * threshold sig, and returns the prepared blob for the caller to add the fee
5041
+ * sig + submit. The prepared `transactionId` is the `createTxId` for execute.
5042
+ */
5043
+ async prepareCreateTopic(req) {
5044
+ return this.http.post("/api/v3/baas/entities/prepare-create", {
5045
+ entityType: "topic",
5046
+ ...req
5047
+ });
5048
+ }
5049
+ /**
5050
+ * EXECUTE half of the payer-funded topic-create flow (Hedera).
5051
+ *
5052
+ * POSTs `/api/v3/baas/entities/execute-create` with `entityType: 'topic'`. The topic
5053
+ * already exists once the payer submitted the create tx; pass `createTxId` (the
5054
+ * prepared create's `transactionId`) so the validator resolves the network-
5055
+ * assigned `0.0.X` topic id from the receipt and stamps `chainAccounts.hedera`.
5056
+ */
5057
+ async executeCreateTopic(req) {
5058
+ return this.http.post("/api/v3/baas/entities/execute-create", {
5059
+ ...req,
5060
+ entityType: "topic"
5061
+ });
4660
5062
  }
4661
- /** Create a canonical topic entity bound to a published rule. */
5063
+ /**
5064
+ * Create a canonical topic entity bound to a published rule.
5065
+ *
5066
+ * Dispatches by `chain`:
5067
+ * - **Hedera** = payer-funded 3-step (prepare → caller submits the TopicCreate
5068
+ * via `fundWith` → execute resolves the `0.0.X` topic id from the receipt).
5069
+ * `fundWith` is REQUIRED; to drive the steps manually call
5070
+ * `prepareCreateTopic` / `executeCreateTopic` directly.
5071
+ * - **other chains** = legacy synchronous `POST /api/v3/baas/entities/createTopic`
5072
+ * (topics are a Hedera primitive; the legacy path is unchanged).
5073
+ */
4662
5074
  async createTopic(req) {
4663
- return this.http.post("/api/entities/createTopic", req);
5075
+ if (req.chain === "hedera") {
5076
+ const { fundWith, ...prepReq } = req;
5077
+ const prep = await this.prepareCreateTopic(prepReq);
5078
+ if (!fundWith) {
5079
+ throw new Error(
5080
+ "createTopic(hedera): pass fundWith (sign+submit the prepared TopicCreate), or call prepareCreateTopic/executeCreateTopic directly"
5081
+ );
5082
+ }
5083
+ await fundWith(prep.prepared, {
5084
+ address: prep.address,
5085
+ reserveRequirement: prep.reserveRequirement
5086
+ });
5087
+ const createTxId = prep.prepared?.[0]?.transactionId;
5088
+ if (!createTxId) {
5089
+ throw new Error(
5090
+ "createTopic(hedera): prepared TopicCreate carries no transactionId \u2014 cannot resolve the topic id from the receipt"
5091
+ );
5092
+ }
5093
+ return this.executeCreateTopic({
5094
+ entityId: prep.entityId,
5095
+ chain: req.chain,
5096
+ createTxId,
5097
+ securityMode: req.securityMode
5098
+ });
5099
+ }
5100
+ const {
5101
+ fundWith: _ignoredFundWith,
5102
+ payerAccountId: _ignoredPayer,
5103
+ securityMode: _ignoredSecurityMode,
5104
+ ...legacyReq
5105
+ } = req;
5106
+ return this.http.post("/api/v3/baas/entities/createTopic", legacyReq);
4664
5107
  }
4665
5108
  /** Create a canonical agent entity bound to a published rule. */
4666
5109
  async createAgent(req) {
4667
- return this.http.post("/api/entities/createAgent", req);
5110
+ return this.http.post("/api/v3/baas/entities/createAgent", req);
4668
5111
  }
4669
5112
  /**
4670
5113
  * Mega-helper: build a token rule with a launchpad ModuleEntry attached,
@@ -4672,15 +5115,15 @@ var EntitiesClient = class {
4672
5115
  * round-trip.
4673
5116
  */
4674
5117
  async launchpad(req) {
4675
- return this.http.post("/api/entities/launchpad", req);
5118
+ return this.http.post("/api/v3/baas/entities/launchpad", req);
4676
5119
  }
4677
5120
  /** Fetch an entity by its canonical `entityId`. */
4678
5121
  async get(entityId) {
4679
- return this.http.get(`/api/entities/${encodePathParam(entityId)}`);
5122
+ return this.http.get(`/api/v3/baas/entities/${encodePathParam(entityId)}`);
4680
5123
  }
4681
5124
  /** List entities owned by the authenticated wallet, optionally filtered by type. */
4682
5125
  async listByOwner(filter) {
4683
- const path = filter?.type ? `/api/entities?type=${encodeURIComponent(filter.type)}` : "/api/entities";
5126
+ const path = filter?.type ? `/api/v3/baas/entities?type=${encodeURIComponent(filter.type)}` : "/api/v3/baas/entities";
4684
5127
  return this.http.get(path);
4685
5128
  }
4686
5129
  };
@@ -4693,6 +5136,13 @@ var BaasClient = class _BaasClient {
4693
5136
  timeout;
4694
5137
  allowInsecure;
4695
5138
  http;
5139
+ /**
5140
+ * Validator-routed HTTP client for the `/api/v3/transactions/*` prepare/execute
5141
+ * surface — a SIBLING of `/host`, NOT under the `pathPrefix`. Rooted at the
5142
+ * raw gateway/ingress origin (`hostUrl`) so transactions reach the validator
5143
+ * even when BaaS traffic is gateway-routed at `/host/*`.
5144
+ */
5145
+ txHttp;
4696
5146
  /** Last HTTP error (for getHttpHealth) */
4697
5147
  lastHttpError;
4698
5148
  /**
@@ -4721,6 +5171,14 @@ var BaasClient = class _BaasClient {
4721
5171
  rules;
4722
5172
  /** Canonical entity authoring surface (token/account/topic/agent + launchpad). */
4723
5173
  entities;
5174
+ /**
5175
+ * Validator-routed transaction prepare/execute (sovereignty model). The
5176
+ * prepare endpoints accept an explicit `payerAccountId` for the session-less
5177
+ * payer path, OR carry the web3-auth session token for the JWT-wallet payer
5178
+ * path (kept in sync with the main client's token — see {@link authenticate}).
5179
+ * Targets `/api/v3/transactions/*`, a sibling of the `/host` BaaS surface.
5180
+ */
5181
+ transactions;
4724
5182
  constructor(config) {
4725
5183
  this.allowInsecure = config.allowInsecure ?? false;
4726
5184
  this.hostUrl = validateUrl2(config.hostUrl, this.allowInsecure);
@@ -4734,7 +5192,12 @@ var BaasClient = class _BaasClient {
4734
5192
  timeout: this.timeout,
4735
5193
  // Transparent session refresh: on a 401, re-run the challenge-response
4736
5194
  // with the retained signer and retry once. No-op until authenticate() has
4737
- // been called (authContext set). Excludes /api/auth/* (see http client).
5195
+ // been called (authContext set). Excludes /api/v3/{,baas/}auth/* (see http client).
5196
+ onUnauthorized: () => this.reauthenticate()
5197
+ });
5198
+ this.txHttp = createHttpClient({
5199
+ baseUrl: `${this.hostUrl.replace(/\/$/, "")}/api/v3/transactions`,
5200
+ timeout: this.timeout,
4738
5201
  onUnauthorized: () => this.reauthenticate()
4739
5202
  });
4740
5203
  const getAppId = () => this.requireAppId();
@@ -4747,6 +5210,7 @@ var BaasClient = class _BaasClient {
4747
5210
  this.customerSession = new CustomerSessionClient(baseUrlWithPrefix, this.timeout);
4748
5211
  this.rules = new RulesClient(this.http);
4749
5212
  this.entities = new EntitiesClient(this.http);
5213
+ this.transactions = new TransactionsClient(this.txHttp);
4750
5214
  }
4751
5215
  /**
4752
5216
  * Connect to the Smart Engines BaaS via cluster auto-discovery.
@@ -4874,7 +5338,7 @@ var BaasClient = class _BaasClient {
4874
5338
  this.authContext = options;
4875
5339
  let challenge;
4876
5340
  try {
4877
- challenge = await this.http.post("/api/auth/challenge", {
5341
+ challenge = await this.http.post("/api/v3/baas/auth/challenge", {
4878
5342
  chain,
4879
5343
  walletAddress,
4880
5344
  appId: this.appId
@@ -4885,7 +5349,7 @@ var BaasClient = class _BaasClient {
4885
5349
  const signature = await signFn(challenge.message);
4886
5350
  let result;
4887
5351
  try {
4888
- result = await this.http.post("/api/auth/verify", {
5352
+ result = await this.http.post("/api/v3/baas/auth/verify", {
4889
5353
  challengeId: challenge.challengeId,
4890
5354
  signature,
4891
5355
  publicKey
@@ -4894,6 +5358,7 @@ var BaasClient = class _BaasClient {
4894
5358
  throw asBaasError(err);
4895
5359
  }
4896
5360
  this.http.setAuthToken(result.token);
5361
+ this.txHttp.setAuthToken(result.token);
4897
5362
  return result;
4898
5363
  }
4899
5364
  /**
@@ -4901,30 +5366,31 @@ var BaasClient = class _BaasClient {
4901
5366
  * session token. Invoked by the http client's `onUnauthorized` hook when a
4902
5367
  * request 401s because the token expired — so long-lived clients keep working
4903
5368
  * without the caller re-implementing refresh. No-op if {@link authenticate}
4904
- * was never called. The `/api/auth/*` calls below are excluded from the http
5369
+ * was never called. The `/api/v3/baas/auth/*` calls below are excluded from the http
4905
5370
  * client's 401-retry path, so this can never recurse.
4906
5371
  */
4907
5372
  async reauthenticate() {
4908
5373
  const ctx = this.authContext;
4909
5374
  if (!ctx) return;
4910
- const challenge = await this.http.post("/api/auth/challenge", {
5375
+ const challenge = await this.http.post("/api/v3/baas/auth/challenge", {
4911
5376
  chain: ctx.chain,
4912
5377
  walletAddress: ctx.walletAddress,
4913
5378
  appId: this.appId
4914
5379
  });
4915
5380
  const signature = await ctx.signFn(challenge.message);
4916
- const result = await this.http.post("/api/auth/verify", {
5381
+ const result = await this.http.post("/api/v3/baas/auth/verify", {
4917
5382
  challengeId: challenge.challengeId,
4918
5383
  signature,
4919
5384
  publicKey: ctx.publicKey
4920
5385
  });
4921
5386
  this.http.setAuthToken(result.token);
5387
+ this.txHttp.setAuthToken(result.token);
4922
5388
  }
4923
5389
  /** Validate the current session */
4924
5390
  async validateSession() {
4925
5391
  this.requireAuth();
4926
5392
  try {
4927
- return await this.http.get("/api/auth/session");
5393
+ return await this.http.get("/api/v3/baas/auth/session");
4928
5394
  } catch (err) {
4929
5395
  throw asBaasError(err);
4930
5396
  }
@@ -4933,11 +5399,12 @@ var BaasClient = class _BaasClient {
4933
5399
  async logout() {
4934
5400
  if (this.http.getAuthToken()) {
4935
5401
  try {
4936
- await this.http.post("/api/auth/logout", {});
5402
+ await this.http.post("/api/v3/baas/auth/logout", {});
4937
5403
  } catch {
4938
5404
  }
4939
5405
  }
4940
5406
  this.http.setAuthToken(void 0);
5407
+ this.txHttp.setAuthToken(void 0);
4941
5408
  }
4942
5409
  // ========== HTTP Helpers ==========
4943
5410
  requireAuth() {