@botim/mp-debug-sdk 0.7.1 → 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 +14 -6
- package/dist/index.cjs +5 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -10
package/dist/index.d.cts
CHANGED
|
@@ -228,8 +228,14 @@ interface AppInfo {
|
|
|
228
228
|
interface RemoteDebugOptions {
|
|
229
229
|
/** When false, returns a no-op handle and installs nothing. */
|
|
230
230
|
enabled?: boolean;
|
|
231
|
-
/** Relay base URL
|
|
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
|
@@ -228,8 +228,14 @@ interface AppInfo {
|
|
|
228
228
|
interface RemoteDebugOptions {
|
|
229
229
|
/** When false, returns a no-op handle and installs nothing. */
|
|
230
230
|
enabled?: boolean;
|
|
231
|
-
/** Relay base URL
|
|
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
|
|
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
|
});
|