@experteam-mx/ngx-services 20.9.10 → 20.9.11

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/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as i0 from '@angular/core';
2
2
  import { InjectionToken, ModuleWithProviders, EnvironmentProviders } from '@angular/core';
3
3
  import { HttpResponse, HttpRequest, HttpHandlerFn, HttpEvent, HttpParams, HttpHeaders } from '@angular/common/http';
4
4
  import { Observable, BehaviorSubject } from 'rxjs';
5
- import { Channel } from 'pusher-js';
5
+ import Pusher, { Channel } from 'pusher-js';
6
6
 
7
7
  /**
8
8
  * Opt-in HTTP cache rule. First matching pattern against `req.urlWithParams` wins.
@@ -28,7 +28,6 @@ type HttpCacheRoute = {
28
28
  * - authCookie: The name of the authentication cookie used for user sessions.
29
29
  * - cacheRoutes: Optional. Opt-in HTTP cache rules; first matching pattern wins.
30
30
  * - printUrl: Optional. The URL used for generating or downloading printable documents.
31
- * - secretKey: A secret key used for authentication or other secure operations.
32
31
  */
33
32
  type Environment = {
34
33
  apiAuditsUrl?: string;
@@ -63,9 +62,7 @@ type Environment = {
63
62
  authCookie?: string;
64
63
  cacheRoutes?: HttpCacheRoute[];
65
64
  printUrl?: string;
66
- secretKey?: string;
67
65
  sockets?: {
68
- app_key: string;
69
66
  debug?: boolean;
70
67
  port: number;
71
68
  url: string;
@@ -9854,8 +9851,35 @@ declare enum PaymentTypeCode {
9854
9851
 
9855
9852
  declare class WebSocketsService {
9856
9853
  private pusher;
9854
+ private appKey;
9855
+ private connectPromise;
9857
9856
  private environments;
9858
- constructor();
9857
+ private getAuthToken;
9858
+ private readonly channelAuthHeaders;
9859
+ /**
9860
+ * Stores the Pusher/Soketi application key without opening a connection.
9861
+ * The first `channelSub` / `eventBind` opens Pusher via `ensureConnected`.
9862
+ *
9863
+ * @param {string} appKey - The Pusher/Soketi application key.
9864
+ */
9865
+ setAppKey(appKey: string): void;
9866
+ /**
9867
+ * Registers a live token provider used when authorizing private/presence channels.
9868
+ * The provider is called at subscribe/authorize time; the token is not snapshotted here.
9869
+ *
9870
+ * @param {() => string | null} getToken - Returns the current session token, or null.
9871
+ */
9872
+ setAuthTokenProvider(getToken: () => string | null): void;
9873
+ /**
9874
+ * Connects to Pusher using the given app key and env `sockets` url/port/debug.
9875
+ * No-ops if already connected with the same key; reconnects if the key changed.
9876
+ * Resolves false when `sockets` is missing from the environment.
9877
+ * Apps should store the key with `setAppKey` and let subscribe open the client.
9878
+ *
9879
+ * @param {string} appKey - The Pusher/Soketi application key.
9880
+ * @return {Promise<Pusher | false>} The Pusher instance, or false when sockets are not configured.
9881
+ */
9882
+ connect(appKey: string): Promise<Pusher | false>;
9859
9883
  /**
9860
9884
  * Publishes an event to the specified channel with the given data.
9861
9885
  *
@@ -9867,11 +9891,11 @@ declare class WebSocketsService {
9867
9891
  */
9868
9892
  pub<T>(channel: Channel, eventName: string, data: T): Promise<boolean>;
9869
9893
  /**
9870
- * Subscribes to a specified channel, retrying multiple times upon failure.
9894
+ * Subscribes to a specified channel and resolves when Pusher reports success.
9871
9895
  *
9872
9896
  * @param {string} channelName - The name of the channel to be subscribed to.
9873
9897
  * @return {Promise<Channel>} A promise that resolves to the subscribed channel object if successful.
9874
- * @throws {Error} If the subscription fails after the maximum number of retry attempts.
9898
+ * @throws {Error} If the subscription fails.
9875
9899
  */
9876
9900
  channelSub(channelName: string): Promise<Channel>;
9877
9901
  /**
@@ -9892,16 +9916,21 @@ declare class WebSocketsService {
9892
9916
  * @return {Observable<T>} An observable that emits data from the unbound event callback.
9893
9917
  */
9894
9918
  eventUnbind<T>(channel: Channel, event: string): Observable<unknown>;
9895
- private connect;
9896
- private wait;
9919
+ /**
9920
+ * Unsubscribes from a channel by name.
9921
+ *
9922
+ * @param {string} channelName - The channel name previously passed to subscribe.
9923
+ */
9924
+ unsubscribe(channelName: string): void;
9925
+ private ensureConnected;
9926
+ private refreshChannelAuthHeader;
9897
9927
  static ɵfac: i0.ɵɵFactoryDeclaration<WebSocketsService, never>;
9898
9928
  static ɵprov: i0.ɵɵInjectableDeclaration<WebSocketsService>;
9899
9929
  }
9900
9930
 
9901
9931
  declare class CryptoService {
9902
- private environments;
9903
- encryptAES(plaintext: string): Promise<string>;
9904
- decryptAES(payload: string): Promise<string>;
9932
+ encryptAES(plaintext: string, secretKey: string): Promise<string>;
9933
+ decryptAES(payload: string, secretKey: string): Promise<string>;
9905
9934
  private loadKey;
9906
9935
  private uint8ArrayToBase64;
9907
9936
  private base64ToUint8Array;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@experteam-mx/ngx-services",
3
- "version": "20.9.10",
3
+ "version": "20.9.11",
4
4
  "description": "Angular common services for Experteam apps",
5
5
  "author": "Experteam Cía. Ltda.",
6
6
  "keywords": [