@maxzima/wa-communicator 1.0.30 → 1.0.32

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.
@@ -29,7 +29,7 @@ export class Communicator {
29
29
  if (index > 0) {
30
30
  separator = '&';
31
31
  }
32
- queryParamsString = `${queryParamsString}${separator}${queryParam[0]}=${queryParam[1]}`;
32
+ queryParamsString = `${queryParamsString}${separator}${queryParam[0]}=${encodeURIComponent(queryParam[1])}`;
33
33
  });
34
34
  return queryParamsString;
35
35
  };
@@ -114,7 +114,7 @@ export class Communicator {
114
114
  mobile: data.phoneNumber,
115
115
  };
116
116
  const url = `${this.props.clientAuthSSEBaseUrl}${"sse/app-auth"}`;
117
- this.sseAuth = new EventSource(`${url}?${this.processingQueryParams(params)}`);
117
+ this.sseAuth = new EventSource(new URL(`${url}?${this.processingQueryParams(params)}`));
118
118
  if (this.sseAuth) {
119
119
  this.sseAuth.addEventListener('open', (event) => {
120
120
  if (this.props.env !== 'prod') {
@@ -84,13 +84,13 @@ declare type TSetupSSERequestData = {
84
84
  onMessage: (responseData: TSSEResponseData) => void;
85
85
  };
86
86
  declare type TSSEResponseData = {
87
- otp?: string;
88
- decline_reason?: string;
89
- message?: string;
90
- error_code?: number;
91
- error_text?: string;
92
- error_context?: {
93
- next_attempts_after?: string;
87
+ success: boolean;
88
+ payload: {
89
+ otp?: string;
90
+ };
91
+ error?: {
92
+ code: number;
93
+ message: string;
94
94
  };
95
95
  };
96
96
  declare type TSetupChallengeResponse = {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.30",
2
+ "version": "1.0.32",
3
3
  "name": "@maxzima/wa-communicator",
4
4
  "description": "",
5
5
  "author": "Noname",
@@ -117,8 +117,7 @@ export class Communicator {
117
117
  mobile: data.phoneNumber,
118
118
  }
119
119
  const url = `${this.props.clientAuthSSEBaseUrl}${CommunicatorAuthAPIEndpointEnum.SSE_AUTH}`;
120
- this.sseAuth = new EventSource(`${url}?${this.processingQueryParams(params)}`);
121
-
120
+ this.sseAuth = new EventSource(new URL(`${url}?${this.processingQueryParams(params)}`));
122
121
  if (this.sseAuth) {
123
122
  this.sseAuth.addEventListener('open', (event: MessageEvent) => {
124
123
  if (this.props.env !== 'prod') {
@@ -152,7 +151,7 @@ export class Communicator {
152
151
  }
153
152
 
154
153
  public closeSSEAuth() {
155
- if (this.sseAuth) { // && this.sseAuth.readyState === EventSource.OPEN
154
+ if (this.sseAuth) {
156
155
  this.sseAuth.close();
157
156
  this.sseAuth = null;
158
157
  }
@@ -323,7 +322,7 @@ export class Communicator {
323
322
  separator = '&';
324
323
  }
325
324
 
326
- queryParamsString = `${queryParamsString}${separator}${queryParam[0]}=${queryParam[1]}`;
325
+ queryParamsString = `${queryParamsString}${separator}${queryParam[0]}=${encodeURIComponent(queryParam[1])}`;
327
326
  });
328
327
 
329
328
  return queryParamsString;
@@ -105,14 +105,14 @@ type TSetupSSERequestData = {
105
105
  }
106
106
 
107
107
  type TSSEResponseData = {
108
- otp?: string,
109
- decline_reason?: string,
110
- message?: string,
111
- error_code?: number,
112
- error_text?: string,
113
- error_context?: {
114
- next_attempts_after?: string,
115
- }
108
+ success: boolean;
109
+ payload: {
110
+ otp?: string,
111
+ },
112
+ error?: {
113
+ code: number;
114
+ message: string;
115
+ };
116
116
  }
117
117
 
118
118
  type TSetupChallengeResponse = {