🚀 Socket Launch Week Day 4:Socket MCP Adds Org Alerts, Threat Feed Review, and Package Inspection.Learn more
Sign In

chaser-sdk

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chaser-sdk - npm Package Compare versions

Comparing version
0.2.0
to
0.2.1
+31
-1
dist/client.js

@@ -22,2 +22,30 @@ import { CdpClient } from './cdp.js';

}
function applyProxyCredentials(url, username, password) {
if (!username && !password) {
return url;
}
const parsed = new URL(url);
if (username) {
parsed.username = username;
}
if (password) {
parsed.password = password;
}
return parsed.toString();
}
function normalizeCreateSessionRequest(request) {
const body = { ...request };
const rootProxy = body.proxy;
const network = isRecord(body.network) ? body.network : null;
const networkMode = network?.mode;
const networkProxy = isRecord(network?.proxy) ? network.proxy : null;
if ((rootProxy === undefined || rootProxy === null || rootProxy === '') &&
networkMode === 'proxy' &&
typeof networkProxy?.url === 'string' &&
networkProxy.url.length > 0) {
body.proxy = applyProxyCredentials(networkProxy.url, typeof networkProxy.username === 'string' ? networkProxy.username : undefined, typeof networkProxy.password === 'string' ? networkProxy.password : undefined);
}
delete body.network;
return body;
}
function isBodyInitLike(value) {

@@ -218,3 +246,5 @@ return (typeof value === 'string' ||

create: async (request) => {
return await this.requestJson('POST', '/v1/sessions', { body: request });
return await this.requestJson('POST', '/v1/sessions', {
body: normalizeCreateSessionRequest(request)
});
},

@@ -221,0 +251,0 @@ list: async () => {

@@ -32,3 +32,8 @@ export type SessionType = 'browser' | 'sandbox';

export interface SessionCreateRequestBase {
/** Canonical proxy selector or proxy URL sent to the API. */
proxy?: string;
/**
* @deprecated Prefer the root-level `proxy` field. The SDK still accepts
* this legacy shape and normalizes `network.proxy.url` for compatibility.
*/
network?: NetworkConfig;

@@ -35,0 +40,0 @@ github_repo?: string | null;

+1
-1
{
"name": "chaser-sdk",
"version": "0.2.0",
"version": "0.2.1",
"description": "Official TypeScript SDK for the Chaser",

@@ -5,0 +5,0 @@ "type": "module",

+41
-13

@@ -80,4 +80,4 @@ # chaser-sdk

const diagnostics = await client.sessions.selfTest(session.id);
const previewUrl = await client.sessions.forwardUrl(session.id, 3000);
console.log(diagnostics.runtime.tools.node, previewUrl.url);
const previewUrl = client.sessions.forwardUrl(session.id, 3000);
console.log(diagnostics.runtime.tools.node, previewUrl);
```

@@ -91,13 +91,10 @@

session_type: 'sandbox',
network: {
mode: 'proxy',
proxy: {
url: 'socks5h://proxy.example.com:1080',
username: process.env.PROXY_USER,
password: process.env.PROXY_PASSWORD
}
}
proxy: 'socks5h://user:pass@proxy.example.com:1080'
});
```
Use the root-level `proxy` field for the public API contract. The SDK still
accepts the older `network.proxy.url` shape and normalizes it for backward
compatibility, but new code should send `proxy` directly.
## Browser CDP helper

@@ -111,5 +108,6 @@

const version = await client.browser.version(browser.id);
const cdpUrl = await client.browser.cdpWebSocketUrl(browser.id);
const cdp = await client.browser.connect(browser.id);
const version = await client.browser.version(browser.id);
console.log(version.webSocketDebuggerUrl);
console.log(version.Browser, cdpUrl);

@@ -120,2 +118,17 @@ await cdp.send('Browser.getVersion');

## Workspace selectors and delete
```ts
const workspace = await client.workspaces.create({
name: 'frontend-app',
session_type: 'sandbox'
});
// Names are preferred when unambiguous; UUIDs work too.
await client.workspaces.delete(workspace.name, { force: true });
```
If a workspace name is ambiguous inside the active account, the API returns a
`workspace_name_ambiguous` error and you should use the workspace UUID instead.
## Account-scoped automation

@@ -161,2 +174,17 @@

- `client.browser.connect()` uses the public CDP endpoint and waits for browser readiness by default.
- `client.sessions.create(...)` now has typed `network.proxy.username/password` support for authenticated upstream proxies.
- For authenticated upstream proxies, embed credentials in the proxy URL, for example `socks5h://user:pass@proxy.example.com:1080`.
## Error handling
```ts
import { ChaserApiError } from 'chaser-sdk';
try {
await client.workspaces.delete('frontend-app');
} catch (error) {
if (error instanceof ChaserApiError) {
console.error(error.status, error.code, error.rateLimit?.remaining);
}
throw error;
}
```