@reactoo/watchtogether-sdk-js 2.7.42-beta.2 → 2.7.42-beta.3

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": "@reactoo/watchtogether-sdk-js",
3
- "version": "2.7.42-beta.2",
3
+ "version": "2.7.42-beta.3",
4
4
  "description": "Javascript SDK for Reactoo",
5
5
  "main": "src/index.js",
6
6
  "unpkg": "dist/watchtogether-sdk.min.js",
package/src/models/iot.js CHANGED
@@ -16,24 +16,29 @@ let iot = function () {
16
16
  this.__privates.iot.log('Updating Credentials...');
17
17
  interruptCount = 0;
18
18
  isReconnecting = true;
19
- return this.iot.getCredentials()
20
- .then(response => this.__privates.iot.updateWebSocketCredentials(
21
- response.data.credentials.accessKeyId,
22
- response.data.credentials.secretAccessKey,
23
- response.data.credentials.sessionToken,
24
- response.data.credentials.expiration
25
- ))
26
- .then(_ => {
27
- isReconnecting = false;
28
- })
29
- .catch(error => {
30
- isReconnecting = false;
31
- this.__privates.iot.log('Failed to update credentials:', error);
32
- throw error;
33
- })
34
- .finally(() => {
35
- isReconnecting = false;
36
- });
19
+ return new Promise((resolve, reject) => {
20
+ const timeoutId = setTimeout(() => {
21
+ reject(new Error('Updating Credentials Timeout...'));
22
+ }, 15000); // 15 seconds timeout is plentyful
23
+ this.iot.getCredentials()
24
+ .then(response => this.__privates.iot.updateWebSocketCredentials(
25
+ response.data.credentials.accessKeyId,
26
+ response.data.credentials.secretAccessKey,
27
+ response.data.credentials.sessionToken,
28
+ response.data.credentials.expiration
29
+ ))
30
+ .then(() => {
31
+ clearTimeout(timeoutId);
32
+ resolve();
33
+ })
34
+ .catch(error => {
35
+ clearTimeout(timeoutId);
36
+ this.__privates.iot.log('Failed to update credentials:', error);
37
+ reject(error);
38
+ })
39
+ }).finally(() => {
40
+ isReconnecting = false;
41
+ });
37
42
  },
38
43
 
39
44
  getCredentials: () => {