@oya-ai/browser 1.0.202 → 1.0.203

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.cjs CHANGED
@@ -138,6 +138,11 @@ var Http = class {
138
138
  this.fetchImpl = fetchImpl;
139
139
  this.origin = origin;
140
140
  }
141
+ baseUrl;
142
+ apiKey;
143
+ timeoutMs;
144
+ fetchImpl;
145
+ origin;
141
146
  /** Sends one request and returns the parsed answer, or throws an OyaError when it failed. */
142
147
  async request(method, path, body, timeoutMs = this.timeoutMs, headers = {}) {
143
148
  const res = await this.send(`${this.baseUrl}${path}`, this.init(method, body, timeoutMs, headers), timeoutMs);
@@ -212,15 +217,32 @@ function addressOf(options, saved) {
212
217
  const found = firstOf(options.baseUrl, "OYA_BASE_URL", saved, "baseUrl");
213
218
  return found.value ? found : { value: DEFAULT_BASE_URL, from: "default" };
214
219
  }
215
- function keyOf(options, saved) {
216
- const found = firstOf(options.apiKey, "OYA_API_KEY", saved, "apiKey");
217
- if (!found.value) throw new Error("No API key. Pass { apiKey }, set OYA_API_KEY, or run `npx @oya-ai/cli login`.");
220
+ function keyOf(options, saved, address) {
221
+ const found = firstOf(options.apiKey, "OYA_API_KEY", savedKeyFor(saved, address), "apiKey");
222
+ if (!found.value) throw new Error(noKey(saved, address));
218
223
  return { ...found, value: headerSafe(found.value, "apiKey", "Copy the key again.") };
219
224
  }
225
+ function savedKeyFor(saved, address) {
226
+ if (!saved.baseUrl || deploymentOf(saved.baseUrl) === deploymentOf(address)) return saved.apiKey;
227
+ return void 0;
228
+ }
229
+ function deploymentOf(url) {
230
+ try {
231
+ const { origin, pathname } = new URL(String(url).trim());
232
+ return `${origin}${pathname.replace(/\/+$/, "")}`;
233
+ } catch {
234
+ return String(url).trim().replace(/\/+$/, "");
235
+ }
236
+ }
237
+ function noKey(saved, address) {
238
+ if (!saved.apiKey) return "No API key. Pass { apiKey }, set OYA_API_KEY, or run `npx @oya-ai/cli login`.";
239
+ const why = `the key saved in ~/.oya/config.json is for ${saved.baseUrl} and is only sent there`;
240
+ return `No API key for ${address}: ${why}. Pass { apiKey }, set OYA_API_KEY, or run \`npx @oya-ai/cli login --url ${address}\`.`;
241
+ }
220
242
  function createHttp(options) {
221
243
  const saved = savedConfig();
222
- const key = keyOf(options, saved.apiKey);
223
244
  const address = addressOf(options, saved.baseUrl);
245
+ const key = keyOf(options, saved, webAddress(address));
224
246
  const fetchImpl = options.fetch || globalThis.fetch;
225
247
  if (!fetchImpl) throw new Error("No fetch available, pass { fetch } or use Node 18+.");
226
248
  const origin = { apiKeyFrom: key.from, baseUrlFrom: address.from, savedKey: !!saved.apiKey };
@@ -335,6 +357,8 @@ var Run = class {
335
357
  this.done.catch(() => {
336
358
  });
337
359
  }
360
+ http;
361
+ id;
338
362
  /** Settles with the result when the run succeeds, or rejects when it fails. */
339
363
  done;
340
364
  /** The run's current state. */
@@ -360,6 +384,8 @@ var Browser = class {
360
384
  ({ id: this.id, provider: this.provider, persona: this.persona, cdpUrl: this.cdpUrl } = info);
361
385
  this.reused = info.reused === true;
362
386
  }
387
+ http;
388
+ autoCaptcha;
363
389
  /** The browser's id. */
364
390
  id;
365
391
  /** Which provider runs it. */
package/dist/index.d.cts CHANGED
@@ -1611,4 +1611,5 @@ declare class Oya {
1611
1611
  private waitUntilConnected;
1612
1612
  }
1613
1613
 
1614
- export { type Activity, type Analysis, type AnalyzeOptions, type AttentionRequest, type Block, Browser, type BrowserDetail, type BrowserInfo, type CaptchaResult, type CaptchaSolver, type Config, type ConfigUpdate, type ControlCredential, type ControlEvent, type ControlOverview, type ControlRole, type ControlSession, type Cookie, type CookieFormat, type DesktopOptions, type EcsAuth, type EcsConfig, type Element, type FileValue, type Fingerprint, type Health, type HumanInputAction, type ImportOptions, type LlmCatalogEntry, type LlmProvider, MAX_FILE_BYTES, type MfaConfig, type MfaResult, Oya, OyaError, type OyaOptions, type PageFormat, type PersonaInfo, type PersonaPrefs, type PlayResult, type Playbook, type PlaybookAnswer, type PlaybookExport, type PlaybookSummary, type ProjectSettings, type Provider, type ProxyCreate, type ProxyInfo, type RecoverOptions, Run, type RunData, type RunInfo, type RunResult, type SandboxRuntime, type Signup, type SignupOptions, type SiteCredentials, type StartOptions, type StartResult, type StopResult, type SubmitOptions, Oya as default, file };
1614
+ export { Browser, MAX_FILE_BYTES, Oya, OyaError, Run, Oya as default, file };
1615
+ export type { Activity, Analysis, AnalyzeOptions, AttentionRequest, Block, BrowserDetail, BrowserInfo, CaptchaResult, CaptchaSolver, Config, ConfigUpdate, ControlCredential, ControlEvent, ControlOverview, ControlRole, ControlSession, Cookie, CookieFormat, DesktopOptions, EcsAuth, EcsConfig, Element, FileValue, Fingerprint, Health, HumanInputAction, ImportOptions, LlmCatalogEntry, LlmProvider, MfaConfig, MfaResult, OyaOptions, PageFormat, PersonaInfo, PersonaPrefs, PlayResult, Playbook, PlaybookAnswer, PlaybookExport, PlaybookSummary, ProjectSettings, Provider, ProxyCreate, ProxyInfo, RecoverOptions, RunData, RunInfo, RunResult, SandboxRuntime, Signup, SignupOptions, SiteCredentials, StartOptions, StartResult, StopResult, SubmitOptions };
package/dist/index.d.ts CHANGED
@@ -1611,4 +1611,5 @@ declare class Oya {
1611
1611
  private waitUntilConnected;
1612
1612
  }
1613
1613
 
1614
- export { type Activity, type Analysis, type AnalyzeOptions, type AttentionRequest, type Block, Browser, type BrowserDetail, type BrowserInfo, type CaptchaResult, type CaptchaSolver, type Config, type ConfigUpdate, type ControlCredential, type ControlEvent, type ControlOverview, type ControlRole, type ControlSession, type Cookie, type CookieFormat, type DesktopOptions, type EcsAuth, type EcsConfig, type Element, type FileValue, type Fingerprint, type Health, type HumanInputAction, type ImportOptions, type LlmCatalogEntry, type LlmProvider, MAX_FILE_BYTES, type MfaConfig, type MfaResult, Oya, OyaError, type OyaOptions, type PageFormat, type PersonaInfo, type PersonaPrefs, type PlayResult, type Playbook, type PlaybookAnswer, type PlaybookExport, type PlaybookSummary, type ProjectSettings, type Provider, type ProxyCreate, type ProxyInfo, type RecoverOptions, Run, type RunData, type RunInfo, type RunResult, type SandboxRuntime, type Signup, type SignupOptions, type SiteCredentials, type StartOptions, type StartResult, type StopResult, type SubmitOptions, Oya as default, file };
1614
+ export { Browser, MAX_FILE_BYTES, Oya, OyaError, Run, Oya as default, file };
1615
+ export type { Activity, Analysis, AnalyzeOptions, AttentionRequest, Block, BrowserDetail, BrowserInfo, CaptchaResult, CaptchaSolver, Config, ConfigUpdate, ControlCredential, ControlEvent, ControlOverview, ControlRole, ControlSession, Cookie, CookieFormat, DesktopOptions, EcsAuth, EcsConfig, Element, FileValue, Fingerprint, Health, HumanInputAction, ImportOptions, LlmCatalogEntry, LlmProvider, MfaConfig, MfaResult, OyaOptions, PageFormat, PersonaInfo, PersonaPrefs, PlayResult, Playbook, PlaybookAnswer, PlaybookExport, PlaybookSummary, ProjectSettings, Provider, ProxyCreate, ProxyInfo, RecoverOptions, RunData, RunInfo, RunResult, SandboxRuntime, Signup, SignupOptions, SiteCredentials, StartOptions, StartResult, StopResult, SubmitOptions };
package/dist/index.js CHANGED
@@ -106,6 +106,11 @@ var Http = class {
106
106
  this.fetchImpl = fetchImpl;
107
107
  this.origin = origin;
108
108
  }
109
+ baseUrl;
110
+ apiKey;
111
+ timeoutMs;
112
+ fetchImpl;
113
+ origin;
109
114
  /** Sends one request and returns the parsed answer, or throws an OyaError when it failed. */
110
115
  async request(method, path, body, timeoutMs = this.timeoutMs, headers = {}) {
111
116
  const res = await this.send(`${this.baseUrl}${path}`, this.init(method, body, timeoutMs, headers), timeoutMs);
@@ -180,15 +185,32 @@ function addressOf(options, saved) {
180
185
  const found = firstOf(options.baseUrl, "OYA_BASE_URL", saved, "baseUrl");
181
186
  return found.value ? found : { value: DEFAULT_BASE_URL, from: "default" };
182
187
  }
183
- function keyOf(options, saved) {
184
- const found = firstOf(options.apiKey, "OYA_API_KEY", saved, "apiKey");
185
- if (!found.value) throw new Error("No API key. Pass { apiKey }, set OYA_API_KEY, or run `npx @oya-ai/cli login`.");
188
+ function keyOf(options, saved, address) {
189
+ const found = firstOf(options.apiKey, "OYA_API_KEY", savedKeyFor(saved, address), "apiKey");
190
+ if (!found.value) throw new Error(noKey(saved, address));
186
191
  return { ...found, value: headerSafe(found.value, "apiKey", "Copy the key again.") };
187
192
  }
193
+ function savedKeyFor(saved, address) {
194
+ if (!saved.baseUrl || deploymentOf(saved.baseUrl) === deploymentOf(address)) return saved.apiKey;
195
+ return void 0;
196
+ }
197
+ function deploymentOf(url) {
198
+ try {
199
+ const { origin, pathname } = new URL(String(url).trim());
200
+ return `${origin}${pathname.replace(/\/+$/, "")}`;
201
+ } catch {
202
+ return String(url).trim().replace(/\/+$/, "");
203
+ }
204
+ }
205
+ function noKey(saved, address) {
206
+ if (!saved.apiKey) return "No API key. Pass { apiKey }, set OYA_API_KEY, or run `npx @oya-ai/cli login`.";
207
+ const why = `the key saved in ~/.oya/config.json is for ${saved.baseUrl} and is only sent there`;
208
+ return `No API key for ${address}: ${why}. Pass { apiKey }, set OYA_API_KEY, or run \`npx @oya-ai/cli login --url ${address}\`.`;
209
+ }
188
210
  function createHttp(options) {
189
211
  const saved = savedConfig();
190
- const key = keyOf(options, saved.apiKey);
191
212
  const address = addressOf(options, saved.baseUrl);
213
+ const key = keyOf(options, saved, webAddress(address));
192
214
  const fetchImpl = options.fetch || globalThis.fetch;
193
215
  if (!fetchImpl) throw new Error("No fetch available, pass { fetch } or use Node 18+.");
194
216
  const origin = { apiKeyFrom: key.from, baseUrlFrom: address.from, savedKey: !!saved.apiKey };
@@ -303,6 +325,8 @@ var Run = class {
303
325
  this.done.catch(() => {
304
326
  });
305
327
  }
328
+ http;
329
+ id;
306
330
  /** Settles with the result when the run succeeds, or rejects when it fails. */
307
331
  done;
308
332
  /** The run's current state. */
@@ -328,6 +352,8 @@ var Browser = class {
328
352
  ({ id: this.id, provider: this.provider, persona: this.persona, cdpUrl: this.cdpUrl } = info);
329
353
  this.reused = info.reused === true;
330
354
  }
355
+ http;
356
+ autoCaptcha;
331
357
  /** The browser's id. */
332
358
  id;
333
359
  /** Which provider runs it. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oya-ai/browser",
3
- "version": "1.0.202",
3
+ "version": "1.0.203",
4
4
  "description": "Rotate thousands of browsers behind one API, personas, proxies, stealth, CAPTCHA and MFA.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://oyabrowser.com",
@@ -69,7 +69,7 @@
69
69
  "devDependencies": {
70
70
  "@arethetypeswrong/cli": "^0.18.5",
71
71
  "publint": "^0.3.25",
72
- "tsup": "^8.5.1",
72
+ "tsup": "^9.0.0",
73
73
  "typescript": "^6.0.3"
74
74
  },
75
75
  "author": "mk@getoya.ai"