@tiledesk/tiledesk-whatsapp-connector 0.1.60 → 0.1.62

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-whatsapp-connector",
3
- "version": "0.1.60",
3
+ "version": "0.1.62",
4
4
  "description": "Tiledesk Whatsapp connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -214,6 +214,20 @@
214
214
 
215
215
  <p style="font-size: 18px;"><b>What's new?</b></p>
216
216
 
217
+ <div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
218
+ <div>
219
+ <p>Fixed bug: custom authentication error</p>
220
+ </div>
221
+ <p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.62</b></p>
222
+ </div>
223
+
224
+ <div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
225
+ <div>
226
+ <p>Bug fixes and performance improvements</p>
227
+ </div>
228
+ <p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.61</b></p>
229
+ </div>
230
+
217
231
  <div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
218
232
  <div>
219
233
  <p>Bug fixes and performance improvements</p>
@@ -238,13 +252,6 @@
238
252
  <p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.55</b></p>
239
253
  </div>
240
254
 
241
- <div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
242
- <div>
243
- <p>Bug fixes and performance improvements</p>
244
- </div>
245
- <p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.53</b></p>
246
- </div>
247
-
248
255
  <hr style="margin-top: 50px; margin-bottom: 20px">
249
256
 
250
257
  <script>
@@ -81,6 +81,7 @@ class TiledeskChannel {
81
81
  }
82
82
 
83
83
  var customToken = jwt.sign(payload, this.settings.secret);
84
+ console.log("\n\ncustomToken: ", customToken)
84
85
 
85
86
  return await axios({
86
87
  url: this.API_URL + "/auth/signinWithCustomToken",
@@ -93,7 +94,8 @@ class TiledeskChannel {
93
94
  }).then((response) => {
94
95
 
95
96
  let token = response.data.token;
96
-
97
+ token = this.fixToken(token);
98
+
97
99
  return axios({
98
100
  url: this.API_URL + `/${this.settings.project_id}/requests/me?channel=${messageInfo.channel}`,
99
101
  headers: {
@@ -198,7 +200,9 @@ class TiledeskChannel {
198
200
  data: {},
199
201
  method: 'POST'
200
202
  }).then((response) => {
203
+
201
204
  let token = response.data.token;
205
+ token = this.fixToken(token);
202
206
 
203
207
  return axios({
204
208
  url: this.API_URL + `/${this.settings.project_id}/requests/${new_request_id}/messages`,
@@ -269,6 +273,18 @@ class TiledeskChannel {
269
273
  }
270
274
  })
271
275
  }
276
+
277
+ fixToken(token) {
278
+
279
+ let index = token.lastIndexOf("JWT ");
280
+ if (index != -1) {
281
+ let new_token = token.substring(index + 4);
282
+ return 'JWT ' + new_token;
283
+ } else {
284
+ return 'JWT ' + token;
285
+ }
286
+
287
+ }
272
288
 
273
289
  }
274
290