@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/esm/index.js CHANGED
@@ -464,7 +464,7 @@ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
464
464
 
465
465
  // Use a function here to be able to mock it in tests
466
466
  const realFetch = () => {
467
- if (typeof document !== 'undefined') {
467
+ if (typeof document !== 'undefined' && window.fetch) {
468
468
  // Browser
469
469
  return window.fetch;
470
470
  }
@@ -3249,13 +3249,16 @@ var updateFrom = (instance , from ) => {
3249
3249
 
3250
3250
 
3251
3251
 
3252
+
3252
3253
 
3253
3254
 
3254
3255
 
3255
3256
 
3256
3257
 
3258
+
3257
3259
 
3258
3260
 
3261
+
3259
3262
 
3260
3263
 
3261
3264
 
@@ -3272,6 +3275,7 @@ var updateFrom = (instance , from ) => {
3272
3275
 
3273
3276
 
3274
3277
 
3278
+
3275
3279
 
3276
3280
 
3277
3281
  class CallSession {
@@ -3291,10 +3295,14 @@ class CallSession {
3291
3295
 
3292
3296
 
3293
3297
 
3294
-
3298
+
3299
+
3300
+ // = creationTime
3295
3301
 
3296
3302
 
3297
3303
 
3304
+
3305
+
3298
3306
 
3299
3307
 
3300
3308
 
@@ -3330,6 +3338,8 @@ class CallSession {
3330
3338
 
3331
3339
 
3332
3340
 
3341
+
3342
+
3333
3343
 
3334
3344
  constructor({
3335
3345
  answered,
@@ -3343,6 +3353,8 @@ class CallSession {
3343
3353
  paused,
3344
3354
  ringing,
3345
3355
  startTime,
3356
+ creationTime,
3357
+ endTime,
3346
3358
  cameraEnabled,
3347
3359
  dialedExtension,
3348
3360
  sipCallId,
@@ -3355,12 +3367,16 @@ class CallSession {
3355
3367
  recording,
3356
3368
  recordingPaused,
3357
3369
  videoRemotelyDowngraded,
3370
+ sipSession,
3371
+ answerTime,
3358
3372
  } ) {
3359
3373
  this.callId = callId;
3360
3374
  this.sipCallId = sipCallId;
3361
3375
  this.displayName = displayName;
3362
3376
  this.number = number;
3377
+ this.creationTime = creationTime;
3363
3378
  this.startTime = startTime;
3379
+ this.endTime = endTime;
3364
3380
  this.isCaller = isCaller;
3365
3381
  this.answered = answered;
3366
3382
  this.answeredBySystem = answeredBySystem;
@@ -3379,6 +3395,8 @@ class CallSession {
3379
3395
  this.recording = recording || false;
3380
3396
  this.recordingPaused = recordingPaused || false;
3381
3397
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3398
+ this.sipSession = sipSession;
3399
+ this.answerTime = answerTime || this.answerTime;
3382
3400
 
3383
3401
  // Useful to compare instead of instanceof with minified code
3384
3402
  this.type = 'CallSession';
@@ -3409,7 +3427,7 @@ class CallSession {
3409
3427
  }
3410
3428
 
3411
3429
  answer() {
3412
- this.answered = true;
3430
+ this.answerTime = new Date();
3413
3431
  }
3414
3432
 
3415
3433
  systemAnswer() {
@@ -3565,6 +3583,15 @@ class CallSession {
3565
3583
  return newFrom(callSession, CallSession);
3566
3584
  }
3567
3585
 
3586
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
3587
+ set answered(value ) {
3588
+ this.answerTime = value ? new Date() : null;
3589
+ }
3590
+
3591
+ get answered() {
3592
+ return !!this.answerTime;
3593
+ }
3594
+
3568
3595
  static parseCall(call ) {
3569
3596
  return new CallSession({
3570
3597
  callId: call.id,
@@ -5624,11 +5651,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5624
5651
 
5625
5652
  // $FlowFixMe
5626
5653
  setRemoteSessionDescription(sessionDescription ) {
5627
- const result = super.setRemoteSessionDescription(sessionDescription);
5654
+ try {
5655
+ const result = super.setRemoteSessionDescription(sessionDescription);
5628
5656
 
5629
- this.eventEmitter.emit('setDescription', sessionDescription);
5657
+ this.eventEmitter.emit('setDescription', sessionDescription);
5630
5658
 
5631
- return result;
5659
+ return result;
5660
+ } catch (error) {
5661
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5662
+ throw error;
5663
+ }
5632
5664
  }
5633
5665
 
5634
5666
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -6167,6 +6199,7 @@ const MAX_REGISTER_TRIES = 10;
6167
6199
 
6168
6200
 
6169
6201
 
6202
+
6170
6203
 
6171
6204
 
6172
6205
 
@@ -7783,6 +7816,13 @@ class WebRTCClient extends Emitter {
7783
7816
  }
7784
7817
 
7785
7818
  _createWebRTCConfiguration(configOverrides = {}) {
7819
+ let { host } = this.config;
7820
+ let port = this.config.port || 443;
7821
+
7822
+ if (this.config.websocketSip) {
7823
+ [host, port = 443] = this.config.websocketSip.split(':');
7824
+ }
7825
+
7786
7826
  const config = {
7787
7827
  authorizationUsername: this.config.authorizationUser,
7788
7828
  authorizationPassword: this.config.password,
@@ -7818,7 +7858,7 @@ class WebRTCClient extends Emitter {
7818
7858
  },
7819
7859
  transportOptions: {
7820
7860
  traceSip: configOverrides.traceSip || false,
7821
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7861
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
7822
7862
  },
7823
7863
  sessionDescriptionHandlerFactoryOptions: {
7824
7864
  modifiers: [replaceLocalIpModifier],
@@ -8776,6 +8816,14 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
8776
8816
  'default': WebSocketClient
8777
8817
  });
8778
8818
 
8819
+ /* */
8820
+ class SFUNotAvailableError extends Error {
8821
+ constructor(message = 'Sorry your user is not configured to support video conference') {
8822
+ super(message);
8823
+ this.name = 'SFUNotAvailableError';
8824
+ }
8825
+ }
8826
+
8779
8827
  var COUNTRIES = {
8780
8828
  BELGIUM: 'BE',
8781
8829
  CANADA: 'CA',
@@ -9173,6 +9221,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
9173
9221
  const ON_CAMERA_RESUMED = 'onCameraResumed';
9174
9222
  const ON_CALL_CANCELED = 'onCallCanceled';
9175
9223
  const ON_CALL_FAILED = 'onCallFailed';
9224
+ const ON_CALL_REJECTED = 'onCallRejected';
9176
9225
  const ON_CALL_ENDED = 'onCallEnded';
9177
9226
  const ON_CALL_ENDING = 'onCallEnding';
9178
9227
  const ON_MESSAGE = 'onMessage';
@@ -9217,6 +9266,7 @@ const events = [
9217
9266
  ON_CAMERA_DISABLED,
9218
9267
  ON_CALL_FAILED,
9219
9268
  ON_CALL_ENDED,
9269
+ ON_CALL_REJECTED,
9220
9270
  ON_MESSAGE,
9221
9271
  ON_REINVITE,
9222
9272
  ON_TRACK,
@@ -9573,6 +9623,7 @@ class WebRTCPhone extends Emitter {
9573
9623
 
9574
9624
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9575
9625
  const callSession = this._createCallSession(sipSession);
9626
+ callSession.endTime = new Date();
9576
9627
  const wasCurrentSession = this._onCallTerminated(sipSession);
9577
9628
 
9578
9629
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9768,6 +9819,7 @@ class WebRTCPhone extends Emitter {
9768
9819
  this.removeIncomingSessions(sipSessionId);
9769
9820
  }
9770
9821
 
9822
+ callSession.answerTime = new Date();
9771
9823
  this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
9772
9824
 
9773
9825
  return callSession;
@@ -9825,6 +9877,7 @@ class WebRTCPhone extends Emitter {
9825
9877
  _onCallTerminated(sipSession ) {
9826
9878
  logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9827
9879
 
9880
+ const sipSessionId = this.getSipSessionId(sipSession);
9828
9881
  const callSession = this._createCallSession(sipSession);
9829
9882
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
9830
9883
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -9842,7 +9895,6 @@ class WebRTCPhone extends Emitter {
9842
9895
  }, 5);
9843
9896
  }
9844
9897
 
9845
- const sipSessionId = this.getSipSessionId(sipSession);
9846
9898
  if (sipSessionId) {
9847
9899
  this.removeIncomingSessions(sipSessionId);
9848
9900
  }
@@ -9983,6 +10035,7 @@ class WebRTCPhone extends Emitter {
9983
10035
  }
9984
10036
 
9985
10037
  this.shouldSendReinvite = false;
10038
+ callSession.answerTime = new Date();
9986
10039
  this.acceptedSessions[callSession.getId()] = true;
9987
10040
 
9988
10041
  this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
@@ -10292,6 +10345,7 @@ class WebRTCPhone extends Emitter {
10292
10345
  return Promise.resolve(null);
10293
10346
  }
10294
10347
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
10348
+ callSession.creationTime = new Date();
10295
10349
 
10296
10350
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
10297
10351
 
@@ -10487,8 +10541,12 @@ class WebRTCPhone extends Emitter {
10487
10541
  }
10488
10542
 
10489
10543
  const sessionId = this.incomingSessions[0];
10544
+ const sipSession = this.client.getSipSession(sessionId);
10545
+ if (!sipSession) {
10546
+ return null;
10547
+ }
10490
10548
 
10491
- return this._createCallSession(this.client.getSipSession(sessionId));
10549
+ return this._createCallSession(sipSession);
10492
10550
  }
10493
10551
 
10494
10552
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
@@ -10566,6 +10624,7 @@ class WebRTCPhone extends Emitter {
10566
10624
  callSession);
10567
10625
  }
10568
10626
 
10627
+ callSession.creationTime = new Date();
10569
10628
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10570
10629
  });
10571
10630
 
@@ -10605,6 +10664,13 @@ class WebRTCPhone extends Emitter {
10605
10664
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10606
10665
  });
10607
10666
 
10667
+ this.client.on(this.client.REJECTED, session => {
10668
+ logger$7.info('WebRTC call rejected', session.id);
10669
+ const callSession = this._createCallSession(session);
10670
+ callSession.endTime = new Date();
10671
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10672
+ });
10673
+
10608
10674
  this.client.on(this.client.UNREGISTERED, () => {
10609
10675
  logger$7.info('WebRTC unregistered');
10610
10676
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10817,6 +10883,7 @@ class WebRTCPhone extends Emitter {
10817
10883
  const number = identity ? identity.uri._normal.user : null;
10818
10884
  const { state } = sipSession || {};
10819
10885
  const sessionId = this.getSipSessionId(sipSession);
10886
+ fromSession = fromSession || this.callSessions[sessionId];
10820
10887
 
10821
10888
  const callSession = new CallSession({
10822
10889
  callId: fromSession && fromSession.callId,
@@ -10824,6 +10891,8 @@ class WebRTCPhone extends Emitter {
10824
10891
  sipStatus: state,
10825
10892
  displayName: identity ? identity.displayName || number : number,
10826
10893
  startTime: fromSession ? fromSession.startTime : new Date(),
10894
+ creationTime: fromSession ? fromSession.creationTime : null,
10895
+ endTime: fromSession ? fromSession.endTime : null,
10827
10896
  answered: state === SessionState.Established,
10828
10897
  paused: this.client.isCallHeld(sipSession),
10829
10898
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10834,6 +10903,7 @@ class WebRTCPhone extends Emitter {
10834
10903
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10835
10904
  recording: fromSession ? fromSession.isRecording() : false,
10836
10905
  recordingPaused: false, // @TODO
10906
+ sipSession,
10837
10907
  ...extra,
10838
10908
  });
10839
10909
 
@@ -10862,6 +10932,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10862
10932
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10863
10933
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10864
10934
  ON_CALL_FAILED: ON_CALL_FAILED,
10935
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10865
10936
  ON_CALL_ENDED: ON_CALL_ENDED,
10866
10937
  ON_CALL_ENDING: ON_CALL_ENDING,
10867
10938
  ON_MESSAGE: ON_MESSAGE,
@@ -12310,7 +12381,7 @@ class Phone extends Emitter {
12310
12381
 
12311
12382
  checkSfu() {
12312
12383
  if (!this.hasSfu()) {
12313
- throw new Error('Sorry your user is not configured to support video conference');
12384
+ throw new SFUNotAvailableError();
12314
12385
  }
12315
12386
  }
12316
12387
 
@@ -13871,6 +13942,7 @@ const Wazo = {
13871
13942
  InvalidSubscription,
13872
13943
  InvalidAuthorization,
13873
13944
  CanceledCallError,
13945
+ SFUNotAvailableError,
13874
13946
  };
13875
13947
 
13876
13948
  if (window) {
@@ -13913,6 +13985,7 @@ var index = {
13913
13985
  WazoWebSocketClient: WebSocketClient,
13914
13986
  BadResponse,
13915
13987
  ServerError,
13988
+ SFUNotAvailableError,
13916
13989
  Call,
13917
13990
  CallSession,
13918
13991
  CTIPhone,
@@ -15,7 +15,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
15
15
 
16
16
  // Use a function here to be able to mock it in tests
17
17
  const realFetch = () => {
18
- if (typeof document !== 'undefined') {
18
+ if (typeof document !== 'undefined' && window.fetch) {
19
19
  // Browser
20
20
  return window.fetch;
21
21
  }
@@ -487,11 +487,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
487
487
 
488
488
  // $FlowFixMe
489
489
  setRemoteSessionDescription(sessionDescription ) {
490
- const result = super.setRemoteSessionDescription(sessionDescription);
490
+ try {
491
+ const result = super.setRemoteSessionDescription(sessionDescription);
491
492
 
492
- this.eventEmitter.emit('setDescription', sessionDescription);
493
+ this.eventEmitter.emit('setDescription', sessionDescription);
493
494
 
494
- return result;
495
+ return result;
496
+ } catch (error) {
497
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
498
+ throw error;
499
+ }
495
500
  }
496
501
 
497
502
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -2466,7 +2466,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
2466
2466
 
2467
2467
  // Use a function here to be able to mock it in tests
2468
2468
  const realFetch = () => {
2469
- if (typeof document !== 'undefined') {
2469
+ if (typeof document !== 'undefined' && window.fetch) {
2470
2470
  // Browser
2471
2471
  return window.fetch;
2472
2472
  }
@@ -11,7 +11,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
11
11
 
12
12
  // Use a function here to be able to mock it in tests
13
13
  const realFetch = () => {
14
- if (typeof document !== 'undefined') {
14
+ if (typeof document !== 'undefined' && window.fetch) {
15
15
  // Browser
16
16
  return window.fetch;
17
17
  }
@@ -11,7 +11,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
11
11
 
12
12
  // Use a function here to be able to mock it in tests
13
13
  const realFetch = () => {
14
- if (typeof document !== 'undefined') {
14
+ if (typeof document !== 'undefined' && window.fetch) {
15
15
  // Browser
16
16
  return window.fetch;
17
17
  }
@@ -444,7 +444,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
444
444
 
445
445
  // Use a function here to be able to mock it in tests
446
446
  const realFetch = () => {
447
- if (typeof document !== 'undefined') {
447
+ if (typeof document !== 'undefined' && window.fetch) {
448
448
  // Browser
449
449
  return window.fetch;
450
450
  }