@wazo/sdk 0.37.26 → 0.37.30

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.
Files changed (121) hide show
  1. package/README.md +98 -59
  2. package/dist/wazo-sdk.js +3 -3
  3. package/esm/__tests__/api-client.test.js +1 -1
  4. package/esm/__tests__/web-rtc-client.test.js +18 -5
  5. package/esm/api/agentd.js +1 -1
  6. package/esm/api/amid.js +1 -1
  7. package/esm/api/application.js +1 -1
  8. package/esm/api/auth.js +1 -1
  9. package/esm/api/call-logd.js +1 -1
  10. package/esm/api/calld.js +1 -1
  11. package/esm/api/chatd.js +1 -1
  12. package/esm/api/confd.js +1 -1
  13. package/esm/api/ctid-ng.js +1 -1
  14. package/esm/api/dird.js +1 -1
  15. package/esm/api/webhookd.js +1 -1
  16. package/esm/api-client.js +1 -1
  17. package/esm/checker/Checker.js +18 -5
  18. package/esm/checker/checks/aor.js +1 -1
  19. package/esm/checker/checks/api.js +1 -1
  20. package/esm/checker/checks/index.js +18 -5
  21. package/esm/checker/checks/wazo-websocket.js +1 -1
  22. package/esm/checker/checks/webrtc-transport.js +18 -5
  23. package/esm/checker/checks/webrtc.js +18 -5
  24. package/esm/domain/AdHocAPIConference.js +1 -1
  25. package/esm/domain/CallSession.js +29 -2
  26. package/esm/domain/Features.js +1 -1
  27. package/esm/domain/Phone/CTIPhone.js +30 -3
  28. package/esm/domain/Phone/WebRTCPhone.js +55 -6
  29. package/esm/domain/SFUNotAvailableError.js +9 -0
  30. package/esm/domain/__tests__/CallSession.test.js +46 -2
  31. package/esm/domain/__tests__/IndirectTransfer.test.js +29 -2
  32. package/esm/domain/__tests__/Room.test.js +29 -2
  33. package/esm/index.js +83 -10
  34. package/esm/lib/WazoSessionDescriptionHandler.js +9 -4
  35. package/esm/service/CallApi.js +1 -1
  36. package/esm/service/IssueReporter.js +1 -1
  37. package/esm/service/__tests__/IssueReporter.test.js +1 -1
  38. package/esm/service/getApiClient.js +1 -1
  39. package/esm/simple/Auth.js +82 -10
  40. package/esm/simple/Configuration.js +82 -10
  41. package/esm/simple/Directory.js +1 -1
  42. package/esm/simple/Phone.js +82 -10
  43. package/esm/simple/Websocket.js +1 -1
  44. package/esm/simple/index.js +82 -10
  45. package/esm/simple/room/LocalParticipant.js +82 -10
  46. package/esm/simple/room/Participant.js +82 -10
  47. package/esm/simple/room/RemoteParticipant.js +82 -10
  48. package/esm/simple/room/Room.js +82 -10
  49. package/esm/simple/room/SipRoom.js +82 -10
  50. package/esm/simple/room/Stream.js +82 -10
  51. package/esm/simple/room/__tests__/RemoteParticipant.test.js +82 -10
  52. package/esm/simple/utils.js +82 -10
  53. package/esm/utils/__tests__/api-requester.test.js +1 -1
  54. package/esm/utils/api-requester.js +1 -1
  55. package/esm/web-rtc-client.js +18 -5
  56. package/esm/websocket-client.js +1 -1
  57. package/lib/__tests__/api-client.test.js +1 -1
  58. package/lib/__tests__/web-rtc-client.test.js +18 -5
  59. package/lib/api/agentd.js +1 -1
  60. package/lib/api/amid.js +1 -1
  61. package/lib/api/application.js +1 -1
  62. package/lib/api/auth.js +1 -1
  63. package/lib/api/call-logd.js +1 -1
  64. package/lib/api/calld.js +1 -1
  65. package/lib/api/chatd.js +1 -1
  66. package/lib/api/confd.js +1 -1
  67. package/lib/api/ctid-ng.js +1 -1
  68. package/lib/api/dird.js +1 -1
  69. package/lib/api/webhookd.js +1 -1
  70. package/lib/api-client.js +1 -1
  71. package/lib/checker/Checker.js +18 -5
  72. package/lib/checker/checks/aor.js +1 -1
  73. package/lib/checker/checks/api.js +1 -1
  74. package/lib/checker/checks/index.js +18 -5
  75. package/lib/checker/checks/wazo-websocket.js +1 -1
  76. package/lib/checker/checks/webrtc-transport.js +18 -5
  77. package/lib/checker/checks/webrtc.js +18 -5
  78. package/lib/domain/AdHocAPIConference.js +1 -1
  79. package/lib/domain/CallSession.js +29 -2
  80. package/lib/domain/Features.js +1 -1
  81. package/lib/domain/Phone/CTIPhone.js +30 -3
  82. package/lib/domain/Phone/WebRTCPhone.js +55 -5
  83. package/lib/domain/SFUNotAvailableError.js +11 -0
  84. package/lib/domain/__tests__/CallSession.test.js +46 -2
  85. package/lib/domain/__tests__/IndirectTransfer.test.js +29 -2
  86. package/lib/domain/__tests__/Room.test.js +29 -2
  87. package/lib/index.js +83 -10
  88. package/lib/lib/WazoSessionDescriptionHandler.js +9 -4
  89. package/lib/service/CallApi.js +1 -1
  90. package/lib/service/IssueReporter.js +1 -1
  91. package/lib/service/__tests__/IssueReporter.test.js +1 -1
  92. package/lib/service/getApiClient.js +1 -1
  93. package/lib/simple/Auth.js +82 -10
  94. package/lib/simple/Configuration.js +82 -10
  95. package/lib/simple/Directory.js +1 -1
  96. package/lib/simple/Phone.js +82 -10
  97. package/lib/simple/Websocket.js +1 -1
  98. package/lib/simple/index.js +82 -10
  99. package/lib/simple/room/LocalParticipant.js +82 -10
  100. package/lib/simple/room/Participant.js +82 -10
  101. package/lib/simple/room/RemoteParticipant.js +82 -10
  102. package/lib/simple/room/Room.js +82 -10
  103. package/lib/simple/room/SipRoom.js +82 -10
  104. package/lib/simple/room/Stream.js +82 -10
  105. package/lib/simple/room/__tests__/RemoteParticipant.test.js +82 -10
  106. package/lib/simple/utils.js +82 -10
  107. package/lib/utils/__tests__/api-requester.test.js +1 -1
  108. package/lib/utils/api-requester.js +1 -1
  109. package/lib/web-rtc-client.js +18 -5
  110. package/lib/websocket-client.js +1 -1
  111. package/package.json +1 -1
  112. package/src/domain/CallSession.js +32 -4
  113. package/src/domain/Phone/WebRTCPhone.js +24 -2
  114. package/src/domain/SFUNotAvailableError.js +7 -0
  115. package/src/domain/__tests__/CallSession.test.js +17 -0
  116. package/src/index.js +2 -0
  117. package/src/lib/WazoSessionDescriptionHandler.js +8 -3
  118. package/src/simple/Phone.js +2 -1
  119. package/src/simple/index.js +2 -0
  120. package/src/utils/api-requester.js +1 -1
  121. package/src/web-rtc-client.js +9 -1
