lexmount 0.5.4 → 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
  */
@@ -630,85 +713,65 @@ declare class SessionsResource {
630
713
  }
631
714
 
632
715
  /**
633
- * Lexmount API client.
716
+ * Chrome DevTools Protocol connection helpers.
634
717
  */
635
718
 
719
+ interface CDPEventMessage {
720
+ method: string;
721
+ params?: Record<string, unknown>;
722
+ sessionId?: string;
723
+ }
636
724
  /**
637
- * 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.
638
729
  */
639
- declare class Lexmount {
640
- /**
641
- * API key used for authentication.
642
- */
643
- readonly apiKey: string;
644
- /**
645
- * Default project identifier used by resource methods.
646
- */
647
- readonly projectId: string;
648
- /**
649
- * API base URL.
650
- */
651
- readonly baseUrl: string;
652
- readonly region?: string;
653
- selectedRegion?: string;
654
- private endpointBaseUrl?;
655
- private selectedHost?;
656
- private regionResolutionAttempted;
657
- private regionResolutionPromise?;
658
- /**
659
- * Session operations.
660
- */
661
- readonly sessions: SessionsResource;
662
- /**
663
- * Persistent context operations.
664
- */
665
- readonly contexts: ContextsResource;
666
- /**
667
- * Browser extension operations.
668
- */
669
- readonly extensions: ExtensionsResource;
670
- private readonly httpClient;
671
- constructor(config?: LexmountConfig);
672
- /**
673
- * Internal POST request helper with timeout and network error mapping.
674
- *
675
- * @internal
676
- */
677
- _post<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
678
- /**
679
- * Internal GET request helper with timeout and network error mapping.
680
- *
681
- * @internal
682
- */
683
- _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);
684
735
  /**
685
- * Internal DELETE request helper with timeout and network error mapping.
686
- *
687
- * @internal
736
+ * Connect the CDP client to the session.
688
737
  */
689
- _delete<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
690
- regionInfo(): Promise<RegionInfo>;
691
- catalogInfo(): Promise<CatalogInfo>;
738
+ connect(): Promise<this>;
692
739
  /**
693
- * Close the client.
740
+ * Send a raw Chrome DevTools Protocol command.
694
741
  *
695
- * Axios does not require explicit teardown, but the method is kept for API symmetry.
742
+ * Returns `undefined` if called before the client has connected.
696
743
  */
697
- close(): void;
744
+ send(method: string, params?: any, sessionId?: string): Promise<any | undefined>;
698
745
  /**
699
- * String representation of the client.
746
+ * Close the CDP connection and release internal listeners.
700
747
  */
701
- toString(): string;
702
- private request;
703
- private normalizeRequestError;
704
- private getDefaultHeaders;
705
- private ensureRegionResolved;
706
- private resolveRegion;
707
- private selectCatalogRegion;
708
- private probeRegionHost;
709
- private isAllowedCatalogHost;
710
- private rewriteUrl;
748
+ close(): Promise<void>;
711
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;
712
775
 
713
776
  /**
714
777
  * Lexmount SDK error hierarchy.
@@ -775,6 +838,6 @@ declare class TimeoutError extends LexmountError {
775
838
  /**
776
839
  * Lexmount Node.js SDK.
777
840
  */
778
- declare const VERSION = "0.5.4";
841
+ declare const VERSION = "0.5.5";
779
842
 
780
- 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
  */
@@ -630,85 +713,65 @@ declare class SessionsResource {
630
713
  }
631
714
 
632
715
  /**
633
- * Lexmount API client.
716
+ * Chrome DevTools Protocol connection helpers.
634
717
  */
635
718
 
719
+ interface CDPEventMessage {
720
+ method: string;
721
+ params?: Record<string, unknown>;
722
+ sessionId?: string;
723
+ }
636
724
  /**
637
- * 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.
638
729
  */
639
- declare class Lexmount {
640
- /**
641
- * API key used for authentication.
642
- */
643
- readonly apiKey: string;
644
- /**
645
- * Default project identifier used by resource methods.
646
- */
647
- readonly projectId: string;
648
- /**
649
- * API base URL.
650
- */
651
- readonly baseUrl: string;
652
- readonly region?: string;
653
- selectedRegion?: string;
654
- private endpointBaseUrl?;
655
- private selectedHost?;
656
- private regionResolutionAttempted;
657
- private regionResolutionPromise?;
658
- /**
659
- * Session operations.
660
- */
661
- readonly sessions: SessionsResource;
662
- /**
663
- * Persistent context operations.
664
- */
665
- readonly contexts: ContextsResource;
666
- /**
667
- * Browser extension operations.
668
- */
669
- readonly extensions: ExtensionsResource;
670
- private readonly httpClient;
671
- constructor(config?: LexmountConfig);
672
- /**
673
- * Internal POST request helper with timeout and network error mapping.
674
- *
675
- * @internal
676
- */
677
- _post<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
678
- /**
679
- * Internal GET request helper with timeout and network error mapping.
680
- *
681
- * @internal
682
- */
683
- _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);
684
735
  /**
685
- * Internal DELETE request helper with timeout and network error mapping.
686
- *
687
- * @internal
736
+ * Connect the CDP client to the session.
688
737
  */
689
- _delete<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
690
- regionInfo(): Promise<RegionInfo>;
691
- catalogInfo(): Promise<CatalogInfo>;
738
+ connect(): Promise<this>;
692
739
  /**
693
- * Close the client.
740
+ * Send a raw Chrome DevTools Protocol command.
694
741
  *
695
- * Axios does not require explicit teardown, but the method is kept for API symmetry.
742
+ * Returns `undefined` if called before the client has connected.
696
743
  */
697
- close(): void;
744
+ send(method: string, params?: any, sessionId?: string): Promise<any | undefined>;
698
745
  /**
699
- * String representation of the client.
746
+ * Close the CDP connection and release internal listeners.
700
747
  */
701
- toString(): string;
702
- private request;
703
- private normalizeRequestError;
704
- private getDefaultHeaders;
705
- private ensureRegionResolved;
706
- private resolveRegion;
707
- private selectCatalogRegion;
708
- private probeRegionHost;
709
- private isAllowedCatalogHost;
710
- private rewriteUrl;
748
+ close(): Promise<void>;
711
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;
712
775
 
713
776
  /**
714
777
  * Lexmount SDK error hierarchy.
@@ -775,6 +838,6 @@ declare class TimeoutError extends LexmountError {
775
838
  /**
776
839
  * Lexmount Node.js SDK.
777
840
  */
778
- declare const VERSION = "0.5.4";
841
+ declare const VERSION = "0.5.5";
779
842
 
780
- 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 };