lexmount 0.5.5 → 0.5.6

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 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
@@ -838,6 +838,6 @@ declare class TimeoutError extends LexmountError {
838
838
  /**
839
839
  * Lexmount Node.js SDK.
840
840
  */
841
- declare const VERSION = "0.5.5";
841
+ declare const VERSION = "0.5.6";
842
842
 
843
843
  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
@@ -838,6 +838,6 @@ declare class TimeoutError extends LexmountError {
838
838
  /**
839
839
  * Lexmount Node.js SDK.
840
840
  */
841
- declare const VERSION = "0.5.5";
841
+ declare const VERSION = "0.5.6";
842
842
 
843
843
  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
  }
@@ -588,10 +592,10 @@ var SessionsResource = class {
588
592
  payload.weak_lock = true;
589
593
  }
590
594
  if (options.asyncCreate !== false) {
591
- return this.createAsync(payload, options);
595
+ return this.createAsync(withRequestedRegion(this.client, payload), options);
592
596
  }
593
597
  const url = `${this.client.baseUrl}/instance`;
594
- const response = await this.client._post(url, payload);
598
+ const response = await this.client._post(url, withRequestedRegion(this.client, payload));
595
599
  if (response.status >= 400) {
596
600
  this.handleCreateError(response);
597
601
  }
@@ -613,6 +617,7 @@ var SessionsResource = class {
613
617
  status: createdSession?.status ?? "active",
614
618
  apiKey: this.client.apiKey,
615
619
  projectId,
620
+ regionId: createdSession?.regionId ?? this.client.selectedRegion ?? this.client.region ?? null,
616
621
  browserType: createdSession?.browserType ?? (options.browserMode ?? "normal"),
617
622
  createdAt: createdSession?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
618
623
  inspectUrl: createdSession?.inspectUrl ?? `${this.client.baseUrl}/inspect?session_id=${sessionId}`,
@@ -648,6 +653,7 @@ var SessionsResource = class {
648
653
  status: "active",
649
654
  apiKey: this.client.apiKey,
650
655
  projectId,
656
+ regionId: info.regionId ?? this.client.selectedRegion ?? this.client.region ?? null,
651
657
  browserType: info.browserType || (options.browserMode ?? "normal"),
652
658
  createdAt: info.createdAt,
653
659
  inspectUrl: info.inspectUrl,
@@ -682,11 +688,11 @@ var SessionsResource = class {
682
688
  * intentionally uses POST even though the operation is read-only.
683
689
  */
684
690
  async get(sessionId, projectId) {
685
- const response = await this.client._post(`${this.client.baseUrl}/instance/session`, {
691
+ const response = await this.client._post(`${this.client.baseUrl}/instance/session`, withRequestedRegion(this.client, {
686
692
  api_key: this.client.apiKey,
687
693
  project_id: projectId ?? this.client.projectId,
688
694
  session_id: sessionId
689
- });
695
+ }));
690
696
  if (response.status >= 400) {
691
697
  this.handleGetError(response, sessionId);
692
698
  }
@@ -704,7 +710,7 @@ var SessionsResource = class {
704
710
  if (options.status) {
705
711
  payload.status = options.status;
706
712
  }
707
- const response = await this.client._post(url, payload);
713
+ const response = await this.client._post(url, withRequestedRegion(this.client, payload));
708
714
  if (response.status >= 400) {
709
715
  this.handleListError(response);
710
716
  }
@@ -730,11 +736,11 @@ var SessionsResource = class {
730
736
  */
731
737
  async delete(options) {
732
738
  const url = `${this.client.baseUrl}/instance`;
733
- const payload = {
739
+ const payload = withRequestedRegion(this.client, {
734
740
  api_key: this.client.apiKey,
735
741
  project_id: options.projectId ?? this.client.projectId,
736
742
  session_id: options.sessionId
737
- };
743
+ });
738
744
  const response = await this.client._delete(url, payload);
739
745
  if (response.status >= 400) {
740
746
  this.handleDeleteError(response, options.sessionId);
@@ -1729,7 +1735,7 @@ var Lexmount = class {
1729
1735
  };
1730
1736
 
1731
1737
  // src/index.ts
1732
- var VERSION = "0.5.5";
1738
+ var VERSION = "0.5.6";
1733
1739
  // Annotate the CommonJS export names for ESM import in node:
1734
1740
  0 && (module.exports = {
1735
1741
  APIError,