device-passport 1.0.0 → 1.2.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/CHANGELOG.md +33 -0
- package/README.md +110 -2
- package/assets/ego-profile-manager.png +0 -0
- package/dist/adapters/index.cjs +19 -0
- package/dist/adapters/index.d.cts +66 -0
- package/dist/adapters/index.d.mts +66 -0
- package/dist/adapters/index.d.ts +66 -0
- package/dist/adapters/index.mjs +3 -0
- package/dist/ego/index.cjs +22 -0
- package/dist/ego/index.d.cts +5 -0
- package/dist/ego/index.d.mts +5 -0
- package/dist/ego/index.d.ts +5 -0
- package/dist/ego/index.mjs +8 -0
- package/dist/evaluator/index.cjs +140 -0
- package/dist/evaluator/index.d.cts +204 -0
- package/dist/evaluator/index.d.mts +204 -0
- package/dist/evaluator/index.d.ts +204 -0
- package/dist/evaluator/index.mjs +119 -0
- package/dist/geo/index.cjs +50 -0
- package/dist/geo/index.d.cts +213 -0
- package/dist/geo/index.d.mts +213 -0
- package/dist/geo/index.d.ts +213 -0
- package/dist/geo/index.mjs +18 -0
- package/dist/index.cjs +110 -3940
- package/dist/index.d.cts +45 -1091
- package/dist/index.d.mts +45 -1091
- package/dist/index.d.ts +45 -1091
- package/dist/index.mjs +11 -3849
- package/dist/shared/device-passport.BGfRcQNh.mjs +565 -0
- package/dist/shared/device-passport.BKtmLzPt.cjs +1266 -0
- package/dist/shared/device-passport.BPQj0qdT.mjs +1238 -0
- package/dist/shared/device-passport.CDS7xrj8.d.ts +469 -0
- package/dist/shared/device-passport.C_F1vBE8.d.cts +79 -0
- package/dist/shared/device-passport.C_F1vBE8.d.mts +79 -0
- package/dist/shared/device-passport.C_F1vBE8.d.ts +79 -0
- package/dist/shared/device-passport.CfLes-lq.d.cts +469 -0
- package/dist/shared/device-passport.Cjxlv8xI.cjs +245 -0
- package/dist/shared/device-passport.CsOWqPIr.d.cts +77 -0
- package/dist/shared/device-passport.CyQtcZeD.mjs +237 -0
- package/dist/shared/device-passport.D7pEnyp2.d.ts +77 -0
- package/dist/shared/device-passport.D9xW6R0B.cjs +1571 -0
- package/dist/shared/device-passport.DirQmSd4.d.cts +47 -0
- package/dist/shared/device-passport.DirQmSd4.d.mts +47 -0
- package/dist/shared/device-passport.DirQmSd4.d.ts +47 -0
- package/dist/shared/device-passport.EK4RX7Xd.cjs +584 -0
- package/dist/shared/device-passport.ZBspe4ZW.d.mts +77 -0
- package/dist/shared/device-passport.dVEqzSEb.d.mts +469 -0
- package/dist/shared/device-passport.gNo82fQ5.mjs +1537 -0
- package/dist/shared/device-passport.kekU28UM.mjs +705 -0
- package/dist/shared/device-passport.qL4tjwc0.cjs +718 -0
- package/dist/storage/index.cjs +10 -0
- package/dist/storage/index.d.cts +97 -0
- package/dist/storage/index.d.mts +97 -0
- package/dist/storage/index.d.ts +97 -0
- package/dist/storage/index.mjs +3 -0
- package/dist/types/index.cjs +2 -0
- package/dist/types/index.d.cts +397 -0
- package/dist/types/index.d.mts +397 -0
- package/dist/types/index.d.ts +397 -0
- package/dist/types/index.mjs +1 -0
- package/package.json +32 -2
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
import { DevicePassport, BrowserProfile, OperatingSystemProfile, HardwareProfile, UserAgentClientHints, DevicePassportContext, PassportEvaluation, PassportGeneratorOptions, SupportedPlatform, SupportedBrowserName, EgoAccountProfile, EgoLiteBridge, EgoProfile, EgoProfileReadiness, EgoProxyBinding, EgoSessionPlan, EgoProxyDeclaration } from '../types/index.mjs';
|
|
2
|
+
import { P as PlaywrightContextOptions, a as PuppeteerEmulationOptions } from './device-passport.ZBspe4ZW.mjs';
|
|
3
|
+
import { S as StorageAdapter } from './device-passport.DirQmSd4.mjs';
|
|
4
|
+
import { L as LocaleProfile } from './device-passport.C_F1vBE8.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* DevicePassportInstance encapsulates a single concrete, zero-contradiction digital identity persona.
|
|
8
|
+
*
|
|
9
|
+
* Provides runtime adapters for:
|
|
10
|
+
* 1. Lightweight HTTP mode (Fetch, Axios, Undici, Got, cURL) with strict canonical header ordering.
|
|
11
|
+
* 2. Heavyweight browser automation (Playwright, Puppeteer, ego-lite) with deep fingerprint masking.
|
|
12
|
+
* 3. Self-evaluating consistency diagnostics based on empirical telemetry models.
|
|
13
|
+
*/
|
|
14
|
+
declare class DevicePassportInstance {
|
|
15
|
+
readonly profile: DevicePassport;
|
|
16
|
+
constructor(profile: DevicePassport);
|
|
17
|
+
/**
|
|
18
|
+
* Factory method to create an instance from a plain DevicePassport object.
|
|
19
|
+
*/
|
|
20
|
+
static from(profile: DevicePassport): DevicePassportInstance;
|
|
21
|
+
get id(): string;
|
|
22
|
+
get seed(): string;
|
|
23
|
+
get createdAt(): string;
|
|
24
|
+
get browser(): BrowserProfile;
|
|
25
|
+
get os(): OperatingSystemProfile;
|
|
26
|
+
get hardware(): HardwareProfile;
|
|
27
|
+
get locale(): LocaleProfile;
|
|
28
|
+
get headers(): Record<string, string>;
|
|
29
|
+
get clientHints(): UserAgentClientHints;
|
|
30
|
+
get context(): DevicePassportContext;
|
|
31
|
+
get userAgent(): string;
|
|
32
|
+
get timezone(): string;
|
|
33
|
+
get playwrightContext(): PlaywrightContextOptions;
|
|
34
|
+
get puppeteerArgs(): PuppeteerEmulationOptions;
|
|
35
|
+
get evaluation(): PassportEvaluation | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Returns HTTP headers formatted in strict canonical browser sequence.
|
|
38
|
+
* Essential for anti-bot evasion against Cloudflare, Akamai, and DataDome.
|
|
39
|
+
*/
|
|
40
|
+
getHeaders(overrides?: Record<string, string>): Record<string, string>;
|
|
41
|
+
/**
|
|
42
|
+
* Returns a higher-order fetch function wrapping standard fetch with this passport's canonical persona.
|
|
43
|
+
*/
|
|
44
|
+
wrapFetch(customFetch?: typeof fetch): typeof fetch;
|
|
45
|
+
/**
|
|
46
|
+
* Alias for wrapFetch.
|
|
47
|
+
*/
|
|
48
|
+
withPassport(customFetch?: typeof fetch): typeof fetch;
|
|
49
|
+
/**
|
|
50
|
+
* Generates a copy-pasteable cURL command with correct browser headers and User-Agent.
|
|
51
|
+
*/
|
|
52
|
+
toCurl(url: string, options?: {
|
|
53
|
+
method?: string;
|
|
54
|
+
data?: any;
|
|
55
|
+
headers?: Record<string, string>;
|
|
56
|
+
}): string;
|
|
57
|
+
/**
|
|
58
|
+
* Generates Playwright BrowserContext options.
|
|
59
|
+
* Usage:
|
|
60
|
+
* ```ts
|
|
61
|
+
* const context = await browser.newContext(passport.getPlaywrightContext());
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
getPlaywrightContext(): PlaywrightContextOptions;
|
|
65
|
+
/**
|
|
66
|
+
* Returns Puppeteer launch args and page emulation parameters.
|
|
67
|
+
*/
|
|
68
|
+
getPuppeteerArgs(): PuppeteerEmulationOptions;
|
|
69
|
+
/**
|
|
70
|
+
* Generates an in-page stealth script to patch runtime JavaScript APIs
|
|
71
|
+
* (navigator.webdriver, hardwareConcurrency, deviceMemory, WebGL, Client Hints).
|
|
72
|
+
*/
|
|
73
|
+
getStealthScript(): string;
|
|
74
|
+
/**
|
|
75
|
+
* Injects stealth scripts and extra HTTP headers into a Playwright BrowserContext.
|
|
76
|
+
*/
|
|
77
|
+
applyToPlaywright(context: any): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Injects stealth scripts and emulation parameters into a Puppeteer Page.
|
|
80
|
+
*/
|
|
81
|
+
applyToPuppeteer(page: any): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Evaluates cross-layer consistency and Shannon entropy.
|
|
84
|
+
* Caches the result on `this.profile.evaluation`.
|
|
85
|
+
*/
|
|
86
|
+
evaluate(forceRecompute?: boolean): PassportEvaluation;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the underlying raw DevicePassport data object.
|
|
89
|
+
*/
|
|
90
|
+
toJSON(): DevicePassport;
|
|
91
|
+
toString(): string;
|
|
92
|
+
}
|
|
93
|
+
interface CreatePassportInputOptions extends PassportGeneratorOptions {
|
|
94
|
+
/** Optional file path or storage adapter to persist this passport deterministically */
|
|
95
|
+
store?: string | StorageAdapter<DevicePassport>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Universal polymorphic factory for creating a DevicePassportInstance.
|
|
99
|
+
*
|
|
100
|
+
* Supports:
|
|
101
|
+
* - One-line string seed: `createPassport('alice', { geo: 'US' })`
|
|
102
|
+
* - Full options object: `createPassport({ seed: 'bot1', store: './passports.json' })`
|
|
103
|
+
* - Existing raw profile: `createPassport(rawProfile)`
|
|
104
|
+
* - Zero-config ephemeral persona: `createPassport()`
|
|
105
|
+
*/
|
|
106
|
+
declare function createPassport(seedOrOptionsOrProfile?: string | CreatePassportInputOptions | DevicePassport, extraOptions?: CreatePassportInputOptions): DevicePassportInstance;
|
|
107
|
+
|
|
108
|
+
interface PassportManagerOptions {
|
|
109
|
+
/**
|
|
110
|
+
* Storage backend for persisting passports:
|
|
111
|
+
* - String path (e.g. './passports.json') -> creates JSONFileStorage automatically.
|
|
112
|
+
* - StorageAdapter instance -> custom pluggable storage (Memory, File, Redis, DB).
|
|
113
|
+
* - Omitted or 'memory' -> uses MemoryStorage.
|
|
114
|
+
*/
|
|
115
|
+
store?: string | StorageAdapter<DevicePassport>;
|
|
116
|
+
/**
|
|
117
|
+
* Default geographic country code for newly generated personas (e.g. 'US', 'GB', 'DE', 'JP').
|
|
118
|
+
* Defaults to 'US'.
|
|
119
|
+
*/
|
|
120
|
+
defaultGeo?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Default operating system preference ('macOS' | 'Windows').
|
|
123
|
+
*/
|
|
124
|
+
defaultOS?: SupportedPlatform;
|
|
125
|
+
/**
|
|
126
|
+
* Default browser preference ('Chrome' | 'Edge').
|
|
127
|
+
*/
|
|
128
|
+
defaultBrowser?: SupportedBrowserName;
|
|
129
|
+
/**
|
|
130
|
+
* Generator function. Defaults to engine's generatePassport.
|
|
131
|
+
*/
|
|
132
|
+
generator?: (options?: PassportGeneratorOptions) => DevicePassport;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* PassportManager manages fleet-scale digital device identities.
|
|
136
|
+
*
|
|
137
|
+
* Guarantees true sticky identity across runs:
|
|
138
|
+
* Calling `getPassport(seed)` with the same seed (e.g. account ID, proxy IP, username)
|
|
139
|
+
* will consistently return the exact same device passport across restarts and cron jobs.
|
|
140
|
+
*/
|
|
141
|
+
declare class PassportManager {
|
|
142
|
+
readonly storage: StorageAdapter<DevicePassport>;
|
|
143
|
+
readonly defaultGeo: string;
|
|
144
|
+
readonly defaultOS?: SupportedPlatform;
|
|
145
|
+
readonly defaultBrowser?: SupportedBrowserName;
|
|
146
|
+
private readonly generator;
|
|
147
|
+
constructor(options?: PassportManagerOptions);
|
|
148
|
+
/**
|
|
149
|
+
* Retrieves an existing sticky passport by seed or deterministically generates
|
|
150
|
+
* and persists a new one if it does not already exist.
|
|
151
|
+
*
|
|
152
|
+
* @param seed Deterministic seed (user ID, account handle, proxy IP, worker slot)
|
|
153
|
+
* @param options Generator options to use if persona needs to be created
|
|
154
|
+
*/
|
|
155
|
+
getPassport(seed: string | number, options?: PassportGeneratorOptions): Promise<DevicePassportInstance>;
|
|
156
|
+
/**
|
|
157
|
+
* Synchronous passport retrieval for environments backed by MemoryStorage or JSONFileStorage.
|
|
158
|
+
*/
|
|
159
|
+
getPassportSync(seed: string | number, options?: PassportGeneratorOptions): DevicePassportInstance;
|
|
160
|
+
/**
|
|
161
|
+
* Forces re-generation and overwrite of a passport for the given seed.
|
|
162
|
+
*/
|
|
163
|
+
renewPassport(seed: string | number, options?: PassportGeneratorOptions): Promise<DevicePassportInstance>;
|
|
164
|
+
/**
|
|
165
|
+
* Check if a passport exists in storage for the given seed.
|
|
166
|
+
*/
|
|
167
|
+
hasPassport(seed: string | number): Promise<boolean>;
|
|
168
|
+
/**
|
|
169
|
+
* Delete a passport from storage.
|
|
170
|
+
*/
|
|
171
|
+
deletePassport(seed: string | number): Promise<boolean>;
|
|
172
|
+
/**
|
|
173
|
+
* Import an existing passport into storage.
|
|
174
|
+
*/
|
|
175
|
+
importPassport(passport: DevicePassport | DevicePassportInstance): Promise<DevicePassportInstance>;
|
|
176
|
+
/**
|
|
177
|
+
* List all stored seeds.
|
|
178
|
+
*/
|
|
179
|
+
listSeeds(): Promise<string[]>;
|
|
180
|
+
/**
|
|
181
|
+
* List all stored passports as DevicePassportInstance objects.
|
|
182
|
+
*/
|
|
183
|
+
listPassports(): Promise<DevicePassportInstance[]>;
|
|
184
|
+
/**
|
|
185
|
+
* Clear all stored passports.
|
|
186
|
+
*/
|
|
187
|
+
clear(): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Return number of stored personas.
|
|
190
|
+
*/
|
|
191
|
+
count(): Promise<number>;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Account profile manager for ego-lite.
|
|
196
|
+
*
|
|
197
|
+
* Maps one account (seed) onto three things that must travel together:
|
|
198
|
+
* 1. a **sticky passport** — same seed ⇒ same persona, forever (via `PassportManager`),
|
|
199
|
+
* 2. an **ego-lite profile binding** (`profileId`) — the browser profile whose
|
|
200
|
+
* cookies and login state persist across task spaces,
|
|
201
|
+
* 3. a **proxy declaration** — recorded, but never applied at the browser layer.
|
|
202
|
+
*
|
|
203
|
+
* The proxy is a declared *gap*, not a feature: ego-lite has no browser-level proxy
|
|
204
|
+
* API, so the profile either has a proxy declared (and the operator must bind it at
|
|
205
|
+
* the system level) or it does not, and the manager reports `missing-proxy` so
|
|
206
|
+
* nobody mistakes "no proxy" for "proxy applied".
|
|
207
|
+
*/
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Options for {@link AccountProfileManager}.
|
|
211
|
+
*/
|
|
212
|
+
interface AccountProfileManagerOptions {
|
|
213
|
+
/**
|
|
214
|
+
* Storage backend for the account profile records (seed → profile binding).
|
|
215
|
+
* - String path → creates a `JSONFileStorage` automatically (atomic writes).
|
|
216
|
+
* - StorageAdapter instance → custom backend.
|
|
217
|
+
* - Omitted → `MemoryStorage`.
|
|
218
|
+
*/
|
|
219
|
+
store?: string | StorageAdapter<EgoAccountProfile>;
|
|
220
|
+
/**
|
|
221
|
+
* Storage backend for the sticky passports (seed → persona).
|
|
222
|
+
*
|
|
223
|
+
* 🔴 Why this is separate from {@link store}:
|
|
224
|
+
* Account records and personas are two different kinds of state with two
|
|
225
|
+
* different lifetimes. Persisting the records but not the personas means a
|
|
226
|
+
* restart regenerates the persona from the default geo — the persona silently
|
|
227
|
+
* changes while its `id` stays the same, so no caller can tell it drifted.
|
|
228
|
+
* Persisting both makes the identity survive a restart for real.
|
|
229
|
+
*
|
|
230
|
+
* - String path → creates a `JSONFileStorage` automatically (atomic writes).
|
|
231
|
+
* - StorageAdapter instance → custom backend.
|
|
232
|
+
* - Omitted → falls back to `passportOptions.store`, then `MemoryStorage`.
|
|
233
|
+
*/
|
|
234
|
+
passportStore?: string | StorageAdapter<DevicePassport>;
|
|
235
|
+
/**
|
|
236
|
+
* The passport manager that owns the sticky identities.
|
|
237
|
+
* When omitted, an internal one is created from {@link passportOptions}.
|
|
238
|
+
*/
|
|
239
|
+
passportManager?: PassportManager;
|
|
240
|
+
/**
|
|
241
|
+
* Options for the internal passport manager. Ignored when
|
|
242
|
+
* {@link passportManager} is supplied.
|
|
243
|
+
*/
|
|
244
|
+
passportOptions?: PassportManagerOptions;
|
|
245
|
+
/**
|
|
246
|
+
* The ego-lite bridge used to list profiles and open task spaces.
|
|
247
|
+
* When omitted, no profile listing is possible and binding is rejected.
|
|
248
|
+
*/
|
|
249
|
+
bridge?: EgoLiteBridge;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Options for binding an account to an ego-lite profile.
|
|
253
|
+
*/
|
|
254
|
+
interface BindProfileOptions {
|
|
255
|
+
/** The ego-lite profile id to bind. Must exist in the ego-lite profile list. */
|
|
256
|
+
profileId: string;
|
|
257
|
+
/**
|
|
258
|
+
* The proxy declaration for this account. Omit to leave the account unbound.
|
|
259
|
+
*/
|
|
260
|
+
proxy?: EgoProxyBinding | null;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Options for creating a session plan.
|
|
264
|
+
*/
|
|
265
|
+
interface CreateSessionPlanOptions {
|
|
266
|
+
/** Task space name. Defaults to a name derived from the seed. */
|
|
267
|
+
taskSpaceName?: string;
|
|
268
|
+
/** Optional CDP session id to attach to every command. */
|
|
269
|
+
sessionId?: string;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Manages ego-lite account profiles: sticky passport + profile binding + proxy declaration.
|
|
273
|
+
*/
|
|
274
|
+
declare class AccountProfileManager {
|
|
275
|
+
/** Persistent store of account profile records. */
|
|
276
|
+
readonly storage: StorageAdapter<EgoAccountProfile>;
|
|
277
|
+
/** The passport manager holding the sticky identities. */
|
|
278
|
+
readonly passportManager: PassportManager;
|
|
279
|
+
/** The ego-lite bridge, when one was injected. */
|
|
280
|
+
readonly bridge?: EgoLiteBridge;
|
|
281
|
+
constructor(options?: AccountProfileManagerOptions);
|
|
282
|
+
/**
|
|
283
|
+
* Lists the ego-lite profiles available for binding.
|
|
284
|
+
*
|
|
285
|
+
* @throws When no bridge was injected — ego-lite has no "create profile" API,
|
|
286
|
+
* so a profile must already exist and be listed before it can be bound.
|
|
287
|
+
*/
|
|
288
|
+
listEgoProfiles(): Promise<EgoProfile[]>;
|
|
289
|
+
/**
|
|
290
|
+
* Returns the stored account profile record for a seed.
|
|
291
|
+
*/
|
|
292
|
+
getProfile(seed: string | number): Promise<EgoAccountProfile | null>;
|
|
293
|
+
/**
|
|
294
|
+
* Returns the readiness of an account profile.
|
|
295
|
+
*
|
|
296
|
+
* `ready` requires both a bound ego-lite profile and a declared proxy.
|
|
297
|
+
*/
|
|
298
|
+
getReadiness(seed: string | number): Promise<EgoProfileReadiness>;
|
|
299
|
+
/**
|
|
300
|
+
* Binds an account to an existing ego-lite profile, and optionally declares its proxy.
|
|
301
|
+
*
|
|
302
|
+
* The proxy is only *recorded* here. ego-lite cannot apply it at the browser layer,
|
|
303
|
+
* so the operator must bind it at the system level before launching a session.
|
|
304
|
+
*
|
|
305
|
+
* @param seed The account seed. Doubles as the sticky passport seed.
|
|
306
|
+
* @param options The profile id to bind and the optional proxy declaration.
|
|
307
|
+
* @param passportOptions Generator options used when the passport is first created.
|
|
308
|
+
*/
|
|
309
|
+
bindProfile(seed: string | number, options: BindProfileOptions, passportOptions?: PassportGeneratorOptions): Promise<EgoAccountProfile>;
|
|
310
|
+
/**
|
|
311
|
+
* Declares (or clears) the proxy binding of an account.
|
|
312
|
+
*
|
|
313
|
+
* Passing `null` removes the declaration; the account then reports `missing-proxy`.
|
|
314
|
+
*/
|
|
315
|
+
setProxy(seed: string | number, proxy: EgoProxyBinding | null): Promise<EgoAccountProfile>;
|
|
316
|
+
/**
|
|
317
|
+
* Returns the sticky passport instance for an account.
|
|
318
|
+
*/
|
|
319
|
+
getPassport(seed: string | number, options?: PassportGeneratorOptions): Promise<DevicePassportInstance>;
|
|
320
|
+
/**
|
|
321
|
+
* Builds the complete launch plan for one account session.
|
|
322
|
+
*
|
|
323
|
+
* The plan carries the CDP command sequence, init scripts, headers, the ego-lite
|
|
324
|
+
* profile id, and an explicit proxy declaration whose `bound` flag reflects whether
|
|
325
|
+
* a proxy is actually declared for the account.
|
|
326
|
+
*
|
|
327
|
+
* @throws When the account has no bound profile.
|
|
328
|
+
*/
|
|
329
|
+
createSessionPlan(seed: string | number, options?: CreateSessionPlanOptions): Promise<EgoSessionPlan>;
|
|
330
|
+
/**
|
|
331
|
+
* Opens an ego-lite task space bound to the account's profile.
|
|
332
|
+
*
|
|
333
|
+
* The task space inherits the profile's cookies and login state; a different
|
|
334
|
+
* profile is fully isolated from it.
|
|
335
|
+
*
|
|
336
|
+
* @returns The task space identifier.
|
|
337
|
+
* @throws When the account has no bound profile or no bridge was injected.
|
|
338
|
+
*/
|
|
339
|
+
openTaskSpace(seed: string | number, taskSpaceName?: string): Promise<string>;
|
|
340
|
+
/**
|
|
341
|
+
* Lists every stored account seed.
|
|
342
|
+
*/
|
|
343
|
+
listSeeds(): Promise<string[]>;
|
|
344
|
+
/**
|
|
345
|
+
* Removes an account profile record.
|
|
346
|
+
*/
|
|
347
|
+
removeProfile(seed: string | number): Promise<boolean>;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Session plan builder for ego-lite.
|
|
352
|
+
*
|
|
353
|
+
* Turns one account profile into everything needed to launch a session:
|
|
354
|
+
* the ordered CDP command sequence, the init scripts, the canonical headers,
|
|
355
|
+
* the ego-lite profile id, and an explicit proxy declaration.
|
|
356
|
+
*
|
|
357
|
+
* The proxy declaration is the important part: ego-lite cannot set a proxy at the
|
|
358
|
+
* browser layer, so the plan states plainly whether a proxy is declared and that
|
|
359
|
+
* it must be arranged outside the browser.
|
|
360
|
+
*/
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* How the proxy is resolved for every ego-lite session.
|
|
364
|
+
*
|
|
365
|
+
* ego-lite exposes no proxy API (no `Browser.setProxySettings` in CDP, no proxy
|
|
366
|
+
* setter among its native bindings), and `--proxy-server` is a browser *launch*
|
|
367
|
+
* flag rather than a CDP command. A proxy must therefore be bound outside the
|
|
368
|
+
* browser: OS-level proxy, TUN/transparent redirect, or a local forwarder in
|
|
369
|
+
* front of the ego-lite process.
|
|
370
|
+
*/
|
|
371
|
+
declare const PROXY_RESOLUTION_NOTE: string;
|
|
372
|
+
/**
|
|
373
|
+
* The note used when an account has no proxy declared at all.
|
|
374
|
+
*/
|
|
375
|
+
declare const PROXY_MISSING_NOTE: string;
|
|
376
|
+
/**
|
|
377
|
+
* Computes the readiness of an account profile.
|
|
378
|
+
*
|
|
379
|
+
* `ready` requires *both* a bound ego-lite profile and a declared proxy.
|
|
380
|
+
*/
|
|
381
|
+
declare function getProfileReadiness(profile: EgoAccountProfile): EgoProfileReadiness;
|
|
382
|
+
/**
|
|
383
|
+
* Builds the proxy declaration for an account profile.
|
|
384
|
+
*/
|
|
385
|
+
declare function buildProxyDeclaration(profile: EgoAccountProfile): EgoProxyDeclaration;
|
|
386
|
+
/**
|
|
387
|
+
* Options for {@link buildEgoSessionPlan}.
|
|
388
|
+
*/
|
|
389
|
+
interface BuildEgoSessionPlanOptions {
|
|
390
|
+
/** Optional task space name. Defaults to a name derived from the seed. */
|
|
391
|
+
taskSpaceName?: string;
|
|
392
|
+
/** Optional CDP session id to attach to every command. */
|
|
393
|
+
sessionId?: string;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Builds the complete launch plan for one account session.
|
|
397
|
+
*
|
|
398
|
+
* Command order is inherited from {@link getCdpPlan} and is load-bearing:
|
|
399
|
+
* `Page.enable` comes first (without it the init script is accepted but never
|
|
400
|
+
* runs), the user-agent override precedes navigation, and the init script is
|
|
401
|
+
* installed last so it is in place before the first document is created.
|
|
402
|
+
*
|
|
403
|
+
* The profile id has exactly one source: the persisted account record. Accepting
|
|
404
|
+
* a second, caller-supplied profile id would let the plan's profile id and its
|
|
405
|
+
* readiness disagree, and a caller could end up launching a session under a
|
|
406
|
+
* profile that was never validated.
|
|
407
|
+
*
|
|
408
|
+
* @param passport The sticky passport for the account.
|
|
409
|
+
* @param profile The persisted account profile (supplies the profile id and the
|
|
410
|
+
* proxy declaration).
|
|
411
|
+
* @param options Task space name and session id.
|
|
412
|
+
*/
|
|
413
|
+
declare function buildEgoSessionPlan(passport: DevicePassport, profile: EgoAccountProfile, options?: BuildEgoSessionPlanOptions): EgoSessionPlan;
|
|
414
|
+
/**
|
|
415
|
+
* Builds the default task space name for a seed.
|
|
416
|
+
*
|
|
417
|
+
* Task space names must be unique per launch, so callers normally append a
|
|
418
|
+
* timestamp or counter. The default is stable enough to be recognizable.
|
|
419
|
+
*/
|
|
420
|
+
declare function defaultTaskSpaceName(seed: string): string;
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* ego-lite bridge adapters.
|
|
424
|
+
*
|
|
425
|
+
* 🔴 Why this exists:
|
|
426
|
+
* ego-lite is the author's own agent browser. It runs on the local machine and is
|
|
427
|
+
* driven through the `ego-browser` CLI's nodejs heredoc mode. This package must not
|
|
428
|
+
* depend on ego-lite (it ships zero dependencies), so the ego-lite specific API is
|
|
429
|
+
* described structurally and injected from the outside.
|
|
430
|
+
*
|
|
431
|
+
* The capability boundary this module encodes — verified against ego-lite's own
|
|
432
|
+
* source, not guessed:
|
|
433
|
+
* · `listProfiles` exists and lists browser profiles.
|
|
434
|
+
* · `createTaskSpace` / `useTaskSpace` accept a `profileId`.
|
|
435
|
+
* · There is **no** proxy API: no `Browser.setProxySettings` in CDP, and no proxy
|
|
436
|
+
* setter among ego-lite's native bindings.
|
|
437
|
+
* · `page.cdp(method, params)` can send arbitrary CDP commands.
|
|
438
|
+
*/
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* The minimal shape of the ego-lite global object this bridge uses.
|
|
442
|
+
*
|
|
443
|
+
* Matches ego-lite's native binding names exactly, so `globalThis.ego` satisfies it
|
|
444
|
+
* structurally without importing ego-lite.
|
|
445
|
+
*/
|
|
446
|
+
interface EgoNativeBridge {
|
|
447
|
+
/** Lists the browser profiles available for new task spaces. */
|
|
448
|
+
listProfiles?(): Promise<{
|
|
449
|
+
profiles?: EgoProfile[];
|
|
450
|
+
} | EgoProfile[]>;
|
|
451
|
+
/** Creates a task space, optionally bound to a browser profile. */
|
|
452
|
+
createTaskSpace?(name: string, profileId?: string): Promise<unknown>;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Reads the ego-lite native bridge from the global scope.
|
|
456
|
+
*
|
|
457
|
+
* @returns The native bridge, or `null` when ego-lite is not present.
|
|
458
|
+
*/
|
|
459
|
+
declare function getEgoNativeBridge(scope?: unknown): EgoNativeBridge | null;
|
|
460
|
+
/**
|
|
461
|
+
* Builds an {@link EgoLiteBridge} on top of the ego-lite native bindings.
|
|
462
|
+
*
|
|
463
|
+
* @param native The native bridge. Defaults to `globalThis.ego`.
|
|
464
|
+
* @throws When ego-lite is unavailable or lacks a required binding.
|
|
465
|
+
*/
|
|
466
|
+
declare function createEgoBridge(native?: EgoNativeBridge | null): EgoLiteBridge;
|
|
467
|
+
|
|
468
|
+
export { AccountProfileManager as A, DevicePassportInstance as D, PROXY_MISSING_NOTE as P, PROXY_RESOLUTION_NOTE as d, PassportManager as e, buildEgoSessionPlan as g, buildProxyDeclaration as h, createEgoBridge as i, createPassport as j, defaultTaskSpaceName as k, getEgoNativeBridge as l, getProfileReadiness as m };
|
|
469
|
+
export type { BindProfileOptions as B, CreatePassportInputOptions as C, EgoNativeBridge as E, AccountProfileManagerOptions as a, BuildEgoSessionPlanOptions as b, CreateSessionPlanOptions as c, PassportManagerOptions as f };
|