package/lib/index.js CHANGED
@@ -475,7 +475,7 @@ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
475
475
 
476
476
  // Use a function here to be able to mock it in tests
477
477
  const realFetch = () => {
478
- if (typeof document !== 'undefined') {
478
+ if (typeof document !== 'undefined' && window.fetch) {
479
479
  // Browser
480
480
  return window.fetch;
481
481
  }
@@ -3260,13 +3260,16 @@ var updateFrom = (instance , from ) => {
3260
3260
 
3261
3261
 
3262
3262
 
3263
+
3263
3264
 
3264
3265
 
3265
3266
 
3266
3267
 
3267
3268
 
3269
+
3268
3270
 
3269
3271
 
3272
+
3270
3273
 
3271
3274
 
3272
3275
 
@@ -3283,6 +3286,7 @@ var updateFrom = (instance , from ) => {
3283
3286
 
3284
3287
 
3285
3288
 
3289
+
3286
3290
 
3287
3291
 
3288
3292
  class CallSession {
@@ -3302,10 +3306,14 @@ class CallSession {
3302
3306
 
3303
3307
 
3304
3308
 
3305
-
3309
+
3310
+
3311
+ // = creationTime
3306
3312
 
3307
3313
 
3308
3314
 
3315
+
3316
+
3309
3317
 
3310
3318
 
3311
3319
 
@@ -3341,6 +3349,8 @@ class CallSession {
3341
3349
 
3342
3350
 
3343
3351
 
3352
+
3353
+
3344
3354
 
3345
3355
  constructor({
3346
3356
  answered,
@@ -3354,6 +3364,8 @@ class CallSession {
3354
3364
  paused,
3355
3365
  ringing,
3356
3366
  startTime,
3367
+ creationTime,
3368
+ endTime,
3357
3369
  cameraEnabled,
3358
3370
  dialedExtension,
3359
3371
  sipCallId,
@@ -3366,12 +3378,16 @@ class CallSession {
3366
3378
  recording,
3367
3379
  recordingPaused,
3368
3380
  videoRemotelyDowngraded,
3381
+ sipSession,
3382
+ answerTime,
3369
3383
  } ) {
3370
3384
  this.callId = callId;
3371
3385
  this.sipCallId = sipCallId;
3372
3386
  this.displayName = displayName;
3373
3387
  this.number = number;
3388
+ this.creationTime = creationTime;
3374
3389
  this.startTime = startTime;
3390
+ this.endTime = endTime;
3375
3391
  this.isCaller = isCaller;
3376
3392
  this.answered = answered;
3377
3393
  this.answeredBySystem = answeredBySystem;
@@ -3390,6 +3406,8 @@ class CallSession {
3390
3406
  this.recording = recording || false;
3391
3407
  this.recordingPaused = recordingPaused || false;
3392
3408
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3409
+ this.sipSession = sipSession;
3410
+ this.answerTime = answerTime || this.answerTime;
3393
3411
 
3394
3412
  // Useful to compare instead of instanceof with minified code
3395
3413
  this.type = 'CallSession';
@@ -3420,7 +3438,7 @@ class CallSession {
3420
3438
  }
3421
3439
 
3422
3440
  answer() {
3423
- this.answered = true;
3441
+ this.answerTime = new Date();
3424
3442
  }
3425
3443
 
3426
3444
  systemAnswer() {
@@ -3576,6 +3594,15 @@ class CallSession {
3576
3594
  return newFrom(callSession, CallSession);
3577
3595
  }
3578
3596
 
3597
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
3598
+ set answered(value ) {
3599
+ this.answerTime = value ? new Date() : null;
3600
+ }
3601
+
3602
+ get answered() {
3603
+ return !!this.answerTime;
3604
+ }
3605
+
3579
3606
  static parseCall(call ) {
3580
3607
  return new CallSession({
3581
3608
  callId: call.id,
@@ -5635,11 +5662,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5635
5662
 
5636
5663
  // $FlowFixMe
5637
5664
  setRemoteSessionDescription(sessionDescription ) {
5638
- const result = super.setRemoteSessionDescription(sessionDescription);
5665
+ try {
5666
+ const result = super.setRemoteSessionDescription(sessionDescription);
5639
5667
 
5640
- this.eventEmitter.emit('setDescription', sessionDescription);
5668
+ this.eventEmitter.emit('setDescription', sessionDescription);
5641
5669
 
5642
- return result;
5670
+ return result;
5671
+ } catch (error) {
5672
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5673
+ throw error;
5674
+ }
5643
5675
  }
5644
5676
 
5645
5677
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -6178,6 +6210,7 @@ const MAX_REGISTER_TRIES = 10;
6178
6210
 
6179
6211
 
6180
6212
 
6213
+
6181
6214
 
6182
6215
 
6183
6216
 
@@ -7794,6 +7827,13 @@ class WebRTCClient extends Emitter {
7794
7827
  }
7795
7828
 
7796
7829
  _createWebRTCConfiguration(configOverrides = {}) {
7830
+ let { host } = this.config;
7831
+ let port = this.config.port || 443;
7832
+
7833
+ if (this.config.websocketSip) {
7834
+ [host, port = 443] = this.config.websocketSip.split(':');
7835
+ }
7836
+
7797
7837
  const config = {
7798
7838
  authorizationUsername: this.config.authorizationUser,
7799
7839
  authorizationPassword: this.config.password,
@@ -7829,7 +7869,7 @@ class WebRTCClient extends Emitter {
7829
7869
  },
7830
7870
  transportOptions: {
7831
7871
  traceSip: configOverrides.traceSip || false,
7832
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7872
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
7833
7873
  },
7834
7874
  sessionDescriptionHandlerFactoryOptions: {
7835
7875
  modifiers: [replaceLocalIpModifier],
@@ -8787,6 +8827,14 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
8787
8827
  'default': WebSocketClient
8788
8828
  });
8789
8829
 
8830
+ /* */
8831
+ class SFUNotAvailableError extends Error {
8832
+ constructor(message = 'Sorry your user is not configured to support video conference') {
8833
+ super(message);
8834
+ this.name = 'SFUNotAvailableError';
8835
+ }
8836
+ }
8837
+
8790
8838
  var COUNTRIES = {
8791
8839
  BELGIUM: 'BE',
8792
8840
  CANADA: 'CA',
@@ -9184,6 +9232,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
9184
9232
  const ON_CAMERA_RESUMED = 'onCameraResumed';
9185
9233
  const ON_CALL_CANCELED = 'onCallCanceled';
9186
9234
  const ON_CALL_FAILED = 'onCallFailed';
9235
+ const ON_CALL_REJECTED = 'onCallRejected';
9187
9236
  const ON_CALL_ENDED = 'onCallEnded';
9188
9237
  const ON_CALL_ENDING = 'onCallEnding';
9189
9238
  const ON_MESSAGE = 'onMessage';
@@ -9228,6 +9277,7 @@ const events = [
9228
9277
  ON_CAMERA_DISABLED,
9229
9278
  ON_CALL_FAILED,
9230
9279
  ON_CALL_ENDED,
9280
+ ON_CALL_REJECTED,
9231
9281
  ON_MESSAGE,
9232
9282
  ON_REINVITE,
9233
9283
  ON_TRACK,
@@ -9584,6 +9634,7 @@ class WebRTCPhone extends Emitter {
9584
9634
 
9585
9635
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9586
9636
  const callSession = this._createCallSession(sipSession);
9637
+ callSession.endTime = new Date();
9587
9638
  const wasCurrentSession = this._onCallTerminated(sipSession);
9588
9639
 
9589
9640
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9779,6 +9830,7 @@ class WebRTCPhone extends Emitter {
9779
9830
  this.removeIncomingSessions(sipSessionId);
9780
9831
  }
9781
9832
 
9833
+ callSession.answerTime = new Date();
9782
9834
  this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
9783
9835
 
9784
9836
  return callSession;
@@ -9836,6 +9888,7 @@ class WebRTCPhone extends Emitter {
9836
9888
  _onCallTerminated(sipSession ) {
9837
9889
  logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9838
9890
 
9891
+ const sipSessionId = this.getSipSessionId(sipSession);
9839
9892
  const callSession = this._createCallSession(sipSession);
9840
9893
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
9841
9894
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -9853,7 +9906,6 @@ class WebRTCPhone extends Emitter {
9853
9906
  }, 5);
9854
9907
  }
9855
9908
 
9856
- const sipSessionId = this.getSipSessionId(sipSession);
9857
9909
  if (sipSessionId) {
9858
9910
  this.removeIncomingSessions(sipSessionId);
9859
9911
  }
@@ -9994,6 +10046,7 @@ class WebRTCPhone extends Emitter {
9994
10046
  }
9995
10047
 
9996
10048
  this.shouldSendReinvite = false;
10049
+ callSession.answerTime = new Date();
9997
10050
  this.acceptedSessions[callSession.getId()] = true;
9998
10051
 
9999
10052
  this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
@@ -10303,6 +10356,7 @@ class WebRTCPhone extends Emitter {
10303
10356
  return Promise.resolve(null);
10304
10357
  }
10305
10358
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
10359
+ callSession.creationTime = new Date();
10306
10360
 
10307
10361
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
10308
10362
 
@@ -10498,8 +10552,12 @@ class WebRTCPhone extends Emitter {
10498
10552
  }
10499
10553
 
10500
10554
  const sessionId = this.incomingSessions[0];
10555
+ const sipSession = this.client.getSipSession(sessionId);
10556
+ if (!sipSession) {
10557
+ return null;
10558
+ }
10501
10559
 
10502
- return this._createCallSession(this.client.getSipSession(sessionId));
10560
+ return this._createCallSession(sipSession);
10503
10561
  }
10504
10562
 
10505
10563
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
@@ -10577,6 +10635,7 @@ class WebRTCPhone extends Emitter {
10577
10635
  callSession);
10578
10636
  }
10579
10637
 
10638
+ callSession.creationTime = new Date();
10580
10639
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10581
10640
  });
10582
10641
 
@@ -10616,6 +10675,13 @@ class WebRTCPhone extends Emitter {
10616
10675
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10617
10676
  });
10618
10677
 
10678
+ this.client.on(this.client.REJECTED, session => {
10679
+ logger$7.info('WebRTC call rejected', session.id);
10680
+ const callSession = this._createCallSession(session);
10681
+ callSession.endTime = new Date();
10682
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10683
+ });
10684
+
10619
10685
  this.client.on(this.client.UNREGISTERED, () => {
10620
10686
  logger$7.info('WebRTC unregistered');
10621
10687
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10828,6 +10894,7 @@ class WebRTCPhone extends Emitter {
10828
10894
  const number = identity ? identity.uri._normal.user : null;
10829
10895
  const { state } = sipSession || {};
10830
10896
  const sessionId = this.getSipSessionId(sipSession);
10897
+ fromSession = fromSession || this.callSessions[sessionId];
10831
10898
 
10832
10899
  const callSession = new CallSession({
10833
10900
  callId: fromSession && fromSession.callId,
@@ -10835,6 +10902,8 @@ class WebRTCPhone extends Emitter {
10835
10902
  sipStatus: state,
10836
10903
  displayName: identity ? identity.displayName || number : number,
10837
10904
  startTime: fromSession ? fromSession.startTime : new Date(),
10905
+ creationTime: fromSession ? fromSession.creationTime : null,
10906
+ endTime: fromSession ? fromSession.endTime : null,
10838
10907
  answered: state === sessionState.SessionState.Established,
10839
10908
  paused: this.client.isCallHeld(sipSession),
10840
10909
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10845,6 +10914,7 @@ class WebRTCPhone extends Emitter {
10845
10914
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10846
10915
  recording: fromSession ? fromSession.isRecording() : false,
10847
10916
  recordingPaused: false, // @TODO
10917
+ sipSession,
10848
10918
  ...extra,
10849
10919
  });
10850
10920
 
@@ -10873,6 +10943,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10873
10943
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10874
10944
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10875
10945
  ON_CALL_FAILED: ON_CALL_FAILED,
10946
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10876
10947
  ON_CALL_ENDED: ON_CALL_ENDED,
10877
10948
  ON_CALL_ENDING: ON_CALL_ENDING,
10878
10949
  ON_MESSAGE: ON_MESSAGE,
@@ -12321,7 +12392,7 @@ class Phone extends Emitter {
12321
12392
 
12322
12393
  checkSfu() {
12323
12394
  if (!this.hasSfu()) {
12324
- throw new Error('Sorry your user is not configured to support video conference');
12395
+ throw new SFUNotAvailableError();
12325
12396
  }
12326
12397
  }
12327
12398
 
@@ -13882,6 +13953,7 @@ const Wazo = {
13882
13953
  InvalidSubscription,
13883
13954
  InvalidAuthorization,
13884
13955
  CanceledCallError,
13956
+ SFUNotAvailableError,
13885
13957
  };
13886
13958
 
13887
13959
  if (window) {
@@ -13924,6 +13996,7 @@ var index = {
13924
13996
  WazoWebSocketClient: WebSocketClient,
13925
13997
  BadResponse,
13926
13998
  ServerError,
13999
+ SFUNotAvailableError,
13927
14000
  Call,
13928
14001
  CallSession,
13929
14002
  CTIPhone,
@@ -25,7 +25,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
25
25
 
26
26
  // Use a function here to be able to mock it in tests
27
27
  const realFetch = () => {
28
- if (typeof document !== 'undefined') {
28
+ if (typeof document !== 'undefined' && window.fetch) {
29
29
  // Browser
30
30
  return window.fetch;
31
31
  }
@@ -497,11 +497,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
497
497
 
498
498
  // $FlowFixMe
499
499
  setRemoteSessionDescription(sessionDescription ) {
500
- const result = super.setRemoteSessionDescription(sessionDescription);
500
+ try {
501
+ const result = super.setRemoteSessionDescription(sessionDescription);
501
502
 
502
- this.eventEmitter.emit('setDescription', sessionDescription);
503
+ this.eventEmitter.emit('setDescription', sessionDescription);
503
504
 
504
- return result;
505
+ return result;
506
+ } catch (error) {
507
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
508
+ throw error;
509
+ }
505
510
  }
506
511
 
507
512
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -2472,7 +2472,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
2472
2472
 
2473
2473
  // Use a function here to be able to mock it in tests
2474
2474
  const realFetch = () => {
2475
- if (typeof document !== 'undefined') {
2475
+ if (typeof document !== 'undefined' && window.fetch) {
2476
2476
  // Browser
2477
2477
  return window.fetch;
2478
2478
  }
@@ -17,7 +17,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
17
17
 
18
18
  // Use a function here to be able to mock it in tests
19
19
  const realFetch = () => {
20
- if (typeof document !== 'undefined') {
20
+ if (typeof document !== 'undefined' && window.fetch) {
21
21
  // Browser
22
22
  return window.fetch;
23
23
  }
@@ -17,7 +17,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
17
17
 
18
18
  // Use a function here to be able to mock it in tests
19
19
  const realFetch = () => {
20
- if (typeof document !== 'undefined') {
20
+ if (typeof document !== 'undefined' && window.fetch) {
21
21
  // Browser
22
22
  return window.fetch;
23
23
  }
@@ -452,7 +452,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
452
452
 
453
453
  // Use a function here to be able to mock it in tests
454
454
  const realFetch = () => {
455
- if (typeof document !== 'undefined') {
455
+ if (typeof document !== 'undefined' && window.fetch) {
456
456
  // Browser
457
457
  return window.fetch;
458
458
  }