lexmount 0.5.5 → 0.5.7
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/README.md +73 -0
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +17 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -224,6 +224,41 @@ await session.close();
|
|
|
224
224
|
client.close();
|
|
225
225
|
```
|
|
226
226
|
|
|
227
|
+
### Integrated Auth with lexmount-extra
|
|
228
|
+
|
|
229
|
+
For NTLM or Kerberos integrated auth, install `lexmount-extra` in your
|
|
230
|
+
application and register the callback factories it provides:
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
import { Lexmount, connectOverCDP, registerIntegratedAuthCallback } from 'lexmount';
|
|
234
|
+
import { createKerberosAuthCallback, createNTLMAuthCallback } from 'lexmount-extra';
|
|
235
|
+
|
|
236
|
+
const client = new Lexmount();
|
|
237
|
+
const session = await client.sessions.create({ browserMode: 'normal' });
|
|
238
|
+
const cdpClient = await connectOverCDP(session);
|
|
239
|
+
|
|
240
|
+
await registerIntegratedAuthCallback(
|
|
241
|
+
cdpClient,
|
|
242
|
+
createNTLMAuthCallback({
|
|
243
|
+
hostname: 'web.lab.local',
|
|
244
|
+
domain: 'LAB',
|
|
245
|
+
username: process.env.LEXMOUNT_NTLM_USERNAME,
|
|
246
|
+
password: process.env.LEXMOUNT_NTLM_PASSWORD,
|
|
247
|
+
})
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
await registerIntegratedAuthCallback(
|
|
251
|
+
cdpClient,
|
|
252
|
+
createKerberosAuthCallback({
|
|
253
|
+
hostname: 'web.lab.test',
|
|
254
|
+
})
|
|
255
|
+
);
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
`lexmount-extra` can derive some NTLM and Kerberos defaults from the current
|
|
259
|
+
environment, but explicit callback options are usually clearer for reproducible
|
|
260
|
+
integrations.
|
|
261
|
+
|
|
227
262
|
### Error Handling
|
|
228
263
|
|
|
229
264
|
```ts
|
|
@@ -283,6 +318,7 @@ Generated files are written to `generated-docs/` and are not meant to be committ
|
|
|
283
318
|
|
|
284
319
|
Example scripts live in [examples](./examples):
|
|
285
320
|
|
|
321
|
+
- `auth-basic.ts`
|
|
286
322
|
- `playwright-basic.ts`
|
|
287
323
|
- `session-management.ts`
|
|
288
324
|
- `context-basic.ts`
|
|
@@ -299,6 +335,7 @@ Run them with:
|
|
|
299
335
|
```bash
|
|
300
336
|
cd examples
|
|
301
337
|
npm install
|
|
338
|
+
npm run auth-basic
|
|
302
339
|
npm run context-fork
|
|
303
340
|
npm run playwright-basic
|
|
304
341
|
npm run session-management
|
|
@@ -542,6 +579,40 @@ await session.close();
|
|
|
542
579
|
client.close();
|
|
543
580
|
```
|
|
544
581
|
|
|
582
|
+
### 使用 lexmount-extra 集成认证
|
|
583
|
+
|
|
584
|
+
如果需要 NTLM 或 Kerberos 集成认证,可以在业务项目中安装 `lexmount-extra`,
|
|
585
|
+
并注册它提供的回调工厂:
|
|
586
|
+
|
|
587
|
+
```ts
|
|
588
|
+
import { Lexmount, connectOverCDP, registerIntegratedAuthCallback } from 'lexmount';
|
|
589
|
+
import { createKerberosAuthCallback, createNTLMAuthCallback } from 'lexmount-extra';
|
|
590
|
+
|
|
591
|
+
const client = new Lexmount();
|
|
592
|
+
const session = await client.sessions.create({ browserMode: 'normal' });
|
|
593
|
+
const cdpClient = await connectOverCDP(session);
|
|
594
|
+
|
|
595
|
+
await registerIntegratedAuthCallback(
|
|
596
|
+
cdpClient,
|
|
597
|
+
createNTLMAuthCallback({
|
|
598
|
+
hostname: 'web.lab.local',
|
|
599
|
+
domain: 'LAB',
|
|
600
|
+
username: process.env.LEXMOUNT_NTLM_USERNAME,
|
|
601
|
+
password: process.env.LEXMOUNT_NTLM_PASSWORD,
|
|
602
|
+
})
|
|
603
|
+
);
|
|
604
|
+
|
|
605
|
+
await registerIntegratedAuthCallback(
|
|
606
|
+
cdpClient,
|
|
607
|
+
createKerberosAuthCallback({
|
|
608
|
+
hostname: 'web.lab.test',
|
|
609
|
+
})
|
|
610
|
+
);
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
`lexmount-extra` 可以从当前环境推导部分 NTLM/Kerberos 默认值,但显式传入回调
|
|
614
|
+
选项更适合可复现的集成。
|
|
615
|
+
|
|
545
616
|
### 错误处理
|
|
546
617
|
|
|
547
618
|
```ts
|
|
@@ -601,6 +672,7 @@ npm run docs:html
|
|
|
601
672
|
|
|
602
673
|
示例脚本位于 [examples](./examples):
|
|
603
674
|
|
|
675
|
+
- `auth-basic.ts`
|
|
604
676
|
- `playwright-basic.ts`
|
|
605
677
|
- `session-management.ts`
|
|
606
678
|
- `context-basic.ts`
|
|
@@ -617,6 +689,7 @@ npm run docs:html
|
|
|
617
689
|
```bash
|
|
618
690
|
cd examples
|
|
619
691
|
npm install
|
|
692
|
+
npm run auth-basic
|
|
620
693
|
npm run context-fork
|
|
621
694
|
npm run playwright-basic
|
|
622
695
|
npm run session-management
|
package/dist/index.d.mts
CHANGED
|
@@ -161,6 +161,10 @@ interface SessionCreateOptions {
|
|
|
161
161
|
* Browser mode to start.
|
|
162
162
|
*/
|
|
163
163
|
browserMode?: BrowserMode;
|
|
164
|
+
/**
|
|
165
|
+
* Optional custom browser image identifier to use for this session.
|
|
166
|
+
*/
|
|
167
|
+
customImageId?: string;
|
|
164
168
|
/**
|
|
165
169
|
* Optional persistent context configuration.
|
|
166
170
|
*/
|
|
@@ -838,6 +842,6 @@ declare class TimeoutError extends LexmountError {
|
|
|
838
842
|
/**
|
|
839
843
|
* Lexmount Node.js SDK.
|
|
840
844
|
*/
|
|
841
|
-
declare const VERSION = "0.5.
|
|
845
|
+
declare const VERSION = "0.5.7";
|
|
842
846
|
|
|
843
847
|
export { APIError, AuthenticationError, type BrowserMode, CDPClient, type CDPEventMessage, type CatalogInfo, type ContextAccessMode, type ContextCreateOptions, ContextInfo, type ContextListOptions, ContextListResponse, ContextLockedError, type ContextMetadata, ContextNotFoundError, type ContextStatus, ContextsResource, ExtensionInfo, type ExtensionInfoShape, type ExtensionListOptions, type ExtensionUploadOptions, ExtensionsResource, type ForceReleaseResponse, type IntegratedAuthCallback, type IntegratedAuthCallbackResult, Lexmount, type LexmountConfig, LexmountError, LexmountLogger, type LogLevel, NetworkError, PaginationInfo, type PaginationInfoShape, type RegionCatalogEntry, type RegionInfo, type SessionContext, type SessionCreateOptions, type SessionCreateResponse, type SessionDeleteOptions, SessionDownloadInfo, type SessionDownloadInfoShape, SessionDownloadsDeleteResponse, type SessionDownloadsDeleteResponseShape, SessionDownloadsListResponse, type SessionDownloadsListResponseShape, SessionDownloadsResource, SessionInfo, type SessionListOptions, SessionListResponse, SessionNotFoundError, type SessionProxyConfig, type SessionStatus, SessionTargetInfo, type SessionTargetInfoShape, SessionsResource, TimeoutError, VERSION, ValidationError, connectOverCDP, Lexmount as default, deregisterIntegratedAuthCallback, disableLogging, enableLogging, getLogger, registerIntegratedAuthCallback, setLogLevel };
|
package/dist/index.d.ts
CHANGED
|
@@ -161,6 +161,10 @@ interface SessionCreateOptions {
|
|
|
161
161
|
* Browser mode to start.
|
|
162
162
|
*/
|
|
163
163
|
browserMode?: BrowserMode;
|
|
164
|
+
/**
|
|
165
|
+
* Optional custom browser image identifier to use for this session.
|
|
166
|
+
*/
|
|
167
|
+
customImageId?: string;
|
|
164
168
|
/**
|
|
165
169
|
* Optional persistent context configuration.
|
|
166
170
|
*/
|
|
@@ -838,6 +842,6 @@ declare class TimeoutError extends LexmountError {
|
|
|
838
842
|
/**
|
|
839
843
|
* Lexmount Node.js SDK.
|
|
840
844
|
*/
|
|
841
|
-
declare const VERSION = "0.5.
|
|
845
|
+
declare const VERSION = "0.5.7";
|
|
842
846
|
|
|
843
847
|
export { APIError, AuthenticationError, type BrowserMode, CDPClient, type CDPEventMessage, type CatalogInfo, type ContextAccessMode, type ContextCreateOptions, ContextInfo, type ContextListOptions, ContextListResponse, ContextLockedError, type ContextMetadata, ContextNotFoundError, type ContextStatus, ContextsResource, ExtensionInfo, type ExtensionInfoShape, type ExtensionListOptions, type ExtensionUploadOptions, ExtensionsResource, type ForceReleaseResponse, type IntegratedAuthCallback, type IntegratedAuthCallbackResult, Lexmount, type LexmountConfig, LexmountError, LexmountLogger, type LogLevel, NetworkError, PaginationInfo, type PaginationInfoShape, type RegionCatalogEntry, type RegionInfo, type SessionContext, type SessionCreateOptions, type SessionCreateResponse, type SessionDeleteOptions, SessionDownloadInfo, type SessionDownloadInfoShape, SessionDownloadsDeleteResponse, type SessionDownloadsDeleteResponseShape, SessionDownloadsListResponse, type SessionDownloadsListResponseShape, SessionDownloadsResource, SessionInfo, type SessionListOptions, SessionListResponse, SessionNotFoundError, type SessionProxyConfig, type SessionStatus, SessionTargetInfo, type SessionTargetInfoShape, SessionsResource, TimeoutError, VERSION, ValidationError, connectOverCDP, Lexmount as default, deregisterIntegratedAuthCallback, disableLogging, enableLogging, getLogger, registerIntegratedAuthCallback, setLogLevel };
|
package/dist/index.js
CHANGED
|
@@ -314,6 +314,10 @@ function asRecord(value) {
|
|
|
314
314
|
function getString(value) {
|
|
315
315
|
return typeof value === "string" ? value : void 0;
|
|
316
316
|
}
|
|
317
|
+
function withRequestedRegion(client, payload) {
|
|
318
|
+
const regionId = client.selectedRegion ?? client.region;
|
|
319
|
+
return regionId ? { ...payload, region_id: regionId } : payload;
|
|
320
|
+
}
|
|
317
321
|
function getNumber(value) {
|
|
318
322
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
319
323
|
}
|
|
@@ -566,6 +570,9 @@ var SessionsResource = class {
|
|
|
566
570
|
project_id: options.projectId ?? this.client.projectId,
|
|
567
571
|
browser_mode: options.browserMode ?? "normal"
|
|
568
572
|
};
|
|
573
|
+
if (options.customImageId) {
|
|
574
|
+
payload.custom_image_id = options.customImageId;
|
|
575
|
+
}
|
|
569
576
|
if (options.context) {
|
|
570
577
|
const contextPayload = {
|
|
571
578
|
id: options.context.id,
|
|
@@ -588,10 +595,10 @@ var SessionsResource = class {
|
|
|
588
595
|
payload.weak_lock = true;
|
|
589
596
|
}
|
|
590
597
|
if (options.asyncCreate !== false) {
|
|
591
|
-
return this.createAsync(payload, options);
|
|
598
|
+
return this.createAsync(withRequestedRegion(this.client, payload), options);
|
|
592
599
|
}
|
|
593
600
|
const url = `${this.client.baseUrl}/instance`;
|
|
594
|
-
const response = await this.client._post(url, payload);
|
|
601
|
+
const response = await this.client._post(url, withRequestedRegion(this.client, payload));
|
|
595
602
|
if (response.status >= 400) {
|
|
596
603
|
this.handleCreateError(response);
|
|
597
604
|
}
|
|
@@ -613,6 +620,7 @@ var SessionsResource = class {
|
|
|
613
620
|
status: createdSession?.status ?? "active",
|
|
614
621
|
apiKey: this.client.apiKey,
|
|
615
622
|
projectId,
|
|
623
|
+
regionId: createdSession?.regionId ?? this.client.selectedRegion ?? this.client.region ?? null,
|
|
616
624
|
browserType: createdSession?.browserType ?? (options.browserMode ?? "normal"),
|
|
617
625
|
createdAt: createdSession?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
618
626
|
inspectUrl: createdSession?.inspectUrl ?? `${this.client.baseUrl}/inspect?session_id=${sessionId}`,
|
|
@@ -648,6 +656,7 @@ var SessionsResource = class {
|
|
|
648
656
|
status: "active",
|
|
649
657
|
apiKey: this.client.apiKey,
|
|
650
658
|
projectId,
|
|
659
|
+
regionId: info.regionId ?? this.client.selectedRegion ?? this.client.region ?? null,
|
|
651
660
|
browserType: info.browserType || (options.browserMode ?? "normal"),
|
|
652
661
|
createdAt: info.createdAt,
|
|
653
662
|
inspectUrl: info.inspectUrl,
|
|
@@ -682,11 +691,11 @@ var SessionsResource = class {
|
|
|
682
691
|
* intentionally uses POST even though the operation is read-only.
|
|
683
692
|
*/
|
|
684
693
|
async get(sessionId, projectId) {
|
|
685
|
-
const response = await this.client._post(`${this.client.baseUrl}/instance/session`, {
|
|
694
|
+
const response = await this.client._post(`${this.client.baseUrl}/instance/session`, withRequestedRegion(this.client, {
|
|
686
695
|
api_key: this.client.apiKey,
|
|
687
696
|
project_id: projectId ?? this.client.projectId,
|
|
688
697
|
session_id: sessionId
|
|
689
|
-
});
|
|
698
|
+
}));
|
|
690
699
|
if (response.status >= 400) {
|
|
691
700
|
this.handleGetError(response, sessionId);
|
|
692
701
|
}
|
|
@@ -704,7 +713,7 @@ var SessionsResource = class {
|
|
|
704
713
|
if (options.status) {
|
|
705
714
|
payload.status = options.status;
|
|
706
715
|
}
|
|
707
|
-
const response = await this.client._post(url, payload);
|
|
716
|
+
const response = await this.client._post(url, withRequestedRegion(this.client, payload));
|
|
708
717
|
if (response.status >= 400) {
|
|
709
718
|
this.handleListError(response);
|
|
710
719
|
}
|
|
@@ -730,11 +739,11 @@ var SessionsResource = class {
|
|
|
730
739
|
*/
|
|
731
740
|
async delete(options) {
|
|
732
741
|
const url = `${this.client.baseUrl}/instance`;
|
|
733
|
-
const payload = {
|
|
742
|
+
const payload = withRequestedRegion(this.client, {
|
|
734
743
|
api_key: this.client.apiKey,
|
|
735
744
|
project_id: options.projectId ?? this.client.projectId,
|
|
736
745
|
session_id: options.sessionId
|
|
737
|
-
};
|
|
746
|
+
});
|
|
738
747
|
const response = await this.client._delete(url, payload);
|
|
739
748
|
if (response.status >= 400) {
|
|
740
749
|
this.handleDeleteError(response, options.sessionId);
|
|
@@ -1729,7 +1738,7 @@ var Lexmount = class {
|
|
|
1729
1738
|
};
|
|
1730
1739
|
|
|
1731
1740
|
// src/index.ts
|
|
1732
|
-
var VERSION = "0.5.
|
|
1741
|
+
var VERSION = "0.5.7";
|
|
1733
1742
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1734
1743
|
0 && (module.exports = {
|
|
1735
1744
|
APIError,
|