@tellescope/sdk 1.4.24 → 1.4.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.
package/src/session.ts CHANGED
@@ -273,7 +273,13 @@ export class Session {
273
273
  }
274
274
  return
275
275
  }
276
- this.socket = io(`${this.host}/${this.userInfo.businessId || this.businessId}`, { transports: ['websocket'] }); // supporting polling requires sticky session at load balancer
276
+ this.socket = io(
277
+ `${this.host}/${this.userInfo.businessId || this.businessId}`,
278
+ {
279
+ auth: { token: this.authToken },
280
+ transports: ['websocket'] // supporting polling requires sticky session at load balancer
281
+ }
282
+ );
277
283
  }
278
284
  authenticate_socket = () => {
279
285
  this.initialize_socket()
@@ -302,9 +308,11 @@ export class Session {
302
308
  // })
303
309
  })
304
310
 
305
- this.socket.emit('authenticate', this.authToken)
311
+ // no longer necessary
312
+ // this.socket.emit('authenticate', this.authToken)
306
313
  }
307
314
 
315
+ /** @deprecated */
308
316
  connectSocket = async () => {
309
317
  if (this.socketAuthenticated) return
310
318
 
@@ -317,7 +325,7 @@ export class Session {
317
325
  }
318
326
 
319
327
  if (loopCount === 10) {
320
- console.error("Failed to authenticate after 10 attempts")
328
+ console.error(`Failed to authenticate ${this.type} ${this.userInfo.id} after 10 attempts`)
321
329
  return
322
330
  }
323
331
 
@@ -616,11 +616,12 @@ const enduser_tests = async (queries=sdk.api.endusers) => {
616
616
  () => queries.updateOne(e1.id ?? '', { email: e2.email }),
617
617
  { shouldError: true, onError: () => true }
618
618
  )
619
- await async_test(
620
- `update-enduser phone conflict`,
621
- () => queries.updateOne(e1.id ?? '', { phone: e2.phone }),
622
- { shouldError: true, onError: () => true }
623
- )
619
+ // no longer restricted
620
+ // await async_test(
621
+ // `update-enduser phone conflict`,
622
+ // () => queries.updateOne(e1.id ?? '', { phone: e2.phone }),
623
+ // { shouldError: true, onError: () => true }
624
+ // )
624
625
  await async_test(
625
626
  `update-enduser email and phone conflict`,
626
627
  () => queries.updateOne(e1.id ?? '', { email: e2.email, phone: e2.phone }),
@@ -3140,56 +3141,6 @@ export const role_based_access_permissions_tests = async () => {
3140
3141
  await sdkNonAdmin.authenticate(nonAdminEmail, nonAdminPassword) // to use new role, handle logout on role change
3141
3142
  }
3142
3143
 
3143
- const example_hep_record = async () => {
3144
- await sdk.api.managed_content_records.createOne({
3145
- "title": "Squats For Days (output.title)",
3146
- "assignmentType": "Individual",
3147
- "enduserId": "tellescope_enduser_id_here",
3148
- "htmlContent": "",
3149
- "textContent": "",
3150
- "blocks": [
3151
- {
3152
- "type": "h1",
3153
- "info": {
3154
- "text": "Standing stability in partial squat with support from table/chair"
3155
- }
3156
- },
3157
- {
3158
- "type": "h2",
3159
- "info": {
3160
- "text": "Stand in front of a counter and hold onto the countertop.\nWhile maintaining your back straight and your hips above the level of your knees, slowly lower your body into a semi-squat position without leaning forward and keeping your heels in contact with the ground at all times."
3161
- }
3162
- },
3163
- {
3164
- "type": "html",
3165
- "info": {
3166
- "html": "<div>custom content synthesizing weight, repetition, frequency, duration, sets, etc.</div>"
3167
- },
3168
- },
3169
- {
3170
- "type": "image",
3171
- "info": {
3172
- "link": "https://hep.physiotec.ca/image.php?param=ZzZySkRIVXBqN2JTejF5U0cvZWtaSkk5MUdyNDYvRmQ3YkFjMm1CU2NEbm9iOENKNEs1ZXlXTXhWcXZyRWZQOERBNVBYVkpNTXlIOVlBWm5PTkVJaFE9PQ=="
3173
- }
3174
- },
3175
- {
3176
- "type": "image",
3177
- "info": {
3178
- "link": "https://hep.physiotec.ca/image.php?param=ZzZySkRIVXBqN2JTejF5U0cvZWtaSkk5MUdyNDYvRmQ3YkFjMm1CU2NEazBlY1g2TFpaYVZsa0wrT3F3aGdsMGd6dTkyVXFvNVdBOUlVUFZpcmltM0E9PQ=="
3179
- }
3180
- },
3181
- {
3182
- "type": "iframe",
3183
- "info": {
3184
- "link": "videos.sproutvideo.com/embed/a09bdeb3191ae5c428/50796be0534425e7?type=sd",
3185
- "width": 630,
3186
- "height": 354
3187
- }
3188
- }
3189
- ]
3190
- })
3191
- }
3192
-
3193
3144
  const NO_TEST = () => {}
3194
3145
  const tests: { [K in keyof ClientModelForName]: () => void } = {
3195
3146
  role_based_access_permissions: role_based_access_permissions_tests,
@@ -226,6 +226,12 @@ const endusers_tests = async (isSubscribed: boolean) => {
226
226
  'Enduser update error', 'Update enduser webhook', isSubscribed
227
227
  )
228
228
 
229
+ await sdk.api.endusers.set_password({ id: enduser.id, password: 'initialPassword' })
230
+ await check_next_webhook(
231
+ a => (a.records?.[0] as any)?.password === 'initialPassword',
232
+ 'Enduser set password error', 'Set enduser password webhook', isSubscribed
233
+ )
234
+
229
235
  // cleanup
230
236
  if (isSubscribed) {
231
237
  await sdk.api.webhooks.update({ subscriptionUpdates: {