@browserbasehq/sdk
Advanced tools
Comparing version 1.3.1 to 1.4.0
{ | ||
"name": "@browserbasehq/sdk", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "Browserbase JS SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -48,2 +48,6 @@ import puppeteer from 'puppeteer-core' | ||
} | ||
context?: { | ||
id: string; | ||
persist: boolean; | ||
}; | ||
} | ||
@@ -374,4 +378,22 @@ keepAlive?: boolean | ||
} | ||
async createContext(): Promise<{ id: string }> { | ||
const response = await fetch(`${this.baseAPIURL}/v1/contexts`, { | ||
method: 'POST', | ||
headers: { | ||
'x-bb-api-key': this.apiKey, | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ projectId: this.projectId }), | ||
}); | ||
if (!response.ok) { | ||
throw new Error('Failed to create context'); | ||
} | ||
const data = await response.json(); | ||
return data; | ||
} | ||
} | ||
export { Browserbase, BrowserbaseAISDK } |
import { describe, it, beforeEach } from 'node:test' | ||
import { expect } from 'chai' | ||
import { Browserbase, BrowserbaseAISDK } from '../src' | ||
import { Browserbase, BrowserbaseAISDK, CreateSessionOptions } from '../src' | ||
@@ -76,2 +76,19 @@ describe('Browserbase', () => { | ||
}) | ||
it('should create a session with dynamically created context', async () => { | ||
const createContextResponse = await browserbase.createContext(); | ||
const contextId = createContextResponse.id; | ||
// Use the created context ID in session creation | ||
const sessionOptions: CreateSessionOptions = { | ||
browserSettings: { | ||
context: { | ||
id: contextId, | ||
persist: true | ||
} | ||
} | ||
}; | ||
const { id } = await browserbase.createSession(sessionOptions); | ||
const session = await browserbase.getSession(id); | ||
}) | ||
}) |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
0
0
40463
12
448
1