lexmount 0.5.3 → 0.5.5

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/index.d.mts CHANGED
@@ -1,3 +1,5 @@
1
+ /// <reference path="../types/chrome-remote-interface.d.ts" />
2
+ import { EventEmitter } from 'events';
1
3
  import { AxiosRequestConfig, AxiosResponse } from 'axios';
2
4
 
3
5
  /**
@@ -443,6 +445,87 @@ declare class ExtensionsResource {
443
445
  private handleError;
444
446
  }
445
447
 
448
+ /**
449
+ * Lexmount API client.
450
+ */
451
+
452
+ /**
453
+ * Main Lexmount SDK client.
454
+ */
455
+ declare class Lexmount {
456
+ /**
457
+ * API key used for authentication.
458
+ */
459
+ readonly apiKey: string;
460
+ /**
461
+ * Default project identifier used by resource methods.
462
+ */
463
+ readonly projectId: string;
464
+ /**
465
+ * API base URL.
466
+ */
467
+ readonly baseUrl: string;
468
+ readonly region?: string;
469
+ selectedRegion?: string;
470
+ private endpointBaseUrl?;
471
+ private selectedHost?;
472
+ private regionResolutionAttempted;
473
+ private regionResolutionPromise?;
474
+ /**
475
+ * Session operations.
476
+ */
477
+ readonly sessions: SessionsResource;
478
+ /**
479
+ * Persistent context operations.
480
+ */
481
+ readonly contexts: ContextsResource;
482
+ /**
483
+ * Browser extension operations.
484
+ */
485
+ readonly extensions: ExtensionsResource;
486
+ private readonly httpClient;
487
+ constructor(config?: LexmountConfig);
488
+ /**
489
+ * Internal POST request helper with timeout and network error mapping.
490
+ *
491
+ * @internal
492
+ */
493
+ _post<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
494
+ /**
495
+ * Internal GET request helper with timeout and network error mapping.
496
+ *
497
+ * @internal
498
+ */
499
+ _get<T = unknown>(url: string, params?: Record<string, unknown>, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
500
+ /**
501
+ * Internal DELETE request helper with timeout and network error mapping.
502
+ *
503
+ * @internal
504
+ */
505
+ _delete<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
506
+ regionInfo(): Promise<RegionInfo>;
507
+ catalogInfo(): Promise<CatalogInfo>;
508
+ /**
509
+ * Close the client.
510
+ *
511
+ * Axios does not require explicit teardown, but the method is kept for API symmetry.
512
+ */
513
+ close(): void;
514
+ /**
515
+ * String representation of the client.
516
+ */
517
+ toString(): string;
518
+ private request;
519
+ private normalizeRequestError;
520
+ private getDefaultHeaders;
521
+ private ensureRegionResolved;
522
+ private resolveRegion;
523
+ private selectCatalogRegion;
524
+ private probeRegionHost;
525
+ private isAllowedCatalogHost;
526
+ private rewriteUrl;
527
+ }
528
+
446
529
  /**
447
530
  * Session resource implementation.
448
531
  */
@@ -464,6 +547,7 @@ interface SessionInfoOptions {
464
547
  status: SessionStatus;
465
548
  apiKey: string;
466
549
  projectId: string;
550
+ regionId?: string | null;
467
551
  browserType: BrowserMode | string;
468
552
  createdAt: string;
469
553
  inspectUrl: string;
@@ -480,6 +564,8 @@ declare class SessionInfo {
480
564
  readonly status: SessionStatus;
481
565
  readonly apiKey: string;
482
566
  readonly projectId: string;
567
+ readonly regionId: string | null;
568
+ readonly region_id: string | null;
483
569
  readonly browserType: BrowserMode | string;
484
570
  readonly createdAt: string;
485
571
  readonly inspectUrl: string;
@@ -627,85 +713,65 @@ declare class SessionsResource {
627
713
  }
628
714
 
629
715
  /**
630
- * Lexmount API client.
716
+ * Chrome DevTools Protocol connection helpers.
631
717
  */
632
718
 
719
+ interface CDPEventMessage {
720
+ method: string;
721
+ params?: Record<string, unknown>;
722
+ sessionId?: string;
723
+ }
633
724
  /**
634
- * Main Lexmount SDK client.
725
+ * Lexmount CDP client.
726
+ *
727
+ * It forwards Chrome DevTools Protocol notifications through EventEmitter and
728
+ * exposes `send()` for raw CDP commands.
635
729
  */
636
- declare class Lexmount {
637
- /**
638
- * API key used for authentication.
639
- */
640
- readonly apiKey: string;
641
- /**
642
- * Default project identifier used by resource methods.
643
- */
644
- readonly projectId: string;
645
- /**
646
- * API base URL.
647
- */
648
- readonly baseUrl: string;
649
- readonly region?: string;
650
- selectedRegion?: string;
651
- private endpointBaseUrl?;
652
- private selectedHost?;
653
- private regionResolutionAttempted;
654
- private regionResolutionPromise?;
655
- /**
656
- * Session operations.
657
- */
658
- readonly sessions: SessionsResource;
659
- /**
660
- * Persistent context operations.
661
- */
662
- readonly contexts: ContextsResource;
663
- /**
664
- * Browser extension operations.
665
- */
666
- readonly extensions: ExtensionsResource;
667
- private readonly httpClient;
668
- constructor(config?: LexmountConfig);
669
- /**
670
- * Internal POST request helper with timeout and network error mapping.
671
- *
672
- * @internal
673
- */
674
- _post<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
675
- /**
676
- * Internal GET request helper with timeout and network error mapping.
677
- *
678
- * @internal
679
- */
680
- _get<T = unknown>(url: string, params?: Record<string, unknown>, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
730
+ declare class CDPClient extends EventEmitter {
731
+ readonly session: SessionInfo;
732
+ private closed;
733
+ private rawClient?;
734
+ constructor(session: SessionInfo);
681
735
  /**
682
- * Internal DELETE request helper with timeout and network error mapping.
683
- *
684
- * @internal
736
+ * Connect the CDP client to the session.
685
737
  */
686
- _delete<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
687
- regionInfo(): Promise<RegionInfo>;
688
- catalogInfo(): Promise<CatalogInfo>;
738
+ connect(): Promise<this>;
689
739
  /**
690
- * Close the client.
740
+ * Send a raw Chrome DevTools Protocol command.
691
741
  *
692
- * Axios does not require explicit teardown, but the method is kept for API symmetry.
742
+ * Returns `undefined` if called before the client has connected.
693
743
  */
694
- close(): void;
744
+ send(method: string, params?: any, sessionId?: string): Promise<any | undefined>;
695
745
  /**
696
- * String representation of the client.
746
+ * Close the CDP connection and release internal listeners.
697
747
  */
698
- toString(): string;
699
- private request;
700
- private normalizeRequestError;
701
- private getDefaultHeaders;
702
- private ensureRegionResolved;
703
- private resolveRegion;
704
- private selectCatalogRegion;
705
- private probeRegionHost;
706
- private isAllowedCatalogHost;
707
- private rewriteUrl;
748
+ close(): Promise<void>;
708
749
  }
750
+ /**
751
+ * Connect to a Lexmount browser session over Chrome DevTools Protocol.
752
+ */
753
+ declare function connectOverCDP(session: SessionInfo): Promise<CDPClient>;
754
+
755
+ /**
756
+ * Integrated authentication helpers.
757
+ */
758
+
759
+ type IntegratedAuthCallbackResult = {
760
+ cancel: true;
761
+ } | {
762
+ cancel: false;
763
+ scheme: string;
764
+ token: string;
765
+ };
766
+ type IntegratedAuthCallback = (params: any, callback: (result: IntegratedAuthCallbackResult) => Promise<void>) => void | Promise<void>;
767
+ /**
768
+ * Register an integrated auth callback for a session.
769
+ */
770
+ declare function registerIntegratedAuthCallback(sessionOrClient: SessionInfo | CDPClient, callback: IntegratedAuthCallback): Promise<void>;
771
+ /**
772
+ * Deregister a previously registered integrated auth callback.
773
+ */
774
+ declare function deregisterIntegratedAuthCallback(sessionOrClient: SessionInfo | CDPClient, callback: IntegratedAuthCallback): void;
709
775
 
710
776
  /**
711
777
  * Lexmount SDK error hierarchy.
@@ -772,6 +838,6 @@ declare class TimeoutError extends LexmountError {
772
838
  /**
773
839
  * Lexmount Node.js SDK.
774
840
  */
775
- declare const VERSION = "0.5.3";
841
+ declare const VERSION = "0.5.5";
776
842
 
777
- export { APIError, AuthenticationError, type BrowserMode, 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, 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, Lexmount as default, disableLogging, enableLogging, getLogger, setLogLevel };
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
@@ -1,3 +1,5 @@
1
+ /// <reference path="../types/chrome-remote-interface.d.ts" />
2
+ import { EventEmitter } from 'events';
1
3
  import { AxiosRequestConfig, AxiosResponse } from 'axios';
2
4
 
3
5
  /**
@@ -443,6 +445,87 @@ declare class ExtensionsResource {
443
445
  private handleError;
444
446
  }
445
447
 
448
+ /**
449
+ * Lexmount API client.
450
+ */
451
+
452
+ /**
453
+ * Main Lexmount SDK client.
454
+ */
455
+ declare class Lexmount {
456
+ /**
457
+ * API key used for authentication.
458
+ */
459
+ readonly apiKey: string;
460
+ /**
461
+ * Default project identifier used by resource methods.
462
+ */
463
+ readonly projectId: string;
464
+ /**
465
+ * API base URL.
466
+ */
467
+ readonly baseUrl: string;
468
+ readonly region?: string;
469
+ selectedRegion?: string;
470
+ private endpointBaseUrl?;
471
+ private selectedHost?;
472
+ private regionResolutionAttempted;
473
+ private regionResolutionPromise?;
474
+ /**
475
+ * Session operations.
476
+ */
477
+ readonly sessions: SessionsResource;
478
+ /**
479
+ * Persistent context operations.
480
+ */
481
+ readonly contexts: ContextsResource;
482
+ /**
483
+ * Browser extension operations.
484
+ */
485
+ readonly extensions: ExtensionsResource;
486
+ private readonly httpClient;
487
+ constructor(config?: LexmountConfig);
488
+ /**
489
+ * Internal POST request helper with timeout and network error mapping.
490
+ *
491
+ * @internal
492
+ */
493
+ _post<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
494
+ /**
495
+ * Internal GET request helper with timeout and network error mapping.
496
+ *
497
+ * @internal
498
+ */
499
+ _get<T = unknown>(url: string, params?: Record<string, unknown>, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
500
+ /**
501
+ * Internal DELETE request helper with timeout and network error mapping.
502
+ *
503
+ * @internal
504
+ */
505
+ _delete<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
506
+ regionInfo(): Promise<RegionInfo>;
507
+ catalogInfo(): Promise<CatalogInfo>;
508
+ /**
509
+ * Close the client.
510
+ *
511
+ * Axios does not require explicit teardown, but the method is kept for API symmetry.
512
+ */
513
+ close(): void;
514
+ /**
515
+ * String representation of the client.
516
+ */
517
+ toString(): string;
518
+ private request;
519
+ private normalizeRequestError;
520
+ private getDefaultHeaders;
521
+ private ensureRegionResolved;
522
+ private resolveRegion;
523
+ private selectCatalogRegion;
524
+ private probeRegionHost;
525
+ private isAllowedCatalogHost;
526
+ private rewriteUrl;
527
+ }
528
+
446
529
  /**
447
530
  * Session resource implementation.
448
531
  */
@@ -464,6 +547,7 @@ interface SessionInfoOptions {
464
547
  status: SessionStatus;
465
548
  apiKey: string;
466
549
  projectId: string;
550
+ regionId?: string | null;
467
551
  browserType: BrowserMode | string;
468
552
  createdAt: string;
469
553
  inspectUrl: string;
@@ -480,6 +564,8 @@ declare class SessionInfo {
480
564
  readonly status: SessionStatus;
481
565
  readonly apiKey: string;
482
566
  readonly projectId: string;
567
+ readonly regionId: string | null;
568
+ readonly region_id: string | null;
483
569
  readonly browserType: BrowserMode | string;
484
570
  readonly createdAt: string;
485
571
  readonly inspectUrl: string;
@@ -627,85 +713,65 @@ declare class SessionsResource {
627
713
  }
628
714
 
629
715
  /**
630
- * Lexmount API client.
716
+ * Chrome DevTools Protocol connection helpers.
631
717
  */
632
718
 
719
+ interface CDPEventMessage {
720
+ method: string;
721
+ params?: Record<string, unknown>;
722
+ sessionId?: string;
723
+ }
633
724
  /**
634
- * Main Lexmount SDK client.
725
+ * Lexmount CDP client.
726
+ *
727
+ * It forwards Chrome DevTools Protocol notifications through EventEmitter and
728
+ * exposes `send()` for raw CDP commands.
635
729
  */
636
- declare class Lexmount {
637
- /**
638
- * API key used for authentication.
639
- */
640
- readonly apiKey: string;
641
- /**
642
- * Default project identifier used by resource methods.
643
- */
644
- readonly projectId: string;
645
- /**
646
- * API base URL.
647
- */
648
- readonly baseUrl: string;
649
- readonly region?: string;
650
- selectedRegion?: string;
651
- private endpointBaseUrl?;
652
- private selectedHost?;
653
- private regionResolutionAttempted;
654
- private regionResolutionPromise?;
655
- /**
656
- * Session operations.
657
- */
658
- readonly sessions: SessionsResource;
659
- /**
660
- * Persistent context operations.
661
- */
662
- readonly contexts: ContextsResource;
663
- /**
664
- * Browser extension operations.
665
- */
666
- readonly extensions: ExtensionsResource;
667
- private readonly httpClient;
668
- constructor(config?: LexmountConfig);
669
- /**
670
- * Internal POST request helper with timeout and network error mapping.
671
- *
672
- * @internal
673
- */
674
- _post<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
675
- /**
676
- * Internal GET request helper with timeout and network error mapping.
677
- *
678
- * @internal
679
- */
680
- _get<T = unknown>(url: string, params?: Record<string, unknown>, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
730
+ declare class CDPClient extends EventEmitter {
731
+ readonly session: SessionInfo;
732
+ private closed;
733
+ private rawClient?;
734
+ constructor(session: SessionInfo);
681
735
  /**
682
- * Internal DELETE request helper with timeout and network error mapping.
683
- *
684
- * @internal
736
+ * Connect the CDP client to the session.
685
737
  */
686
- _delete<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
687
- regionInfo(): Promise<RegionInfo>;
688
- catalogInfo(): Promise<CatalogInfo>;
738
+ connect(): Promise<this>;
689
739
  /**
690
- * Close the client.
740
+ * Send a raw Chrome DevTools Protocol command.
691
741
  *
692
- * Axios does not require explicit teardown, but the method is kept for API symmetry.
742
+ * Returns `undefined` if called before the client has connected.
693
743
  */
694
- close(): void;
744
+ send(method: string, params?: any, sessionId?: string): Promise<any | undefined>;
695
745
  /**
696
- * String representation of the client.
746
+ * Close the CDP connection and release internal listeners.
697
747
  */
698
- toString(): string;
699
- private request;
700
- private normalizeRequestError;
701
- private getDefaultHeaders;
702
- private ensureRegionResolved;
703
- private resolveRegion;
704
- private selectCatalogRegion;
705
- private probeRegionHost;
706
- private isAllowedCatalogHost;
707
- private rewriteUrl;
748
+ close(): Promise<void>;
708
749
  }
750
+ /**
751
+ * Connect to a Lexmount browser session over Chrome DevTools Protocol.
752
+ */
753
+ declare function connectOverCDP(session: SessionInfo): Promise<CDPClient>;
754
+
755
+ /**
756
+ * Integrated authentication helpers.
757
+ */
758
+
759
+ type IntegratedAuthCallbackResult = {
760
+ cancel: true;
761
+ } | {
762
+ cancel: false;
763
+ scheme: string;
764
+ token: string;
765
+ };
766
+ type IntegratedAuthCallback = (params: any, callback: (result: IntegratedAuthCallbackResult) => Promise<void>) => void | Promise<void>;
767
+ /**
768
+ * Register an integrated auth callback for a session.
769
+ */
770
+ declare function registerIntegratedAuthCallback(sessionOrClient: SessionInfo | CDPClient, callback: IntegratedAuthCallback): Promise<void>;
771
+ /**
772
+ * Deregister a previously registered integrated auth callback.
773
+ */
774
+ declare function deregisterIntegratedAuthCallback(sessionOrClient: SessionInfo | CDPClient, callback: IntegratedAuthCallback): void;
709
775
 
710
776
  /**
711
777
  * Lexmount SDK error hierarchy.
@@ -772,6 +838,6 @@ declare class TimeoutError extends LexmountError {
772
838
  /**
773
839
  * Lexmount Node.js SDK.
774
840
  */
775
- declare const VERSION = "0.5.3";
841
+ declare const VERSION = "0.5.5";
776
842
 
777
- export { APIError, AuthenticationError, type BrowserMode, 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, 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, Lexmount as default, disableLogging, enableLogging, getLogger, setLogLevel };
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 };