@tiledesk/tiledesk-whatsapp-connector 0.1.60 → 0.1.61

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.61",
4
4
  "description": "Tiledesk Whatsapp connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -214,6 +214,13 @@
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>Bug fixes and performance improvements</p>
220
+ </div>
221
+ <p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.61</b></p>
222
+ </div>
223
+
217
224
  <div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
218
225
  <div>
219
226
  <p>Bug fixes and performance improvements</p>
@@ -238,13 +245,6 @@
238
245
  <p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.55</b></p>
239
246
  </div>
240
247
 
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
248
  <hr style="margin-top: 50px; margin-bottom: 20px">
249
249
 
250
250
  <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,22 @@ class TiledeskChannel {
269
273
  }
270
274
  })
271
275
  }
276
+
277
+ fixToken(token) {
278
+
279
+ let index = token.lastIndexOf("JWT ");
280
+ let new_token = token.substring(index + 4);
281
+
282
+ return 'JWT ' + new_token;
283
+
284
+ /*
285
+ if (token.startsWith('JWT ')) {
286
+ return token
287
+ } else {
288
+ return 'JWT ' + token
289
+ }
290
+ */
291
+ }
272
292
 
273
293
  }
274
294