@tellescope/sdk 1.74.3 → 1.75.0

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/src/session.ts CHANGED
@@ -366,62 +366,59 @@ export class Session {
366
366
  }
367
367
 
368
368
  authenticate_socket = () => {
369
- if (this.userInfo.requiresMFA) return
370
- if (this.lastSocketConnection + 2500 > Date.now()) return
371
- this.lastSocketConnection = Date.now()
369
+ // if (this.userInfo.requiresMFA) return
370
+ // if (this.lastSocketConnection + 2500 > Date.now()) return
371
+ // this.lastSocketConnection = Date.now()
372
372
 
373
- if (this.enableSocketLogging) console.log('authenticating socket')
373
+ // if (this.enableSocketLogging) console.log('authenticating socket')
374
374
 
375
- this.initialize_socket()
376
- if (!this.socket) {
377
- console.warn("failed to initialize_socket")
378
- return
379
- }
375
+ // this.initialize_socket()
376
+ // if (!this.socket) {
377
+ // console.warn("failed to initialize_socket")
378
+ // return
379
+ // }
380
380
 
381
- this.socket.removeAllListeners()
382
-
383
- this.socket.on('ping', () => {
384
- if (this.enableSocketLogging) { this.socket_log("pong") }
385
- })
386
-
387
- // handle events which are sent when handlers may be off
388
- this.socket?.onAny((e, v)=> {
389
- if (this.handlers[e] && v) {
390
- this.handlers[e](v)
391
- } else if (Array.isArray(v)) {
392
- if (!this.loadedSocketEvents[e]) {
393
- this.loadedSocketEvents[e] = []
394
- }
395
- this.loadedSocketEvents[e].push(...v)
396
- }
397
- })
398
-
399
- this.socket.on('connect', () => {
400
- if (this.enableSocketLogging) { this.socket_log(`connect, authenticated=${this.socketAuthenticated}`) }
401
- })
402
-
403
- this.socket.on('disconnect', () => {
404
- this.socketAuthenticated = false
405
- if (this.enableSocketLogging) { this.socket_log("disconnect") }
406
- })
407
- this.socket.on('authenticated', () => {
408
- this.socketAuthenticated = true
409
- // if (this.enableSocketLogging) {
410
- this.socket_log("authenticated")
411
- // }
412
- })
413
- this.socket.on('error', (error: any) => {
414
- console.warn('socket error: ', error)
415
- })
416
- this.socket.on('connect_error', (error: any) => {
417
- console.warn('connect_error: ', error)
418
- // setTimeout(() => {
419
- // this.socket?.connect()
420
- // })
421
- })
422
-
423
- // no longer necessary
424
- // this.socket.emit('authenticate', this.authToken)
381
+ // this.socket.removeAllListeners()
382
+
383
+ // this.socket.on('ping', () => {
384
+ // if (this.enableSocketLogging) { this.socket_log("pong") }
385
+ // })
386
+
387
+ // // handle events which are sent when handlers may be off
388
+ // this.socket?.onAny((e, v)=> {
389
+ // if (this.handlers[e] && v) {
390
+ // this.handlers[e](v)
391
+ // } else if (Array.isArray(v)) {
392
+ // if (!this.loadedSocketEvents[e]) {
393
+ // this.loadedSocketEvents[e] = []
394
+ // }
395
+ // this.loadedSocketEvents[e].push(...v)
396
+ // }
397
+ // })
398
+
399
+ // this.socket.on('connect', () => {
400
+ // if (this.enableSocketLogging) { this.socket_log(`connect, authenticated=${this.socketAuthenticated}`) }
401
+ // })
402
+
403
+ // this.socket.on('disconnect', () => {
404
+ // this.socketAuthenticated = false
405
+ // if (this.enableSocketLogging) { this.socket_log("disconnect") }
406
+ // })
407
+ // this.socket.on('authenticated', () => {
408
+ // this.socketAuthenticated = true
409
+ // // if (this.enableSocketLogging) {
410
+ // this.socket_log("authenticated")
411
+ // // }
412
+ // })
413
+ // this.socket.on('error', (error: any) => {
414
+ // console.warn('socket error: ', error)
415
+ // })
416
+ // this.socket.on('connect_error', (error: any) => {
417
+ // console.warn('connect_error: ', error)
418
+ // // setTimeout(() => {
419
+ // // this.socket?.connect()
420
+ // // })
421
+ // })
425
422
  }
426
423
 
427
424
  /** @deprecated */
@@ -5850,6 +5850,7 @@ export const alternate_phones_tests = async () => {
5850
5850
 
5851
5851
  const NO_TEST = () => {}
5852
5852
  const tests: { [K in keyof ClientModelForName]: () => void } = {
5853
+ enduser_encounters: NO_TEST,
5853
5854
  enduser_orders: NO_TEST,
5854
5855
  ticket_queues: NO_TEST,
5855
5856
  phone_trees: NO_TEST,
@@ -6618,6 +6619,33 @@ const test_send_with_template = async () => {
6618
6619
  ])
6619
6620
  }
6620
6621
 
6622
+ const delete_user_tests = async () => {
6623
+ // delete if previous test failed and user still exists
6624
+ const existing = await sdk.api.users.getSome({ filter: { email: 'deleteme@tellescope.com'}})
6625
+ if (existing[0]?.email === 'deleteme@tellescope.com') {
6626
+ await sdk.api.users.deleteOne(existing[0].id)
6627
+ }
6628
+
6629
+ const u = await sdk.api.users.createOne({ email: 'deleteme@tellescope.com', verifiedEmail: true })
6630
+
6631
+ const { authToken } = await sdk.api.users.generate_auth_token({ id: u.id })
6632
+ const createdUserSDK = new Session({ host, authToken })
6633
+
6634
+ await async_test(
6635
+ "Authenticated",
6636
+ createdUserSDK.test_authenticated,
6637
+ passOnAnyResult
6638
+ )
6639
+
6640
+ await sdk.api.users.deleteOne(u.id)
6641
+ await wait(undefined, 250)
6642
+ await async_test(
6643
+ "De-authenticated after deletion",
6644
+ createdUserSDK.test_authenticated,
6645
+ handleAnyError
6646
+ )
6647
+ }
6648
+
6621
6649
  (async () => {
6622
6650
  log_header("API")
6623
6651
 
@@ -6660,6 +6688,7 @@ const test_send_with_template = async () => {
6660
6688
  await mfa_tests()
6661
6689
  await setup_tests()
6662
6690
  await multi_tenant_tests() // should come right after setup tests
6691
+ await delete_user_tests()
6663
6692
  // await test_send_with_template()
6664
6693
  await self_serve_appointment_booking_tests()
6665
6694
  await bulk_read_tests()
Binary file