@solarisdk/browserbase-compat 0.2.0 → 0.2.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.1
4
+ - **Security: the base URL check accepts only the Solari API hosts.** It used to accept any `*.getsolari.com` host, including sandbox preview hosts (`<label>-<port>.preview.getsolari.com`) that serve customer code, so a `baseURL` / `SOLARI_BASE_URL` pointed there would send your `slr_` key to code running in a sandbox. Now only the Solari API hosts and loopback are accepted.
5
+
3
6
  ## 0.2.0
4
7
  - `timeout`, `keepAlive` and `userMetadata` are sent to Solari (they were warned about and ignored in 0.1.0). `userMetadata` comes back on `create`, `retrieve` and `list`, and `sessions.list({ q })` filters on it.
5
8
  - **A base URL that does not point at Solari is now refused.** `baseURL` and `SOLARI_BASE_URL` must be `https` on `getsolari.com` (or a subdomain) or a loopback address; anything else throws `BrowserbaseError` ("Refusing to send a Solari API key to …"). In 0.1.0 such a URL was used as given, which could send your `slr_` key to another host.
package/COMPAT.md CHANGED
@@ -22,7 +22,7 @@ Keep it private: the session id inside it is the credential.
22
22
  | | |
23
23
  |---|---|
24
24
  | Key | `apiKey` option, else `SOLARI_API_KEY`, else `BROWSERBASE_API_KEY`. **A key that does not start with `slr_` is never used or sent** (it is probably a Browserbase secret): it is skipped with a warning that does not print it, and if no `slr_` key remains the constructor throws. |
25
- | Endpoint | `baseURL` option or `SOLARI_BASE_URL`; default `https://api.getsolari.com`. Must be `https` on `getsolari.com` (or a subdomain) or loopback, otherwise the constructor throws `BrowserbaseError` ("Refusing to send a Solari API key to …"): the key is never sent to another host. |
25
+ | Endpoint | `baseURL` option or `SOLARI_BASE_URL`; default `https://api.getsolari.com`. Must be `https` on a Solari API host or loopback (preview and other `*.getsolari.com` hosts are refused: they serve customer code), otherwise the constructor throws `BrowserbaseError` ("Refusing to send a Solari API key to …"): the key is never sent to another host. |
26
26
  | `projectId` | Accepted and ignored: Solari keys belong to an organisation, there are no projects. |
27
27
 
28
28
  ## Works
@@ -35,7 +35,7 @@ Keep it private: the session id inside it is the credential.
35
35
  | `browserSettings.verified`, `advancedStealth` | Solari's stealth browser. |
36
36
  | `browserSettings.solveCaptchas: true` | Solari captcha solving (stealth browser, plan-gated). **Off unless you pass `true`**: Browserbase turns it on by default. |
37
37
  | `browserSettings.recordSession: true` | Session recording. **Off unless you pass `true`**: Browserbase records by default. Read it back with `sessions.recording.retrieve(id)` (rrweb events). |
38
- | `browserSettings.allowedDomains` | Egress allowlist (enterprise plan, stealth browser); a plan error comes back as an `APIError` with `code: "FeatureRequiresPlan"`. |
38
+ | `browserSettings.allowedDomains` | Egress allowlist (Team or Enterprise plan, stealth browser); a plan error comes back as an `APIError` with `code: "FeatureRequiresPlan"`. |
39
39
  | `browserSettings.context: { id, persist }`, `contexts.create/retrieve/delete` | A Context is a Solari **profile**. See [Contexts](#contexts). |
40
40
  | `sessions.debug(id, { expiresIn })` | A view-only live-view link (`debuggerUrl` and `debuggerFullscreenUrl` are the same link; `pages` is empty; `wsUrl` is the CDP URL). |
41
41
 
package/dist/client.d.ts CHANGED
@@ -15,7 +15,7 @@ export interface BrowserbaseOptions {
15
15
  /** Test hook. */
16
16
  fetch?: typeof fetch;
17
17
  }
18
- /** Whether a base URL may receive a Solari key: https on getsolari.com or a subdomain, or loopback. */
18
+ /** Whether a base URL may receive a Solari key: https on a Solari API host, or loopback. */
19
19
  export declare function isSolariBaseUrl(raw: string): boolean;
20
20
  export declare class Browserbase {
21
21
  readonly sessions: Sessions;
package/dist/client.js CHANGED
@@ -19,7 +19,9 @@ function resolveApiKey(explicit, warn) {
19
19
  }
20
20
  throw new BrowserbaseError("No Solari API key: pass apiKey or set SOLARI_API_KEY (keys start with slr_)");
21
21
  }
22
- /** Whether a base URL may receive a Solari key: https on getsolari.com or a subdomain, or loopback. */
22
+ /** The only Solari hosts that may receive a key (the API gateways). Not every *.getsolari.com host: preview hosts (<label>-<port>.preview.getsolari.com) serve customer code. */
23
+ const SOLARI_API_HOST = /^api(-sta(-gcp)?)?\.getsolari\.com$/;
24
+ /** Whether a base URL may receive a Solari key: https on a Solari API host, or loopback. */
23
25
  export function isSolariBaseUrl(raw) {
24
26
  let u;
25
27
  try {
@@ -31,7 +33,7 @@ export function isSolariBaseUrl(raw) {
31
33
  if (u.username || u.password)
32
34
  return false; // never a URL with credentials in it
33
35
  const host = u.hostname.toLowerCase().replace(/\.$/, "");
34
- if (u.protocol === "https:" && (host === "getsolari.com" || host.endsWith(".getsolari.com")))
36
+ if (u.protocol === "https:" && SOLARI_API_HOST.test(host))
35
37
  return true;
36
38
  const loopback = host === "localhost" || host === "[::1]" || /^127(\.\d{1,3}){3}$/.test(host);
37
39
  return loopback && (u.protocol === "http:" || u.protocol === "https:");
@@ -49,7 +51,7 @@ function resolveBaseUrl(explicit) {
49
51
  if (!given)
50
52
  return DEFAULT_BASE_URL;
51
53
  if (!isSolariBaseUrl(given)) {
52
- throw new BrowserbaseError(`Refusing to send a Solari API key to ${describeHost(given)}: it does not point at Solari (getsolari.com or loopback).`);
54
+ throw new BrowserbaseError(`Refusing to send a Solari API key to ${describeHost(given)}: it is not a Solari API host or loopback.`);
53
55
  }
54
56
  return given.replace(/\/+$/, "");
55
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solarisdk/browserbase-compat",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Drop-in Browserbase-style SDK surface for Solari Browser: sessions, connectUrl (CDP), contexts, live view, replay events.",
5
5
  "license": "MIT",
6
6
  "type": "module",