vtb-appit 0.1.25 → 0.1.27

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.
@@ -12,7 +12,7 @@ class AppitBaseTransformer {
12
12
  this.vtbMessages = [];
13
13
 
14
14
  try {
15
- this.token = fs.readFileSync(pth.join(__dirname, '../../assets/token.jwt'), {encoding: 'utf8' });
15
+ this.token = fs.readFileSync(pth.join(__dirname, '../../assets/token.jwt'), {encoding: 'utf8' }).trim();
16
16
  } catch(e) {
17
17
  this.token = false;
18
18
  }
@@ -186,11 +186,10 @@ class AppitBaseTransformer {
186
186
 
187
187
  async tsGetDocuments()
188
188
  {
189
- const jwt = await this.fetchTSJWT();
190
- const tokenDecodablePart = jwt.split('.')[1];
189
+ const tokenDecodablePart = this.token.split('.')[1];
191
190
  const decoded = JSON.parse(Buffer.from(tokenDecodablePart, 'base64').toString());
192
191
  const endPath = '/documentdata/';
193
- let documents = await this.tsFetchDocuments(jwt, decoded, endPath);
192
+ let documents = await this.tsFetchDocuments(this.token, decoded, endPath);
194
193
 
195
194
  let baseUrl = (decoded.hasOwnProperty('https://visualtourbuilder.com/app_metadata')) ?
196
195
  decoded['https://visualtourbuilder.com/app_metadata'].baseUrl :
@@ -201,7 +200,7 @@ class AppitBaseTransformer {
201
200
  promises.push(new Promise(resolve => {
202
201
  const req = https.request({
203
202
  headers: {
204
- 'Authorization': jwt
203
+ 'Authorization': this.token
205
204
  },
206
205
  hostname: baseUrl.replace('https://', '').replace(/.com\/.*/, '.com').replace(/.app\/.*/, '.app'),
207
206
  path: baseUrl.replace(/.*?.app/, '').replace(/.*?.com/, '') + endPath + document.id,
@@ -264,14 +263,7 @@ class AppitBaseTransformer {
264
263
  async tsGetData()
265
264
  {
266
265
  return new Promise(async (resolve, reject) => {
267
- let jwt = null
268
- try {
269
- jwt = await this.fetchTSJWT()
270
- } catch(e) {
271
- return reject(e);
272
- }
273
-
274
- const tokenDecodablePart = jwt.split('.')[1];
266
+ const tokenDecodablePart = this.token.split('.')[1];
275
267
  const decoded = JSON.parse(Buffer.from(tokenDecodablePart, 'base64').toString());
276
268
  const endPath = '/dynamicdata/';
277
269
 
@@ -281,7 +273,7 @@ class AppitBaseTransformer {
281
273
 
282
274
  let req = https.request({
283
275
  headers: {
284
- 'Authorization': jwt
276
+ 'Authorization': this.token
285
277
  },
286
278
  hostname: baseUrl.replace('https://', '').replace(/.com\/.*/, '.com').replace(/.app\/.*/, '.app'),
287
279
  path: baseUrl.replace(/.*?.app/, '').replace(/.*?.com/, '') + endPath,
@@ -304,51 +296,6 @@ class AppitBaseTransformer {
304
296
  })
305
297
  }
306
298
 
307
- fetchTSJWT()
308
- {
309
- return new Promise((resolve, reject) => {
310
- const data = JSON.stringify({
311
- query: `{
312
- tsJWT {
313
- jwt
314
- }
315
- }`,
316
- });
317
-
318
- const options = {
319
- hostname: 'vtb-global-vtb-gateway-z7stqwbrxa-ew.a.run.app',
320
- path: '/graphql',
321
- port: 443,
322
- method: 'POST',
323
- headers: {
324
- 'Content-Type': 'application/json',
325
- 'Content-Length': data.length,
326
- 'Authorization': `Bearer ${this.token}`,
327
- 'User-Agent': 'Node',
328
- },
329
- };
330
-
331
- const req = https.request(options, (res) => {
332
- let data = '';
333
-
334
- res.on('data', (d) => {
335
- data += d;
336
- });
337
-
338
- res.on('error', (e) => {
339
- reject(e);
340
- });
341
-
342
- res.on('end', () => {
343
- resolve(JSON.parse(data).data.tsJWT.jwt);
344
- });
345
- });
346
-
347
- req.write(data);
348
- req.end();
349
- })
350
- }
351
-
352
299
  async mediaToBase64(media)
353
300
  {
354
301
  let promises = [];
package/appit-notify.js CHANGED
@@ -55,7 +55,7 @@ class AppitNotify {
55
55
  try {
56
56
  const response = await axios({
57
57
  method: 'post',
58
- url: `https://vtb-global-vtb-gateway-z7stqwbrxa-ew.a.run.app/graphql`,
58
+ url: `https://vtb-gateway-legacy.visualtourbuilder.com/graphql`,
59
59
  data: JSON.stringify({ query }),
60
60
  headers: {
61
61
  Authorization: `Bearer ${token}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vtb-appit",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {},