@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/README.md CHANGED
@@ -100,7 +100,14 @@ import { botimConfig } from 'virtual:botim/config';
100
100
  const handle = await enableRemoteDebug({
101
101
  // The relay URL the plugin baked in. Falls back to same-origin if you
102
102
  // didn't pass `relayUrl` to the plugin (e.g. you're using a dev proxy).
103
+ // For a gateway-hosted relay this is the gateway origin (optionally with a
104
+ // path prefix), e.g. 'https://proxy-uat-ae.botim.me/botim-cli-gateway'.
103
105
  endpoint: botimConfig.relayUrl ?? location.origin,
106
+ // Relay connect token (rdt_…). REQUIRED for gateway-hosted relays, which
107
+ // gate attach on `Authorization: Bearer rdt_…`. Mint one bound to this
108
+ // (mpId, env) with `botim-cli relay token --mp <id> --env uat` (24 h TTL).
109
+ // Omit for the legacy standalone relay, which ignores it.
110
+ token: import.meta.env.VITE_RELAY_TOKEN,
104
111
  config: botimConfig,
105
112
  // app is optional — plugin auto-fills from app_id + version in
106
113
  // botim.{env}.json. Override only when you want a different name/version
package/dist/index.cjs CHANGED
@@ -440,7 +440,7 @@ function sleep(ms) {
440
440
  }
441
441
 
442
442
  // src/attach.ts
443
- async function attachDevice(endpoint, config, deviceInfo, consent) {
443
+ async function attachDevice(endpoint, config, deviceInfo, consent, token) {
444
444
  const base = endpoint.replace(/\/$/, "");
445
445
  const url = `${base}/v1/attach`;
446
446
  const body = {
@@ -451,9 +451,11 @@ async function attachDevice(endpoint, config, deviceInfo, consent) {
451
451
  consent,
452
452
  schemaVersion: SCHEMA_VERSION
453
453
  };
454
+ const headers = { "Content-Type": "application/json" };
455
+ if (token) headers.Authorization = `Bearer ${token}`;
454
456
  const res = await fetch(url, {
455
457
  method: "POST",
456
- headers: { "Content-Type": "application/json" },
458
+ headers,
457
459
  body: JSON.stringify(body)
458
460
  });
459
461
  if (!res.ok) {
@@ -1645,7 +1647,7 @@ async function enableRemoteDebug(options) {
1645
1647
  };
1646
1648
  const deviceInfo = detectDeviceInfo(app, options.device);
1647
1649
  const consent = options.consent ?? {};
1648
- const session = await attachDevice(options.endpoint, options.config, deviceInfo, consent);
1650
+ const session = await attachDevice(options.endpoint, options.config, deviceInfo, consent, options.token);
1649
1651
  const buffer = new RingBuffer({
1650
1652
  capacity: options.bufferSize ?? DEFAULT_BUFFER_SIZE
1651
1653
  });