@botim/mp-debug-sdk 0.7.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -230,6 +230,12 @@ interface RemoteDebugOptions {
230
230
  enabled?: boolean;
231
231
  /** Relay base URL — your debug-relay deployment (e.g. "https://relay.example.com"). */
232
232
  endpoint: string;
233
+ /**
234
+ * Relay connect token (rdt_…) minted with `botim-cli relay token --mp <id>`.
235
+ * REQUIRED when the relay is hosted by botim-gateway (token-gated attach);
236
+ * ignored by legacy standalone relays.
237
+ */
238
+ token?: string;
233
239
  /**
234
240
  * Optional override for the app identity reported in events. When omitted
235
241
  * the SDK falls back to `config.appName` / `config.appVersion` resolved by
package/dist/index.d.ts CHANGED
@@ -230,6 +230,12 @@ interface RemoteDebugOptions {
230
230
  enabled?: boolean;
231
231
  /** Relay base URL — your debug-relay deployment (e.g. "https://relay.example.com"). */
232
232
  endpoint: string;
233
+ /**
234
+ * Relay connect token (rdt_…) minted with `botim-cli relay token --mp <id>`.
235
+ * REQUIRED when the relay is hosted by botim-gateway (token-gated attach);
236
+ * ignored by legacy standalone relays.
237
+ */
238
+ token?: string;
233
239
  /**
234
240
  * Optional override for the app identity reported in events. When omitted
235
241
  * the SDK falls back to `config.appName` / `config.appVersion` resolved by
package/dist/index.js CHANGED
@@ -438,7 +438,7 @@ function sleep(ms) {
438
438
  }
439
439
 
440
440
  // src/attach.ts
441
- async function attachDevice(endpoint, config, deviceInfo, consent) {
441
+ async function attachDevice(endpoint, config, deviceInfo, consent, token) {
442
442
  const base = endpoint.replace(/\/$/, "");
443
443
  const url = `${base}/v1/attach`;
444
444
  const body = {
@@ -449,9 +449,11 @@ async function attachDevice(endpoint, config, deviceInfo, consent) {
449
449
  consent,
450
450
  schemaVersion: SCHEMA_VERSION
451
451
  };
452
+ const headers = { "Content-Type": "application/json" };
453
+ if (token) headers.Authorization = `Bearer ${token}`;
452
454
  const res = await fetch(url, {
453
455
  method: "POST",
454
- headers: { "Content-Type": "application/json" },
456
+ headers,
455
457
  body: JSON.stringify(body)
456
458
  });
457
459
  if (!res.ok) {
@@ -1643,7 +1645,7 @@ async function enableRemoteDebug(options) {
1643
1645
  };
1644
1646
  const deviceInfo = detectDeviceInfo(app, options.device);
1645
1647
  const consent = options.consent ?? {};
1646
- const session = await attachDevice(options.endpoint, options.config, deviceInfo, consent);
1648
+ const session = await attachDevice(options.endpoint, options.config, deviceInfo, consent, options.token);
1647
1649
  const buffer = new RingBuffer({
1648
1650
  capacity: options.bufferSize ?? DEFAULT_BUFFER_SIZE
1649
1651
  });