@botim/mp-debug-sdk 0.7.0 → 0.7.2

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
@@ -13,14 +13,14 @@ Mini-programs run on user devices in environments you can't easily attach a debu
13
13
 
14
14
  ## Install
15
15
 
16
- > **Heads-up registry override required in BOTIM repos.**
17
- > Most BOTIM mini-program repos pin the `@botim` scope to the internal Artifactory mirror (`@botim:registry=https://artifactory.corp.algento.com/artifactory/api/npm/bot-npm/`). This SDK is **published to public npm**, so a plain `npm install @botim/mp-debug-sdk` in those repos will hit Artifactory, not find the package, and 404. Use the public registry explicitly for this one package:
16
+ > **If your project's `.npmrc` pins the `@botim` scope to a private registry, override it for this package.**
17
+ > This SDK is published to public npm. If your `.npmrc` contains a line like `@botim:registry=<private-mirror-url>`, plain `npm install @botim/mp-debug-sdk` will route to the private mirror, not find the package, and fail. Use:
18
18
 
19
19
  ```bash
20
20
  npm install @botim/mp-debug-sdk --registry=https://registry.npmjs.org/
21
21
  ```
22
22
 
23
- If your repo doesn't have an `@botim` scope override (rare), the flag is harmless — npm uses `registry.npmjs.org` by default. **Don't** add `@botim:registry=https://registry.npmjs.org/` to your `.npmrc`: it would shadow the internal Artifactory registry that other `@botim/*` packages (mp-framework, etc.) need.
23
+ If your repo has no `@botim` scope override, the flag is harmless — npm uses `registry.npmjs.org` by default. Don't permanently re-pin the `@botim` scope to public npm in your `.npmrc`: it would shadow whatever private registry your other `@botim/*` packages come from.
24
24
 
25
25
  ## 1. Add the env config files
26
26
 
@@ -127,7 +127,7 @@ That's it — `console.*`, network calls, and uncaught errors now stream to the
127
127
 
128
128
  ### Cross-origin setup
129
129
 
130
- The SDK posts directly to `endpoint` — there's no proxy required. Your relay must allow the page's origin via CORS. The reference [`@botim/debug-relay`](https://github.com/botim/debug-relay) ships with `CORS_ORIGINS=*` by default; tighten via env when going to production:
130
+ The SDK posts directly to `endpoint` — there's no proxy required. Your relay must allow the page's origin via CORS. A reference debug-relay implementation typically defaults to `CORS_ORIGINS=*` for development; tighten via env when going to production:
131
131
 
132
132
  ```bash
133
133
  CORS_ORIGINS=https://my-mp.example.com,https://staging.example.com
@@ -139,7 +139,7 @@ Once `enableRemoteDebug` returns, an attached agent can send a JS snippet to the
139
139
 
140
140
  ```bash
141
141
  # From any terminal that can reach your relay:
142
- curl -sX POST "https://debug.botim.dev/v1/mp/<MP_ID>/devices/<DEVICE_ID>/commands" \
142
+ curl -sX POST "<RELAY_URL>/v1/mp/<MP_ID>/devices/<DEVICE_ID>/commands" \
143
143
  -H 'content-type: application/json' \
144
144
  -d '{"name":"exec","args":{"code":"console.log(\"hi\"); return window.location.href"}}'
145
145
  ```
@@ -222,7 +222,7 @@ console.log(handle.sid); // server-issued session id
222
222
 
223
223
  ## Debugging a live mini-program
224
224
 
225
- Once your build is wired and shipped, see **[`docs/live-debugging.md`](./docs/live-debugging.md)** for the end-to-end runbook against the shared demo relay at `https://aistudiodemo.ext.algento.com/mp-debug-relay`. It covers:
225
+ Once your build is wired and shipped, see **[`docs/live-debugging.md`](./docs/live-debugging.md)** for the end-to-end runbook against your debug-relay deployment. It covers:
226
226
 
227
227
  - pointing the Vite plugin at the live relay URL,
228
228
  - pulling errors and tailing sessions from the admin UI,
@@ -255,3 +255,4 @@ cp -r .claude/skills/botim-debug-relay ~/.claude/skills/
255
255
  ## License
256
256
 
257
257
  [ISC](./LICENSE) © BOTIM
258
+
package/dist/index.cjs CHANGED
@@ -1616,19 +1616,24 @@ function assertConfig(config) {
1616
1616
  async function enableRemoteDebug(options) {
1617
1617
  if (options.enabled === false) return NOOP_HANDLE;
1618
1618
  assertConfig(options.config);
1619
- if (options.consent?.promptUser) {
1619
+ const consentInput = options.consent ?? {};
1620
+ const hasExplicitConsent = consentInput.userOptIn === true || typeof consentInput.hostToken === "string" && consentInput.hostToken.length > 0;
1621
+ const promptDisabled = consentInput.promptUser === false;
1622
+ const canPrompt = typeof document !== "undefined" && typeof window !== "undefined";
1623
+ const shouldPrompt = !hasExplicitConsent && !promptDisabled && canPrompt;
1624
+ if (shouldPrompt) {
1620
1625
  const cached = readConsentDecision(options.config.miniProgramId);
1621
1626
  let decision = cached;
1622
1627
  if (decision === null) {
1623
1628
  decision = await promptForConsent(
1624
1629
  options.config.miniProgramId,
1625
- options.consent.promptCopy
1630
+ consentInput.promptCopy
1626
1631
  );
1627
1632
  }
1628
1633
  if (decision === "denied") return NOOP_HANDLE;
1629
1634
  options = {
1630
1635
  ...options,
1631
- consent: { ...options.consent, userOptIn: true }
1636
+ consent: { ...consentInput, userOptIn: true }
1632
1637
  };
1633
1638
  }
1634
1639
  assertConsent(options.config, options.consent);