@hsuite/smart-engines-sdk 3.10.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,
@@ -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
  };
@@ -2937,50 +2980,58 @@ var AgentsClient = class {
2937
2980
  }
2938
2981
  http;
2939
2982
  /** Register a new agent */
2940
- async register(request) {
2941
- return this.http.post("/api/v3/baas/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/v3/baas/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/v3/baas/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/v3/baas/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/v3/baas/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/v3/baas/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/v3/baas/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/v3/baas/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/v3/baas/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.
@@ -2990,24 +3041,24 @@ var AgentsClient = class {
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/v3/baas/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/v3/baas/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/v3/baas/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/v3/baas/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/v3/baas/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
 
@@ -4343,30 +4394,31 @@ var StorageClient = class {
4343
4394
  /**
4344
4395
  * Upload a file to storage
4345
4396
  */
4346
- async upload(file, filename, metadata) {
4397
+ async upload(file, filename, metadata, opts) {
4347
4398
  const appId = this.getAppId();
4348
- return this.http.upload(`/api/v3/baas/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);
4349
4400
  }
4350
4401
  /**
4351
- * 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).
4352
4404
  */
4353
- async download(cid) {
4405
+ async download(cid, opts) {
4354
4406
  const appId = this.getAppId();
4355
- return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/download/${encodePathParam(cid)}`);
4407
+ return this.http.getBinary(`/api/v3/baas/storage/${encodePathParam(appId)}/download/${encodePathParam(cid)}`, opts);
4356
4408
  }
4357
4409
  /**
4358
4410
  * Get file metadata
4359
4411
  */
4360
- async getMetadata(cid) {
4412
+ async getMetadata(cid, opts) {
4361
4413
  const appId = this.getAppId();
4362
- return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/metadata/${encodePathParam(cid)}`);
4414
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/metadata/${encodePathParam(cid)}`, opts);
4363
4415
  }
4364
4416
  /**
4365
4417
  * Delete a file
4366
4418
  */
4367
- async delete(cid) {
4419
+ async delete(cid, opts) {
4368
4420
  const appId = this.getAppId();
4369
- return this.http.delete(`/api/v3/baas/storage/${encodePathParam(appId)}/${encodePathParam(cid)}`);
4421
+ return this.http.delete(`/api/v3/baas/storage/${encodePathParam(appId)}/${encodePathParam(cid)}`, opts);
4370
4422
  }
4371
4423
  /**
4372
4424
  * List all files for the app.
@@ -4375,27 +4427,27 @@ var StorageClient = class {
4375
4427
  * `offset` for pagination).
4376
4428
  * @returns The file list and total count.
4377
4429
  */
4378
- async listFiles(pagination) {
4430
+ async listFiles(pagination, opts) {
4379
4431
  const appId = this.getAppId();
4380
4432
  const params = new URLSearchParams();
4381
4433
  if (pagination?.limit !== void 0) params.set("limit", String(pagination.limit));
4382
4434
  if (pagination?.offset !== void 0) params.set("offset", String(pagination.offset));
4383
4435
  const qs = params.toString();
4384
- return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/files${qs ? `?${qs}` : ""}`);
4436
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/files${qs ? `?${qs}` : ""}`, opts);
4385
4437
  }
4386
4438
  /**
4387
4439
  * Get storage usage for the current app
4388
4440
  */
4389
- async getUsage() {
4441
+ async getUsage(opts) {
4390
4442
  const appId = this.getAppId();
4391
- return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/usage`);
4443
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/usage`, opts);
4392
4444
  }
4393
4445
  /**
4394
4446
  * Check if a file exists
4395
4447
  */
4396
- async exists(cid) {
4448
+ async exists(cid, opts) {
4397
4449
  const appId = this.getAppId();
4398
- return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/exists/${encodePathParam(cid)}`);
4450
+ return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/exists/${encodePathParam(cid)}`, opts);
4399
4451
  }
4400
4452
  };
4401
4453
 
@@ -4408,61 +4460,99 @@ var FunctionsClient = class {
4408
4460
  http;
4409
4461
  getAppId;
4410
4462
  /**
4411
- * Deploy a new function
4412
- */
4413
- 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) {
4414
4487
  const appId = this.getAppId();
4415
- return this.http.post(`/api/v3/baas/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);
4416
4490
  }
4417
4491
  /**
4418
4492
  * Invoke a function
4419
4493
  */
4420
- async invoke(functionId, payload) {
4494
+ async invoke(functionId, payload, opts) {
4421
4495
  const appId = this.getAppId();
4422
4496
  return this.http.post(
4423
4497
  `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/invoke`,
4424
- payload ?? {}
4498
+ payload ?? {},
4499
+ opts
4425
4500
  );
4426
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
+ }
4427
4514
  /**
4428
4515
  * List all functions for the current app
4429
4516
  */
4430
- async list() {
4517
+ async list(opts) {
4431
4518
  const appId = this.getAppId();
4432
- return this.http.get(`/api/v3/baas/functions/${encodePathParam(appId)}`);
4519
+ return this.http.get(`/api/v3/baas/functions/${encodePathParam(appId)}`, opts);
4433
4520
  }
4434
4521
  /**
4435
4522
  * Get function details
4436
4523
  */
4437
- async get(functionId) {
4524
+ async get(functionId, opts) {
4438
4525
  const appId = this.getAppId();
4439
4526
  return this.http.get(
4440
- `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`
4527
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
4528
+ opts
4441
4529
  );
4442
4530
  }
4443
4531
  /**
4444
4532
  * Update a function
4445
4533
  */
4446
- async update(functionId, updates) {
4534
+ async update(functionId, updates, opts) {
4447
4535
  const appId = this.getAppId();
4448
4536
  return this.http.put(
4449
4537
  `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
4450
- updates
4538
+ updates,
4539
+ opts
4451
4540
  );
4452
4541
  }
4453
4542
  /**
4454
4543
  * Delete a function
4455
4544
  */
4456
- async delete(functionId) {
4545
+ async delete(functionId, opts) {
4457
4546
  const appId = this.getAppId();
4458
4547
  return this.http.delete(
4459
- `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`
4548
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
4549
+ opts
4460
4550
  );
4461
4551
  }
4462
4552
  /**
4463
4553
  * Get function execution logs
4464
4554
  */
4465
- async getLogs(functionId, options) {
4555
+ async getLogs(functionId, options, opts) {
4466
4556
  const appId = this.getAppId();
4467
4557
  const params = new URLSearchParams();
4468
4558
  if (options?.limit !== void 0) params.set("limit", String(options.limit));
@@ -4470,15 +4560,16 @@ var FunctionsClient = class {
4470
4560
  if (options?.level) params.set("level", options.level);
4471
4561
  const qs = params.toString();
4472
4562
  return this.http.get(
4473
- `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/logs${qs ? `?${qs}` : ""}`
4563
+ `/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/logs${qs ? `?${qs}` : ""}`,
4564
+ opts
4474
4565
  );
4475
4566
  }
4476
4567
  /**
4477
4568
  * Get function statistics for an app
4478
4569
  */
4479
- async getStats() {
4570
+ async getStats(opts) {
4480
4571
  const appId = this.getAppId();
4481
- return this.http.get(`/api/v3/baas/functions/${encodePathParam(appId)}/stats`);
4572
+ return this.http.get(`/api/v3/baas/functions/${encodePathParam(appId)}/stats`, opts);
4482
4573
  }
4483
4574
  };
4484
4575
 
@@ -4493,45 +4584,46 @@ var MessagingClient = class {
4493
4584
  /**
4494
4585
  * Create a new channel
4495
4586
  */
4496
- async createChannel(config) {
4587
+ async createChannel(config, opts) {
4497
4588
  const appId = this.getAppId();
4498
- return this.http.post(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels`, config);
4589
+ return this.http.post(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels`, config, opts);
4499
4590
  }
4500
4591
  /**
4501
4592
  * Delete a channel
4502
4593
  */
4503
- async deleteChannel(channelId) {
4594
+ async deleteChannel(channelId, opts) {
4504
4595
  const appId = this.getAppId();
4505
- return this.http.delete(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`);
4596
+ return this.http.delete(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`, opts);
4506
4597
  }
4507
4598
  /**
4508
4599
  * Get a channel by ID
4509
4600
  */
4510
- async getChannel(channelId) {
4601
+ async getChannel(channelId, opts) {
4511
4602
  const appId = this.getAppId();
4512
- return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`);
4603
+ return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`, opts);
4513
4604
  }
4514
4605
  /**
4515
4606
  * List all channels for the app
4516
4607
  */
4517
- async listChannels() {
4608
+ async listChannels(opts) {
4518
4609
  const appId = this.getAppId();
4519
- return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels`);
4610
+ return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels`, opts);
4520
4611
  }
4521
4612
  /**
4522
4613
  * Publish a message to a channel
4523
4614
  */
4524
- async publish(channel, message, metadata) {
4615
+ async publish(channel, message, metadata, opts) {
4525
4616
  const appId = this.getAppId();
4526
4617
  return this.http.post(
4527
4618
  `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/publish`,
4528
- { data: message, metadata }
4619
+ { data: message, metadata },
4620
+ opts
4529
4621
  );
4530
4622
  }
4531
4623
  /**
4532
4624
  * Get message history for a channel
4533
4625
  */
4534
- async getHistory(channel, options) {
4626
+ async getHistory(channel, options, opts) {
4535
4627
  const appId = this.getAppId();
4536
4628
  const params = new URLSearchParams();
4537
4629
  if (options?.limit !== void 0) params.set("limit", String(options.limit));
@@ -4539,7 +4631,8 @@ var MessagingClient = class {
4539
4631
  if (options?.after) params.set("after", options.after);
4540
4632
  const qs = params.toString();
4541
4633
  return this.http.get(
4542
- `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/history${qs ? `?${qs}` : ""}`
4634
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/history${qs ? `?${qs}` : ""}`,
4635
+ opts
4543
4636
  );
4544
4637
  }
4545
4638
  /**
@@ -4550,11 +4643,12 @@ var MessagingClient = class {
4550
4643
  * `setPresence(member)` hit a non-existent appId-scoped route and 404'd
4551
4644
  * in production. The channel is now the first argument.
4552
4645
  */
4553
- async setPresence(channel, member) {
4646
+ async setPresence(channel, member, opts) {
4554
4647
  const appId = this.getAppId();
4555
4648
  return this.http.post(
4556
4649
  `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`,
4557
- member
4650
+ member,
4651
+ opts
4558
4652
  );
4559
4653
  }
4560
4654
  /**
@@ -4566,27 +4660,29 @@ var MessagingClient = class {
4566
4660
  * `clientId` (not `memberId`) the second — they're the same identifier
4567
4661
  * but renamed to match the server param.
4568
4662
  */
4569
- async removePresence(channel, clientId) {
4663
+ async removePresence(channel, clientId, opts) {
4570
4664
  const appId = this.getAppId();
4571
4665
  return this.http.delete(
4572
- `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence/${encodePathParam(clientId)}`
4666
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence/${encodePathParam(clientId)}`,
4667
+ opts
4573
4668
  );
4574
4669
  }
4575
4670
  /**
4576
4671
  * Get presence info for a channel
4577
4672
  */
4578
- async getPresence(channel) {
4673
+ async getPresence(channel, opts) {
4579
4674
  const appId = this.getAppId();
4580
4675
  return this.http.get(
4581
- `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`
4676
+ `/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`,
4677
+ opts
4582
4678
  );
4583
4679
  }
4584
4680
  /**
4585
4681
  * Get messaging statistics
4586
4682
  */
4587
- async getStats() {
4683
+ async getStats(opts) {
4588
4684
  const appId = this.getAppId();
4589
- return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/stats`);
4685
+ return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/stats`, opts);
4590
4686
  }
4591
4687
  };
4592
4688