cbrowser 18.19.0 → 18.22.0
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/analysis/accessibility-empathy.d.ts.map +1 -1
- package/dist/analysis/accessibility-empathy.js +2 -1
- package/dist/analysis/accessibility-empathy.js.map +1 -1
- package/dist/analysis/agent-ready-audit.d.ts.map +1 -1
- package/dist/analysis/agent-ready-audit.js +2 -1
- package/dist/analysis/agent-ready-audit.js.map +1 -1
- package/dist/analysis/competitive-benchmark.d.ts.map +1 -1
- package/dist/analysis/competitive-benchmark.js +2 -1
- package/dist/analysis/competitive-benchmark.js.map +1 -1
- package/dist/browser.d.ts +20 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +98 -0
- package/dist/browser.js.map +1 -1
- package/dist/cli.js +259 -27
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/lightpanda.d.ts +184 -0
- package/dist/lightpanda.d.ts.map +1 -0
- package/dist/lightpanda.js +416 -0
- package/dist/lightpanda.js.map +1 -0
- package/dist/remediation/llms-txt.d.ts.map +1 -1
- package/dist/remediation/llms-txt.js +2 -1
- package/dist/remediation/llms-txt.js.map +1 -1
- package/dist/remediation/structured-data.d.ts.map +1 -1
- package/dist/remediation/structured-data.js +2 -1
- package/dist/remediation/structured-data.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* await browser.close();
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
export { CBrowser } from "./browser.js";
|
|
19
|
+
export { CBrowser, launchBrowserWithFallback, isBrowserNotInstalledError, installPlaywrightBrowsers, getBrowserInstallErrorMessage } from "./browser.js";
|
|
20
20
|
export { getDefaultConfig, getPaths, ensureDirectories, mergeConfig } from "./config.js";
|
|
21
21
|
export type { CBrowserConfig, CBrowserPaths, BrowserType } from "./config.js";
|
|
22
22
|
export * from "./types.js";
|
|
@@ -38,4 +38,6 @@ export * from "./values/index.js";
|
|
|
38
38
|
export { registerAllPublicTools, registerBaseTools, registerPersonaCreationTools, registerAskUserTool, registerEnterpriseStubs, registerNavigationTools, registerInteractionTools, registerExtractionTools, registerAssertionTools, registerAnalysisTools, registerSessionTools, registerHealingTools, registerVisualTestingTools, registerTestingTools, registerBugAnalysisTools, registerPersonaComparisonTools, registerCognitiveTools, registerValuesTools, registerPerformanceTools, registerAuditTools, registerBrowserManagementTools, registerRemediationTools, registerLlmsTxtTools, } from "./mcp-tools/index.js";
|
|
39
39
|
export type { ToolRegistrationContext } from "./mcp-tools/index.js";
|
|
40
40
|
export * from "./security/index.js";
|
|
41
|
+
export { connectToLightpanda, launchWithLightpandaFallback, getLightpandaStatus, isLightpandaConfigured, shouldUseLightpanda, getLightpandaConfig, isSensitiveOperation, LIGHTPANDA_SETUP_GUIDE, LIGHTPANDA_SECURITY_WARNING, LIGHTPANDA_LOCAL_ENDPOINT, LIGHTPANDA_CLOUD_ENDPOINT, } from "./lightpanda.js";
|
|
42
|
+
export type { LightpandaConfig, LightpandaConnectionResult, SensitiveOperation } from "./lightpanda.js";
|
|
41
43
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,6BAA6B,EAAE,MAAM,cAAc,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,EAAE,MAAM,sBAAsB,CAAC;AAGpE,cAAc,qBAAqB,CAAC;AAKpC,OAAO,EACL,mBAAmB,EACnB,4BAA4B,EAC5B,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,2BAA2B,EAC3B,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* await browser.close();
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
export { CBrowser } from "./browser.js";
|
|
19
|
+
export { CBrowser, launchBrowserWithFallback, isBrowserNotInstalledError, installPlaywrightBrowsers, getBrowserInstallErrorMessage } from "./browser.js";
|
|
20
20
|
export { getDefaultConfig, getPaths, ensureDirectories, mergeConfig } from "./config.js";
|
|
21
21
|
export * from "./types.js";
|
|
22
22
|
export { BUILTIN_PERSONAS, registerPersonas } from "./personas.js";
|
|
@@ -56,4 +56,8 @@ export { registerAllPublicTools, registerBaseTools, registerPersonaCreationTools
|
|
|
56
56
|
registerNavigationTools, registerInteractionTools, registerExtractionTools, registerAssertionTools, registerAnalysisTools, registerSessionTools, registerHealingTools, registerVisualTestingTools, registerTestingTools, registerBugAnalysisTools, registerPersonaComparisonTools, registerCognitiveTools, registerValuesTools, registerPerformanceTools, registerAuditTools, registerBrowserManagementTools, registerRemediationTools, registerLlmsTxtTools, } from "./mcp-tools/index.js";
|
|
57
57
|
// Security module (v18.0.0) - Request signing and audit logging
|
|
58
58
|
export * from "./security/index.js";
|
|
59
|
+
// Lightpanda Integration (v18.20.0) - High-performance headless browser
|
|
60
|
+
// Uses CDP connection for 11x faster, 9x less memory headless browsing
|
|
61
|
+
// ⚠️ SECURITY: Opt-in only, no security audit, never for sensitive ops
|
|
62
|
+
export { connectToLightpanda, launchWithLightpandaFallback, getLightpandaStatus, isLightpandaConfigured, shouldUseLightpanda, getLightpandaConfig, isSensitiveOperation, LIGHTPANDA_SETUP_GUIDE, LIGHTPANDA_SECURITY_WARNING, LIGHTPANDA_LOCAL_ENDPOINT, LIGHTPANDA_CLOUD_ENDPOINT, } from "./lightpanda.js";
|
|
59
63
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAC;AACzJ,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEzF,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEnE,yEAAyE;AACzE,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEvH,2BAA2B;AAC3B,wBAAwB;AACxB,cAAc,mBAAmB,CAAC;AAElC,iBAAiB;AACjB,cAAc,oBAAoB,CAAC;AAEnC,kBAAkB;AAClB,cAAc,qBAAqB,CAAC;AAEpC,+BAA+B;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.shai.eden@gmail.com
|
|
4
|
+
* Learn more at https://cbrowser.ai - MIT License
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Lightpanda Integration
|
|
8
|
+
*
|
|
9
|
+
* Lightpanda is a high-performance headless browser written in Zig.
|
|
10
|
+
* It's 11x faster and uses 9x less memory than Chrome headless.
|
|
11
|
+
*
|
|
12
|
+
* This module provides CDP-based integration with Playwright, allowing
|
|
13
|
+
* CBrowser to use Lightpanda as an alternative browser backend.
|
|
14
|
+
*
|
|
15
|
+
* ⚠️ SECURITY NOTICE:
|
|
16
|
+
* - Lightpanda is BETA software with no formal security audit
|
|
17
|
+
* - No SECURITY.md or vulnerability disclosure policy
|
|
18
|
+
* - Cloud mode routes traffic through lightpanda.io servers
|
|
19
|
+
* - Never use for credential handling or sensitive operations
|
|
20
|
+
*
|
|
21
|
+
* @see https://lightpanda.io/
|
|
22
|
+
* @see https://github.com/lightpanda-io/browser
|
|
23
|
+
* @since 18.20.0
|
|
24
|
+
*/
|
|
25
|
+
import { chromium, type Browser } from "playwright";
|
|
26
|
+
/**
|
|
27
|
+
* Lightpanda connection configuration
|
|
28
|
+
*/
|
|
29
|
+
export interface LightpandaConfig {
|
|
30
|
+
/** WebSocket endpoint (e.g., ws://127.0.0.1:9222, wss://cloud.lightpanda.io/ws) */
|
|
31
|
+
endpoint?: string;
|
|
32
|
+
/** API token for cloud connections */
|
|
33
|
+
token?: string;
|
|
34
|
+
/** Connection timeout in ms (default: 30000) */
|
|
35
|
+
timeout?: number;
|
|
36
|
+
/** Explicitly opt-in to Lightpanda (required for use) */
|
|
37
|
+
explicitOptIn?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Lightpanda connection result
|
|
41
|
+
*/
|
|
42
|
+
export interface LightpandaConnectionResult {
|
|
43
|
+
success: boolean;
|
|
44
|
+
browser?: Browser;
|
|
45
|
+
endpoint?: string;
|
|
46
|
+
error?: string;
|
|
47
|
+
isCloud: boolean;
|
|
48
|
+
/** Security warning if using cloud mode */
|
|
49
|
+
securityWarning?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Operations that should NEVER use Lightpanda due to security concerns
|
|
53
|
+
*/
|
|
54
|
+
export type SensitiveOperation = "auth" | "login" | "credential" | "payment" | "checkout" | "password" | "2fa" | "mfa" | "oauth";
|
|
55
|
+
/**
|
|
56
|
+
* Default local endpoint for Lightpanda
|
|
57
|
+
*/
|
|
58
|
+
export declare const LIGHTPANDA_LOCAL_ENDPOINT = "ws://127.0.0.1:9222";
|
|
59
|
+
/**
|
|
60
|
+
* Cloud endpoint template
|
|
61
|
+
*/
|
|
62
|
+
export declare const LIGHTPANDA_CLOUD_ENDPOINT = "wss://euwest.cloud.lightpanda.io/ws";
|
|
63
|
+
/**
|
|
64
|
+
* Get Lightpanda configuration from environment variables
|
|
65
|
+
*/
|
|
66
|
+
export declare function getLightpandaConfig(): LightpandaConfig;
|
|
67
|
+
/**
|
|
68
|
+
* Check if Lightpanda is configured (env vars set)
|
|
69
|
+
*/
|
|
70
|
+
export declare function isLightpandaConfigured(): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Check if an operation is sensitive and should never use Lightpanda
|
|
73
|
+
*/
|
|
74
|
+
export declare function isSensitiveOperation(operation?: string): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Check if Lightpanda should be used for the current operation
|
|
77
|
+
*
|
|
78
|
+
* SECURITY: Lightpanda is OPT-IN ONLY. It will NOT be used automatically
|
|
79
|
+
* even if configured. The caller must explicitly set explicitOptIn: true.
|
|
80
|
+
*
|
|
81
|
+
* Lightpanda is suitable for:
|
|
82
|
+
* - Agent-ready audits (public page analysis)
|
|
83
|
+
* - Empathy audits (accessibility testing)
|
|
84
|
+
* - Web scraping of public content
|
|
85
|
+
* - Performance-critical batch operations
|
|
86
|
+
*
|
|
87
|
+
* Lightpanda is NOT suitable for:
|
|
88
|
+
* - Any authentication flows
|
|
89
|
+
* - Credential handling
|
|
90
|
+
* - Payment/checkout flows
|
|
91
|
+
* - Visual regression testing
|
|
92
|
+
* - Cross-browser testing
|
|
93
|
+
*/
|
|
94
|
+
export declare function shouldUseLightpanda(options: {
|
|
95
|
+
headless?: boolean;
|
|
96
|
+
requiresVisualAccuracy?: boolean;
|
|
97
|
+
browserType?: string;
|
|
98
|
+
/** Must be true to enable Lightpanda */
|
|
99
|
+
explicitOptIn?: boolean;
|
|
100
|
+
/** Operation name - checked against sensitive patterns */
|
|
101
|
+
operation?: string;
|
|
102
|
+
}): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Build the Lightpanda WebSocket URL
|
|
105
|
+
*/
|
|
106
|
+
export declare function buildLightpandaUrl(config: LightpandaConfig): string;
|
|
107
|
+
/**
|
|
108
|
+
* Check if a Lightpanda server is available at the given endpoint
|
|
109
|
+
*
|
|
110
|
+
* Uses Playwright's connectOverCDP with a short timeout to verify connectivity.
|
|
111
|
+
*/
|
|
112
|
+
export declare function checkLightpandaAvailability(endpoint?: string, timeout?: number): Promise<boolean>;
|
|
113
|
+
/**
|
|
114
|
+
* Connect to Lightpanda via CDP
|
|
115
|
+
*
|
|
116
|
+
* Lightpanda exposes a Chrome DevTools Protocol (CDP) interface,
|
|
117
|
+
* which Playwright can connect to using chromium.connectOverCDP().
|
|
118
|
+
*
|
|
119
|
+
* ⚠️ SECURITY: Cloud connections route traffic through lightpanda.io.
|
|
120
|
+
* Never use for sensitive operations.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* // Local Lightpanda instance (recommended)
|
|
125
|
+
* const result = await connectToLightpanda({ endpoint: "ws://127.0.0.1:9222" });
|
|
126
|
+
*
|
|
127
|
+
* // Lightpanda Cloud (⚠️ traffic visible to lightpanda.io)
|
|
128
|
+
* const result = await connectToLightpanda({ token: "your-api-token" });
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
export declare function connectToLightpanda(config?: LightpandaConfig): Promise<LightpandaConnectionResult>;
|
|
132
|
+
/**
|
|
133
|
+
* Launch a browser with Lightpanda (OPT-IN ONLY)
|
|
134
|
+
*
|
|
135
|
+
* ⚠️ SECURITY: Lightpanda is NOT used automatically. You must explicitly
|
|
136
|
+
* set explicitOptIn: true to use it. This is a security measure because:
|
|
137
|
+
* - Lightpanda is beta software with no security audit
|
|
138
|
+
* - Cloud mode exposes traffic to third party
|
|
139
|
+
* - It should never be used for sensitive operations
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* // Explicit opt-in required
|
|
144
|
+
* const { browser, isLightpanda } = await launchWithLightpandaFallback({
|
|
145
|
+
* headless: true,
|
|
146
|
+
* explicitOptIn: true, // Required!
|
|
147
|
+
* operation: "agent-ready-audit", // Checked against sensitive patterns
|
|
148
|
+
* });
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
export declare function launchWithLightpandaFallback(options: {
|
|
152
|
+
headless?: boolean;
|
|
153
|
+
requiresVisualAccuracy?: boolean;
|
|
154
|
+
browserType?: "chromium" | "firefox" | "webkit";
|
|
155
|
+
launchOptions?: Parameters<typeof chromium.launch>[0];
|
|
156
|
+
/** Must be true to enable Lightpanda - OPT-IN ONLY */
|
|
157
|
+
explicitOptIn?: boolean;
|
|
158
|
+
/** Operation name - sensitive operations are blocked */
|
|
159
|
+
operation?: string;
|
|
160
|
+
}): Promise<{
|
|
161
|
+
browser: Browser;
|
|
162
|
+
isLightpanda: boolean;
|
|
163
|
+
securityWarning?: string;
|
|
164
|
+
}>;
|
|
165
|
+
/**
|
|
166
|
+
* Get Lightpanda status information
|
|
167
|
+
*/
|
|
168
|
+
export declare function getLightpandaStatus(): Promise<{
|
|
169
|
+
configured: boolean;
|
|
170
|
+
available: boolean;
|
|
171
|
+
endpoint: string;
|
|
172
|
+
isCloud: boolean;
|
|
173
|
+
error?: string;
|
|
174
|
+
securityWarning?: string;
|
|
175
|
+
}>;
|
|
176
|
+
/**
|
|
177
|
+
* Lightpanda setup instructions with security warnings
|
|
178
|
+
*/
|
|
179
|
+
export declare const LIGHTPANDA_SETUP_GUIDE = "\n\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557\n\u2551 Lightpanda Setup - High-Performance Headless Browser \u2551\n\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\n\nLightpanda is 11x faster and uses 9x less memory than Chrome headless.\nIt's ideal for AI agents, web scraping, and automated testing.\n\n\u2501\u2501\u2501 \u26A0\uFE0F SECURITY NOTICE \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\nLightpanda is BETA software. Before using, understand:\n\n \uD83D\uDD34 NO SECURITY AUDIT - No formal security review or SECURITY.md\n \uD83D\uDD34 BETA STATUS - Crashes and bugs are expected\n \uD83D\uDD34 CLOUD EXPOSURE - Cloud mode routes traffic through lightpanda.io\n \uD83D\uDD34 OPT-IN ONLY - Requires explicit --lightpanda flag\n\nNEVER use Lightpanda for:\n \u2717 Authentication or login flows\n \u2717 Credential or password handling\n \u2717 Payment or checkout processes\n \u2717 Any sensitive data operations\n\n\u2501\u2501\u2501 Option 1: Local Installation (Recommended) \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\nDocker (isolates Lightpanda from your system):\n docker run -d --name lightpanda -p 9222:9222 lightpanda/browser:nightly\n\nBinary (Linux/macOS):\n curl -LO https://github.com/lightpanda-io/browser/releases/latest/download/lightpanda\n chmod +x lightpanda\n ./lightpanda serve --host 127.0.0.1 --port 9222\n\nThen set environment variable:\n export LIGHTPANDA_ENDPOINT=ws://127.0.0.1:9222\n\n\u2501\u2501\u2501 Option 2: Lightpanda Cloud (\u26A0\uFE0F Third-Party Data Exposure) \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\nWARNING: Cloud mode sends ALL browser traffic through lightpanda.io servers.\nThey can see: URLs, page content, cookies, form submissions.\n\nOnly use for PUBLIC content you don't mind sharing.\n\n1. Sign up at https://lightpanda.io/\n2. Get your API token from the dashboard\n3. Set environment variable:\n export LIGHTPANDA_TOKEN=your-api-token\n\n\u2501\u2501\u2501 Usage (OPT-IN REQUIRED) \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\nLightpanda is NOT used automatically. You must explicitly opt-in:\n\n # Check status\n npx cbrowser lightpanda-status\n\n # Take screenshot with Lightpanda (--lightpanda flag required)\n npx cbrowser screenshot https://example.com --lightpanda\n\n # Run audit with Lightpanda\n npx cbrowser agent-ready-audit https://example.com --lightpanda\n\n\u2501\u2501\u2501 When to Use Lightpanda \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\n\u2705 Good for (public, non-sensitive):\n \u2022 Agent-ready audits on public sites\n \u2022 Empathy audits (accessibility testing)\n \u2022 Web scraping public content\n \u2022 Performance benchmarking\n \u2022 Batch operations on public pages\n\n\u274C Never use for:\n \u2022 Visual regression testing (different rendering)\n \u2022 Cross-browser testing (Chromium only)\n \u2022 Authentication flows\n \u2022 Any operation with credentials\n \u2022 Payment or checkout testing\n\n\u2501\u2501\u2501 More Information \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\nGitHub: https://github.com/lightpanda-io/browser\nDocumentation: https://lightpanda.io/docs\nCBrowser Integration: https://cbrowser.ai/docs/lightpanda\n";
|
|
180
|
+
/**
|
|
181
|
+
* Security warning constant for display
|
|
182
|
+
*/
|
|
183
|
+
export declare const LIGHTPANDA_SECURITY_WARNING: string;
|
|
184
|
+
//# sourceMappingURL=lightpanda.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lightpanda.d.ts","sourceRoot":"","sources":["../src/lightpanda.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,QAAQ,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mFAAmF;IACnF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,2CAA2C;IAC3C,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN,OAAO,GACP,YAAY,GACZ,SAAS,GACT,UAAU,GACV,UAAU,GACV,KAAK,GACL,KAAK,GACL,OAAO,CAAC;AAEZ;;GAEG;AACH,eAAO,MAAM,yBAAyB,wBAAwB,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,yBAAyB,wCAAwC,CAAC;AAE/E;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,gBAAgB,CAOtD;AAED;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AC;IAAC,YAAY,EAAE,OAAO,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAgDjF;AAED;;GAEG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC;IACnD,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC,CAsCD;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,+yKAkFlC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,QAUhC,CAAC"}
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CBrowser - Cognitive Browser Automation
|
|
3
|
+
* Copyright 2026 Alexandria Eden alexandria.shai.eden@gmail.com
|
|
4
|
+
* Learn more at https://cbrowser.ai - MIT License
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Lightpanda Integration
|
|
8
|
+
*
|
|
9
|
+
* Lightpanda is a high-performance headless browser written in Zig.
|
|
10
|
+
* It's 11x faster and uses 9x less memory than Chrome headless.
|
|
11
|
+
*
|
|
12
|
+
* This module provides CDP-based integration with Playwright, allowing
|
|
13
|
+
* CBrowser to use Lightpanda as an alternative browser backend.
|
|
14
|
+
*
|
|
15
|
+
* ⚠️ SECURITY NOTICE:
|
|
16
|
+
* - Lightpanda is BETA software with no formal security audit
|
|
17
|
+
* - No SECURITY.md or vulnerability disclosure policy
|
|
18
|
+
* - Cloud mode routes traffic through lightpanda.io servers
|
|
19
|
+
* - Never use for credential handling or sensitive operations
|
|
20
|
+
*
|
|
21
|
+
* @see https://lightpanda.io/
|
|
22
|
+
* @see https://github.com/lightpanda-io/browser
|
|
23
|
+
* @since 18.20.0
|
|
24
|
+
*/
|
|
25
|
+
import { chromium } from "playwright";
|
|
26
|
+
/**
|
|
27
|
+
* Default local endpoint for Lightpanda
|
|
28
|
+
*/
|
|
29
|
+
export const LIGHTPANDA_LOCAL_ENDPOINT = "ws://127.0.0.1:9222";
|
|
30
|
+
/**
|
|
31
|
+
* Cloud endpoint template
|
|
32
|
+
*/
|
|
33
|
+
export const LIGHTPANDA_CLOUD_ENDPOINT = "wss://euwest.cloud.lightpanda.io/ws";
|
|
34
|
+
/**
|
|
35
|
+
* Get Lightpanda configuration from environment variables
|
|
36
|
+
*/
|
|
37
|
+
export function getLightpandaConfig() {
|
|
38
|
+
return {
|
|
39
|
+
endpoint: process.env.LIGHTPANDA_ENDPOINT,
|
|
40
|
+
token: process.env.LIGHTPANDA_TOKEN,
|
|
41
|
+
timeout: parseInt(process.env.LIGHTPANDA_TIMEOUT || "30000", 10) || 30000,
|
|
42
|
+
explicitOptIn: false, // Must be explicitly set
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Check if Lightpanda is configured (env vars set)
|
|
47
|
+
*/
|
|
48
|
+
export function isLightpandaConfigured() {
|
|
49
|
+
const config = getLightpandaConfig();
|
|
50
|
+
return !!(config.endpoint || config.token);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Check if an operation is sensitive and should never use Lightpanda
|
|
54
|
+
*/
|
|
55
|
+
export function isSensitiveOperation(operation) {
|
|
56
|
+
if (!operation)
|
|
57
|
+
return false;
|
|
58
|
+
const lower = operation.toLowerCase();
|
|
59
|
+
const sensitivePatterns = [
|
|
60
|
+
"auth",
|
|
61
|
+
"login",
|
|
62
|
+
"credential",
|
|
63
|
+
"payment",
|
|
64
|
+
"checkout",
|
|
65
|
+
"password",
|
|
66
|
+
"2fa",
|
|
67
|
+
"mfa",
|
|
68
|
+
"oauth",
|
|
69
|
+
];
|
|
70
|
+
return sensitivePatterns.some((pattern) => lower.includes(pattern));
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Check if Lightpanda should be used for the current operation
|
|
74
|
+
*
|
|
75
|
+
* SECURITY: Lightpanda is OPT-IN ONLY. It will NOT be used automatically
|
|
76
|
+
* even if configured. The caller must explicitly set explicitOptIn: true.
|
|
77
|
+
*
|
|
78
|
+
* Lightpanda is suitable for:
|
|
79
|
+
* - Agent-ready audits (public page analysis)
|
|
80
|
+
* - Empathy audits (accessibility testing)
|
|
81
|
+
* - Web scraping of public content
|
|
82
|
+
* - Performance-critical batch operations
|
|
83
|
+
*
|
|
84
|
+
* Lightpanda is NOT suitable for:
|
|
85
|
+
* - Any authentication flows
|
|
86
|
+
* - Credential handling
|
|
87
|
+
* - Payment/checkout flows
|
|
88
|
+
* - Visual regression testing
|
|
89
|
+
* - Cross-browser testing
|
|
90
|
+
*/
|
|
91
|
+
export function shouldUseLightpanda(options) {
|
|
92
|
+
// SECURITY: Require explicit opt-in
|
|
93
|
+
if (!options.explicitOptIn) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
// SECURITY: Block sensitive operations
|
|
97
|
+
if (isSensitiveOperation(options.operation)) {
|
|
98
|
+
if (process.env.CBROWSER_VERBOSE === "true") {
|
|
99
|
+
console.log(`⚠️ Lightpanda blocked for sensitive operation: ${options.operation}`);
|
|
100
|
+
}
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
// Only use Lightpanda for headless chromium operations
|
|
104
|
+
if (options.browserType && options.browserType !== "chromium") {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
// Don't use for visual accuracy requirements
|
|
108
|
+
if (options.requiresVisualAccuracy) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
// Only use for headless mode
|
|
112
|
+
if (options.headless === false) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
// Check if configured
|
|
116
|
+
return isLightpandaConfigured();
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Build the Lightpanda WebSocket URL
|
|
120
|
+
*/
|
|
121
|
+
export function buildLightpandaUrl(config) {
|
|
122
|
+
// If explicit endpoint provided, use it
|
|
123
|
+
if (config.endpoint) {
|
|
124
|
+
let url = config.endpoint;
|
|
125
|
+
// Append token if provided and endpoint doesn't have it
|
|
126
|
+
if (config.token && !url.includes("token=")) {
|
|
127
|
+
const separator = url.includes("?") ? "&" : "?";
|
|
128
|
+
url = `${url}${separator}token=${config.token}`;
|
|
129
|
+
}
|
|
130
|
+
return url;
|
|
131
|
+
}
|
|
132
|
+
// If only token provided, use cloud endpoint
|
|
133
|
+
if (config.token) {
|
|
134
|
+
return `${LIGHTPANDA_CLOUD_ENDPOINT}?token=${config.token}`;
|
|
135
|
+
}
|
|
136
|
+
// Default to local endpoint
|
|
137
|
+
return LIGHTPANDA_LOCAL_ENDPOINT;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Check if a Lightpanda server is available at the given endpoint
|
|
141
|
+
*
|
|
142
|
+
* Uses Playwright's connectOverCDP with a short timeout to verify connectivity.
|
|
143
|
+
*/
|
|
144
|
+
export async function checkLightpandaAvailability(endpoint = LIGHTPANDA_LOCAL_ENDPOINT, timeout = 5000) {
|
|
145
|
+
try {
|
|
146
|
+
const browser = await chromium.connectOverCDP(endpoint, { timeout });
|
|
147
|
+
await browser.close();
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Get security warning for cloud mode
|
|
156
|
+
*/
|
|
157
|
+
function getCloudSecurityWarning() {
|
|
158
|
+
return `
|
|
159
|
+
⚠️ CLOUD MODE SECURITY WARNING:
|
|
160
|
+
Your browser traffic will be routed through lightpanda.io servers.
|
|
161
|
+
They can see: URLs visited, page content, cookies, and form data.
|
|
162
|
+
|
|
163
|
+
DO NOT use cloud mode for:
|
|
164
|
+
• Authentication flows
|
|
165
|
+
• Handling credentials or passwords
|
|
166
|
+
• Payment or checkout processes
|
|
167
|
+
• Any sensitive data
|
|
168
|
+
|
|
169
|
+
For sensitive operations, use local Lightpanda or Playwright Chromium.
|
|
170
|
+
`.trim();
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Connect to Lightpanda via CDP
|
|
174
|
+
*
|
|
175
|
+
* Lightpanda exposes a Chrome DevTools Protocol (CDP) interface,
|
|
176
|
+
* which Playwright can connect to using chromium.connectOverCDP().
|
|
177
|
+
*
|
|
178
|
+
* ⚠️ SECURITY: Cloud connections route traffic through lightpanda.io.
|
|
179
|
+
* Never use for sensitive operations.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* // Local Lightpanda instance (recommended)
|
|
184
|
+
* const result = await connectToLightpanda({ endpoint: "ws://127.0.0.1:9222" });
|
|
185
|
+
*
|
|
186
|
+
* // Lightpanda Cloud (⚠️ traffic visible to lightpanda.io)
|
|
187
|
+
* const result = await connectToLightpanda({ token: "your-api-token" });
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
export async function connectToLightpanda(config) {
|
|
191
|
+
const cfg = config || getLightpandaConfig();
|
|
192
|
+
const endpoint = buildLightpandaUrl(cfg);
|
|
193
|
+
const isCloud = endpoint.includes("cloud.lightpanda.io");
|
|
194
|
+
// Add security warning for cloud mode
|
|
195
|
+
const securityWarning = isCloud ? getCloudSecurityWarning() : undefined;
|
|
196
|
+
if (isCloud && process.env.CBROWSER_VERBOSE === "true") {
|
|
197
|
+
console.log(securityWarning);
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
// Use Playwright's CDP connection
|
|
201
|
+
const browser = await chromium.connectOverCDP(endpoint, {
|
|
202
|
+
timeout: cfg.timeout || 30000,
|
|
203
|
+
});
|
|
204
|
+
console.log(`🐼 Connected to Lightpanda ${isCloud ? "(Cloud ⚠️)" : "(Local)"}`);
|
|
205
|
+
return {
|
|
206
|
+
success: true,
|
|
207
|
+
browser,
|
|
208
|
+
endpoint,
|
|
209
|
+
isCloud,
|
|
210
|
+
securityWarning,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
215
|
+
return {
|
|
216
|
+
success: false,
|
|
217
|
+
error: `Failed to connect to Lightpanda at ${endpoint}: ${message}`,
|
|
218
|
+
endpoint,
|
|
219
|
+
isCloud,
|
|
220
|
+
securityWarning,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Launch a browser with Lightpanda (OPT-IN ONLY)
|
|
226
|
+
*
|
|
227
|
+
* ⚠️ SECURITY: Lightpanda is NOT used automatically. You must explicitly
|
|
228
|
+
* set explicitOptIn: true to use it. This is a security measure because:
|
|
229
|
+
* - Lightpanda is beta software with no security audit
|
|
230
|
+
* - Cloud mode exposes traffic to third party
|
|
231
|
+
* - It should never be used for sensitive operations
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* // Explicit opt-in required
|
|
236
|
+
* const { browser, isLightpanda } = await launchWithLightpandaFallback({
|
|
237
|
+
* headless: true,
|
|
238
|
+
* explicitOptIn: true, // Required!
|
|
239
|
+
* operation: "agent-ready-audit", // Checked against sensitive patterns
|
|
240
|
+
* });
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
export async function launchWithLightpandaFallback(options) {
|
|
244
|
+
const { headless = true, requiresVisualAccuracy = false, browserType = "chromium", launchOptions = {}, explicitOptIn = false, operation, } = options;
|
|
245
|
+
// Check if we should try Lightpanda (requires explicit opt-in)
|
|
246
|
+
if (shouldUseLightpanda({ headless, requiresVisualAccuracy, browserType, explicitOptIn, operation })) {
|
|
247
|
+
const result = await connectToLightpanda();
|
|
248
|
+
if (result.success && result.browser) {
|
|
249
|
+
return {
|
|
250
|
+
browser: result.browser,
|
|
251
|
+
isLightpanda: true,
|
|
252
|
+
securityWarning: result.securityWarning,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
// Log fallback reason if verbose
|
|
256
|
+
if (process.env.CBROWSER_VERBOSE === "true") {
|
|
257
|
+
console.log(`⚠️ Lightpanda unavailable: ${result.error}`);
|
|
258
|
+
console.log(" Falling back to Playwright Chromium...");
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
// Fall back to Playwright
|
|
262
|
+
const { chromium: playwrightChromium, firefox, webkit } = await import("playwright");
|
|
263
|
+
const launchers = {
|
|
264
|
+
chromium: playwrightChromium,
|
|
265
|
+
firefox,
|
|
266
|
+
webkit,
|
|
267
|
+
};
|
|
268
|
+
const launcher = launchers[browserType] || playwrightChromium;
|
|
269
|
+
const browser = await launcher.launch({
|
|
270
|
+
headless,
|
|
271
|
+
...launchOptions,
|
|
272
|
+
});
|
|
273
|
+
return {
|
|
274
|
+
browser,
|
|
275
|
+
isLightpanda: false,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Get Lightpanda status information
|
|
280
|
+
*/
|
|
281
|
+
export async function getLightpandaStatus() {
|
|
282
|
+
const config = getLightpandaConfig();
|
|
283
|
+
const configured = isLightpandaConfigured();
|
|
284
|
+
const endpoint = buildLightpandaUrl(config);
|
|
285
|
+
const isCloud = endpoint.includes("cloud.lightpanda.io");
|
|
286
|
+
const securityWarning = isCloud ? getCloudSecurityWarning() : undefined;
|
|
287
|
+
if (!configured) {
|
|
288
|
+
return {
|
|
289
|
+
configured: false,
|
|
290
|
+
available: false,
|
|
291
|
+
endpoint: LIGHTPANDA_LOCAL_ENDPOINT,
|
|
292
|
+
isCloud: false,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
// Try to connect
|
|
296
|
+
const result = await connectToLightpanda(config);
|
|
297
|
+
if (result.success && result.browser) {
|
|
298
|
+
await result.browser.close();
|
|
299
|
+
return {
|
|
300
|
+
configured: true,
|
|
301
|
+
available: true,
|
|
302
|
+
endpoint,
|
|
303
|
+
isCloud,
|
|
304
|
+
securityWarning,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
configured: true,
|
|
309
|
+
available: false,
|
|
310
|
+
endpoint,
|
|
311
|
+
isCloud,
|
|
312
|
+
error: result.error,
|
|
313
|
+
securityWarning,
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Lightpanda setup instructions with security warnings
|
|
318
|
+
*/
|
|
319
|
+
export const LIGHTPANDA_SETUP_GUIDE = `
|
|
320
|
+
╔══════════════════════════════════════════════════════════════════════════════╗
|
|
321
|
+
║ Lightpanda Setup - High-Performance Headless Browser ║
|
|
322
|
+
╚══════════════════════════════════════════════════════════════════════════════╝
|
|
323
|
+
|
|
324
|
+
Lightpanda is 11x faster and uses 9x less memory than Chrome headless.
|
|
325
|
+
It's ideal for AI agents, web scraping, and automated testing.
|
|
326
|
+
|
|
327
|
+
━━━ ⚠️ SECURITY NOTICE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
328
|
+
|
|
329
|
+
Lightpanda is BETA software. Before using, understand:
|
|
330
|
+
|
|
331
|
+
🔴 NO SECURITY AUDIT - No formal security review or SECURITY.md
|
|
332
|
+
🔴 BETA STATUS - Crashes and bugs are expected
|
|
333
|
+
🔴 CLOUD EXPOSURE - Cloud mode routes traffic through lightpanda.io
|
|
334
|
+
🔴 OPT-IN ONLY - Requires explicit --lightpanda flag
|
|
335
|
+
|
|
336
|
+
NEVER use Lightpanda for:
|
|
337
|
+
✗ Authentication or login flows
|
|
338
|
+
✗ Credential or password handling
|
|
339
|
+
✗ Payment or checkout processes
|
|
340
|
+
✗ Any sensitive data operations
|
|
341
|
+
|
|
342
|
+
━━━ Option 1: Local Installation (Recommended) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
343
|
+
|
|
344
|
+
Docker (isolates Lightpanda from your system):
|
|
345
|
+
docker run -d --name lightpanda -p 9222:9222 lightpanda/browser:nightly
|
|
346
|
+
|
|
347
|
+
Binary (Linux/macOS):
|
|
348
|
+
curl -LO https://github.com/lightpanda-io/browser/releases/latest/download/lightpanda
|
|
349
|
+
chmod +x lightpanda
|
|
350
|
+
./lightpanda serve --host 127.0.0.1 --port 9222
|
|
351
|
+
|
|
352
|
+
Then set environment variable:
|
|
353
|
+
export LIGHTPANDA_ENDPOINT=ws://127.0.0.1:9222
|
|
354
|
+
|
|
355
|
+
━━━ Option 2: Lightpanda Cloud (⚠️ Third-Party Data Exposure) ━━━━━━━━━━━━━━━━
|
|
356
|
+
|
|
357
|
+
WARNING: Cloud mode sends ALL browser traffic through lightpanda.io servers.
|
|
358
|
+
They can see: URLs, page content, cookies, form submissions.
|
|
359
|
+
|
|
360
|
+
Only use for PUBLIC content you don't mind sharing.
|
|
361
|
+
|
|
362
|
+
1. Sign up at https://lightpanda.io/
|
|
363
|
+
2. Get your API token from the dashboard
|
|
364
|
+
3. Set environment variable:
|
|
365
|
+
export LIGHTPANDA_TOKEN=your-api-token
|
|
366
|
+
|
|
367
|
+
━━━ Usage (OPT-IN REQUIRED) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
368
|
+
|
|
369
|
+
Lightpanda is NOT used automatically. You must explicitly opt-in:
|
|
370
|
+
|
|
371
|
+
# Check status
|
|
372
|
+
npx cbrowser lightpanda-status
|
|
373
|
+
|
|
374
|
+
# Take screenshot with Lightpanda (--lightpanda flag required)
|
|
375
|
+
npx cbrowser screenshot https://example.com --lightpanda
|
|
376
|
+
|
|
377
|
+
# Run audit with Lightpanda
|
|
378
|
+
npx cbrowser agent-ready-audit https://example.com --lightpanda
|
|
379
|
+
|
|
380
|
+
━━━ When to Use Lightpanda ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
381
|
+
|
|
382
|
+
✅ Good for (public, non-sensitive):
|
|
383
|
+
• Agent-ready audits on public sites
|
|
384
|
+
• Empathy audits (accessibility testing)
|
|
385
|
+
• Web scraping public content
|
|
386
|
+
• Performance benchmarking
|
|
387
|
+
• Batch operations on public pages
|
|
388
|
+
|
|
389
|
+
❌ Never use for:
|
|
390
|
+
• Visual regression testing (different rendering)
|
|
391
|
+
• Cross-browser testing (Chromium only)
|
|
392
|
+
• Authentication flows
|
|
393
|
+
• Any operation with credentials
|
|
394
|
+
• Payment or checkout testing
|
|
395
|
+
|
|
396
|
+
━━━ More Information ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
397
|
+
|
|
398
|
+
GitHub: https://github.com/lightpanda-io/browser
|
|
399
|
+
Documentation: https://lightpanda.io/docs
|
|
400
|
+
CBrowser Integration: https://cbrowser.ai/docs/lightpanda
|
|
401
|
+
`;
|
|
402
|
+
/**
|
|
403
|
+
* Security warning constant for display
|
|
404
|
+
*/
|
|
405
|
+
export const LIGHTPANDA_SECURITY_WARNING = `
|
|
406
|
+
⚠️ LIGHTPANDA SECURITY NOTICE
|
|
407
|
+
|
|
408
|
+
Lightpanda is beta software with no formal security audit.
|
|
409
|
+
• No SECURITY.md or vulnerability disclosure process
|
|
410
|
+
• No third-party code audit documented
|
|
411
|
+
• Cloud mode exposes traffic to lightpanda.io servers
|
|
412
|
+
|
|
413
|
+
Use only for public, non-sensitive operations.
|
|
414
|
+
Never use for authentication, credentials, or payments.
|
|
415
|
+
`.trim();
|
|
416
|
+
//# sourceMappingURL=lightpanda.js.map
|