matrix-js-sdk 41.0.0 → 41.1.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.
Files changed (93) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/lib/@types/event.d.ts +1 -1
  3. package/lib/@types/event.d.ts.map +1 -1
  4. package/lib/@types/event.js +1 -1
  5. package/lib/@types/event.js.map +1 -1
  6. package/lib/client.d.ts.map +1 -1
  7. package/lib/client.js +250 -246
  8. package/lib/client.js.map +1 -1
  9. package/lib/crypto-api/index.d.ts +13 -2
  10. package/lib/crypto-api/index.d.ts.map +1 -1
  11. package/lib/crypto-api/index.js +11 -0
  12. package/lib/crypto-api/index.js.map +1 -1
  13. package/lib/logger.d.ts +5 -5
  14. package/lib/logger.d.ts.map +1 -1
  15. package/lib/logger.js.map +1 -1
  16. package/lib/matrixrtc/CallMembership.d.ts +49 -145
  17. package/lib/matrixrtc/CallMembership.d.ts.map +1 -1
  18. package/lib/matrixrtc/CallMembership.js +157 -265
  19. package/lib/matrixrtc/CallMembership.js.map +1 -1
  20. package/lib/matrixrtc/EncryptionManager.d.ts +1 -85
  21. package/lib/matrixrtc/EncryptionManager.d.ts.map +1 -1
  22. package/lib/matrixrtc/EncryptionManager.js +0 -317
  23. package/lib/matrixrtc/EncryptionManager.js.map +1 -1
  24. package/lib/matrixrtc/MatrixRTCSession.d.ts +18 -22
  25. package/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -1
  26. package/lib/matrixrtc/MatrixRTCSession.js +48 -76
  27. package/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
  28. package/lib/matrixrtc/MatrixRTCSessionManager.d.ts +2 -1
  29. package/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +1 -1
  30. package/lib/matrixrtc/MatrixRTCSessionManager.js +3 -2
  31. package/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -1
  32. package/lib/matrixrtc/MembershipManager.d.ts +10 -4
  33. package/lib/matrixrtc/MembershipManager.d.ts.map +1 -1
  34. package/lib/matrixrtc/MembershipManager.js +10 -4
  35. package/lib/matrixrtc/MembershipManager.js.map +1 -1
  36. package/lib/matrixrtc/RTCEncryptionManager.d.ts +6 -7
  37. package/lib/matrixrtc/RTCEncryptionManager.d.ts.map +1 -1
  38. package/lib/matrixrtc/RTCEncryptionManager.js +4 -7
  39. package/lib/matrixrtc/RTCEncryptionManager.js.map +1 -1
  40. package/lib/matrixrtc/index.d.ts +1 -0
  41. package/lib/matrixrtc/index.d.ts.map +1 -1
  42. package/lib/matrixrtc/index.js.map +1 -1
  43. package/lib/matrixrtc/membershipData/common.d.ts +8 -0
  44. package/lib/matrixrtc/membershipData/common.d.ts.map +1 -0
  45. package/lib/matrixrtc/membershipData/common.js +26 -0
  46. package/lib/matrixrtc/membershipData/common.js.map +1 -0
  47. package/lib/matrixrtc/membershipData/index.d.ts +4 -0
  48. package/lib/matrixrtc/membershipData/index.d.ts.map +1 -0
  49. package/lib/matrixrtc/membershipData/index.js +20 -0
  50. package/lib/matrixrtc/membershipData/index.js.map +1 -0
  51. package/lib/matrixrtc/membershipData/rtc.d.ts +33 -0
  52. package/lib/matrixrtc/membershipData/rtc.d.ts.map +1 -0
  53. package/lib/matrixrtc/membershipData/rtc.js +137 -0
  54. package/lib/matrixrtc/membershipData/rtc.js.map +1 -0
  55. package/lib/matrixrtc/membershipData/session.d.ts +77 -0
  56. package/lib/matrixrtc/membershipData/session.d.ts.map +1 -0
  57. package/lib/matrixrtc/membershipData/session.js +62 -0
  58. package/lib/matrixrtc/membershipData/session.js.map +1 -0
  59. package/lib/matrixrtc/types.d.ts +23 -0
  60. package/lib/matrixrtc/types.d.ts.map +1 -1
  61. package/lib/matrixrtc/types.js +9 -1
  62. package/lib/matrixrtc/types.js.map +1 -1
  63. package/lib/matrixrtc/utils.d.ts +11 -1
  64. package/lib/matrixrtc/utils.d.ts.map +1 -1
  65. package/lib/matrixrtc/utils.js +24 -1
  66. package/lib/matrixrtc/utils.js.map +1 -1
  67. package/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
  68. package/lib/rust-crypto/rust-crypto.js +2 -2
  69. package/lib/rust-crypto/rust-crypto.js.map +1 -1
  70. package/package.json +5 -7
  71. package/src/@types/event.ts +2 -2
  72. package/src/client.ts +5 -3
  73. package/src/crypto-api/index.ts +17 -2
  74. package/src/logger.ts +5 -5
  75. package/src/matrixrtc/CallMembership.ts +159 -373
  76. package/src/matrixrtc/EncryptionManager.ts +1 -417
  77. package/src/matrixrtc/MatrixRTCSession.ts +82 -122
  78. package/src/matrixrtc/MatrixRTCSessionManager.ts +5 -3
  79. package/src/matrixrtc/MembershipManager.ts +14 -17
  80. package/src/matrixrtc/RTCEncryptionManager.ts +7 -10
  81. package/src/matrixrtc/index.ts +1 -0
  82. package/src/matrixrtc/membershipData/common.ts +27 -0
  83. package/src/matrixrtc/membershipData/index.ts +19 -0
  84. package/src/matrixrtc/membershipData/rtc.ts +156 -0
  85. package/src/matrixrtc/membershipData/session.ts +146 -0
  86. package/src/matrixrtc/types.ts +27 -1
  87. package/src/matrixrtc/utils.ts +24 -2
  88. package/src/rust-crypto/rust-crypto.ts +4 -1
  89. package/lib/matrixrtc/RoomKeyTransport.d.ts +0 -25
  90. package/lib/matrixrtc/RoomKeyTransport.d.ts.map +0 -1
  91. package/lib/matrixrtc/RoomKeyTransport.js +0 -152
  92. package/lib/matrixrtc/RoomKeyTransport.js.map +0 -1
  93. package/src/matrixrtc/RoomKeyTransport.ts +0 -189
package/lib/client.js CHANGED
@@ -2763,28 +2763,32 @@ export class MatrixClient extends TypedEventEmitter {
2763
2763
  * May return synthesized attributes if the URL lacked OG meta.
2764
2764
  */
2765
2765
  getUrlPreview(url, ts) {
2766
- // bucket the timestamp to the nearest minute to prevent excessive spam to the server
2767
- // Surely 60-second accuracy is enough for anyone.
2768
- ts = Math.floor(ts / 60000) * 60000;
2769
- var parsed = new URL(url);
2770
- parsed.hash = ""; // strip the hash as it won't affect the preview
2771
- url = parsed.toString();
2772
- var key = ts + "_" + url;
2773
-
2774
- // If there's already a request in flight (or we've handled it), return that instead.
2775
- if (key in this.urlPreviewCache) {
2776
- return this.urlPreviewCache[key];
2777
- }
2778
- var resp = this.http.authedRequest(Method.Get, "/preview_url", {
2779
- url,
2780
- ts: ts.toString()
2781
- }, undefined, {
2782
- prefix: MediaPrefix.V3,
2783
- priority: "low"
2784
- });
2785
- // TODO: Expire the URL preview cache sometimes
2786
- this.urlPreviewCache[key] = resp;
2787
- return resp;
2766
+ var _this30 = this;
2767
+ return _asyncToGenerator(function* () {
2768
+ // bucket the timestamp to the nearest minute to prevent excessive spam to the server
2769
+ // Surely 60-second accuracy is enough for anyone.
2770
+ ts = Math.floor(ts / 60000) * 60000;
2771
+ var parsed = new URL(url);
2772
+ parsed.hash = ""; // strip the hash as it won't affect the preview
2773
+ url = parsed.toString();
2774
+ var key = ts + "_" + url;
2775
+
2776
+ // If there's already a request in flight (or we've handled it), return that instead.
2777
+ if (key in _this30.urlPreviewCache) {
2778
+ return _this30.urlPreviewCache[key];
2779
+ }
2780
+ var supportsNewEndpoint = yield _this30.isVersionSupported("v1.11");
2781
+ var resp = _this30.http.authedRequest(Method.Get, supportsNewEndpoint ? "/media/preview_url" : "/preview_url", {
2782
+ url,
2783
+ ts: ts.toString()
2784
+ }, undefined, {
2785
+ prefix: supportsNewEndpoint ? ClientPrefix.V1 : MediaPrefix.V3,
2786
+ priority: "low"
2787
+ });
2788
+ // TODO: Expire the URL preview cache sometimes
2789
+ _this30.urlPreviewCache[key] = resp;
2790
+ return resp;
2791
+ })();
2788
2792
  }
2789
2793
 
2790
2794
  /**
@@ -2912,7 +2916,7 @@ export class MatrixClient extends TypedEventEmitter {
2912
2916
  */
2913
2917
  invite(roomId, userId) {
2914
2918
  var _arguments10 = arguments,
2915
- _this30 = this;
2919
+ _this31 = this;
2916
2920
  return _asyncToGenerator(function* () {
2917
2921
  var opts = _arguments10.length > 2 && _arguments10[2] !== undefined ? _arguments10[2] : {};
2918
2922
  if (typeof opts != "object") {
@@ -2921,10 +2925,10 @@ export class MatrixClient extends TypedEventEmitter {
2921
2925
  };
2922
2926
  }
2923
2927
  if (opts.shareEncryptedHistory) {
2924
- var _this30$cryptoBackend;
2925
- yield (_this30$cryptoBackend = _this30.cryptoBackend) === null || _this30$cryptoBackend === void 0 ? void 0 : _this30$cryptoBackend.shareRoomHistoryWithUser(roomId, userId);
2928
+ var _this31$cryptoBackend;
2929
+ yield (_this31$cryptoBackend = _this31.cryptoBackend) === null || _this31$cryptoBackend === void 0 ? void 0 : _this31$cryptoBackend.shareRoomHistoryWithUser(roomId, userId);
2926
2930
  }
2927
- return yield _this30.membershipChange(roomId, userId, KnownMembership.Invite, opts.reason);
2931
+ return yield _this31.membershipChange(roomId, userId, KnownMembership.Invite, opts.reason);
2928
2932
  })();
2929
2933
  }
2930
2934
 
@@ -2952,13 +2956,13 @@ export class MatrixClient extends TypedEventEmitter {
2952
2956
  * @see MatrixSafetyError
2953
2957
  */
2954
2958
  inviteByThreePid(roomId, medium, address) {
2955
- var _this31 = this;
2959
+ var _this32 = this;
2956
2960
  return _asyncToGenerator(function* () {
2957
- var _this31$identityServe;
2961
+ var _this32$identityServe;
2958
2962
  var path = utils.encodeUri("/rooms/$roomId/invite", {
2959
2963
  $roomId: roomId
2960
2964
  });
2961
- var identityServerUrl = _this31.getIdentityServerUrl(true);
2965
+ var identityServerUrl = _this32.getIdentityServerUrl(true);
2962
2966
  if (!identityServerUrl) {
2963
2967
  return Promise.reject(new MatrixError({
2964
2968
  error: "No supplied identity server URL",
@@ -2970,13 +2974,13 @@ export class MatrixClient extends TypedEventEmitter {
2970
2974
  medium: medium,
2971
2975
  address: address
2972
2976
  };
2973
- if ((_this31$identityServe = _this31.identityServer) !== null && _this31$identityServe !== void 0 && _this31$identityServe.getAccessToken) {
2974
- var identityAccessToken = yield _this31.identityServer.getAccessToken();
2977
+ if ((_this32$identityServe = _this32.identityServer) !== null && _this32$identityServe !== void 0 && _this32$identityServe.getAccessToken) {
2978
+ var identityAccessToken = yield _this32.identityServer.getAccessToken();
2975
2979
  if (identityAccessToken) {
2976
2980
  params["id_access_token"] = identityAccessToken;
2977
2981
  }
2978
2982
  }
2979
- return _this31.http.authedRequest(Method.Post, path, undefined, params);
2983
+ return _this32.http.authedRequest(Method.Post, path, undefined, params);
2980
2984
  })();
2981
2985
  }
2982
2986
 
@@ -3045,17 +3049,17 @@ export class MatrixClient extends TypedEventEmitter {
3045
3049
  */
3046
3050
  forget(roomId) {
3047
3051
  var _arguments11 = arguments,
3048
- _this32 = this;
3052
+ _this33 = this;
3049
3053
  return _asyncToGenerator(function* () {
3050
3054
  var deleteRoom = _arguments11.length > 1 && _arguments11[1] !== undefined ? _arguments11[1] : true;
3051
3055
  // API returns an empty object
3052
3056
  var path = utils.encodeUri("/rooms/$room_id/forget", {
3053
3057
  $room_id: roomId
3054
3058
  });
3055
- var response = yield _this32.http.authedRequest(Method.Post, path);
3059
+ var response = yield _this33.http.authedRequest(Method.Post, path);
3056
3060
  if (deleteRoom) {
3057
- _this32.store.removeRoom(roomId);
3058
- _this32.emit(ClientEvent.DeleteRoom, roomId);
3061
+ _this33.store.removeRoom(roomId);
3062
+ _this33.emit(ClientEvent.DeleteRoom, roomId);
3059
3063
  }
3060
3064
  return response;
3061
3065
  })();
@@ -3173,13 +3177,13 @@ export class MatrixClient extends TypedEventEmitter {
3173
3177
  * @see MatrixSafetyError
3174
3178
  */
3175
3179
  setDisplayName(name) {
3176
- var _this33 = this;
3180
+ var _this34 = this;
3177
3181
  return _asyncToGenerator(function* () {
3178
- var prom = yield _this33.setProfileInfo("displayname", {
3182
+ var prom = yield _this34.setProfileInfo("displayname", {
3179
3183
  displayname: name
3180
3184
  });
3181
3185
  // XXX: synthesise a profile update for ourselves because Synapse is broken and won't
3182
- var user = _this33.getUser(_this33.getUserId());
3186
+ var user = _this34.getUser(_this34.getUserId());
3183
3187
  if (user) {
3184
3188
  user.displayName = name;
3185
3189
  user.emit(UserEvent.DisplayName, user.events.presence, user);
@@ -3195,13 +3199,13 @@ export class MatrixClient extends TypedEventEmitter {
3195
3199
  * @see MatrixSafetyError
3196
3200
  */
3197
3201
  setAvatarUrl(url) {
3198
- var _this34 = this;
3202
+ var _this35 = this;
3199
3203
  return _asyncToGenerator(function* () {
3200
- var prom = yield _this34.setProfileInfo("avatar_url", {
3204
+ var prom = yield _this35.setProfileInfo("avatar_url", {
3201
3205
  avatar_url: url
3202
3206
  });
3203
3207
  // XXX: synthesise a profile update for ourselves because Synapse is broken and won't
3204
- var user = _this34.getUser(_this34.getUserId());
3208
+ var user = _this35.getUser(_this35.getUserId());
3205
3209
  if (user) {
3206
3210
  user.avatarUrl = url;
3207
3211
  user.emit(UserEvent.AvatarUrl, user.events.presence, user);
@@ -3242,10 +3246,10 @@ export class MatrixClient extends TypedEventEmitter {
3242
3246
  * @param presence - the presence to specify to set_presence of sync calls
3243
3247
  */
3244
3248
  setSyncPresence(presence) {
3245
- var _this35 = this;
3249
+ var _this36 = this;
3246
3250
  return _asyncToGenerator(function* () {
3247
- var _this35$syncApi;
3248
- (_this35$syncApi = _this35.syncApi) === null || _this35$syncApi === void 0 || _this35$syncApi.setPresence(presence);
3251
+ var _this36$syncApi;
3252
+ (_this36$syncApi = _this36.syncApi) === null || _this36$syncApi === void 0 || _this36$syncApi.setPresence(presence);
3249
3253
  })();
3250
3254
  }
3251
3255
 
@@ -3256,16 +3260,16 @@ export class MatrixClient extends TypedEventEmitter {
3256
3260
  * @throws If 'presence' isn't a valid presence enum value.
3257
3261
  */
3258
3262
  setPresence(opts) {
3259
- var _this36 = this;
3263
+ var _this37 = this;
3260
3264
  return _asyncToGenerator(function* () {
3261
3265
  var path = utils.encodeUri("/presence/$userId/status", {
3262
- $userId: _this36.credentials.userId
3266
+ $userId: _this37.credentials.userId
3263
3267
  });
3264
3268
  var validStates = ["offline", "online", "unavailable"];
3265
3269
  if (validStates.indexOf(opts.presence) === -1) {
3266
3270
  throw new Error("Bad presence value: " + opts.presence);
3267
3271
  }
3268
- yield _this36.http.authedRequest(Method.Put, path, undefined, opts);
3272
+ yield _this37.http.authedRequest(Method.Put, path, undefined, opts);
3269
3273
  })();
3270
3274
  }
3271
3275
 
@@ -3368,9 +3372,9 @@ export class MatrixClient extends TypedEventEmitter {
3368
3372
  * @private
3369
3373
  */
3370
3374
  getEventContext(roomId, eventId) {
3371
- var _this37 = this;
3375
+ var _this38 = this;
3372
3376
  return _asyncToGenerator(function* () {
3373
- var _this37$clientOpts;
3377
+ var _this38$clientOpts;
3374
3378
  var path = utils.encodeUri("/rooms/$roomId/context/$eventId", {
3375
3379
  $roomId: roomId,
3376
3380
  $eventId: eventId
@@ -3378,12 +3382,12 @@ export class MatrixClient extends TypedEventEmitter {
3378
3382
  var params = {
3379
3383
  limit: "0"
3380
3384
  };
3381
- if ((_this37$clientOpts = _this37.clientOpts) !== null && _this37$clientOpts !== void 0 && _this37$clientOpts.lazyLoadMembers) {
3385
+ if ((_this38$clientOpts = _this38.clientOpts) !== null && _this38$clientOpts !== void 0 && _this38$clientOpts.lazyLoadMembers) {
3382
3386
  params.filter = JSON.stringify(Filter.LAZY_LOADING_MESSAGES_FILTER);
3383
3387
  }
3384
3388
 
3385
3389
  // TODO: we should implement a backoff (as per scrollback()) to deal more nicely with HTTP errors.
3386
- var res = yield _this37.http.authedRequest(Method.Get, path, params);
3390
+ var res = yield _this38.http.authedRequest(Method.Get, path, params);
3387
3391
  if (res.event) {
3388
3392
  var _res$events_after, _res$events_before, _res$state;
3389
3393
  return {
@@ -3414,11 +3418,11 @@ export class MatrixClient extends TypedEventEmitter {
3414
3418
  * {@link EventTimeline} including the given event
3415
3419
  */
3416
3420
  getEventTimeline(timelineSet, eventId) {
3417
- var _this38 = this;
3421
+ var _this39 = this;
3418
3422
  return _asyncToGenerator(function* () {
3419
3423
  var _ref4, _timelineSet$getTimel, _timelineSet$room$fin;
3420
3424
  // don't allow any timeline support unless it's been enabled.
3421
- if (!_this38.timelineSupport) {
3425
+ if (!_this39.timelineSupport) {
3422
3426
  throw new Error("timeline support is disabled. Set the 'timelineSupport'" + " parameter to true when creating MatrixClient to enable it.");
3423
3427
  }
3424
3428
  if (!(timelineSet !== null && timelineSet !== void 0 && timelineSet.room)) {
@@ -3427,20 +3431,20 @@ export class MatrixClient extends TypedEventEmitter {
3427
3431
  if (timelineSet.getTimelineForEvent(eventId)) {
3428
3432
  return timelineSet.getTimelineForEvent(eventId);
3429
3433
  }
3430
- if (timelineSet.thread && _this38.supportsThreads()) {
3431
- var _yield$_this38$getThr;
3432
- return (_yield$_this38$getThr = yield _this38.getThreadTimeline(timelineSet, eventId)) !== null && _yield$_this38$getThr !== void 0 ? _yield$_this38$getThr : null;
3434
+ if (timelineSet.thread && _this39.supportsThreads()) {
3435
+ var _yield$_this39$getThr;
3436
+ return (_yield$_this39$getThr = yield _this39.getThreadTimeline(timelineSet, eventId)) !== null && _yield$_this39$getThr !== void 0 ? _yield$_this39$getThr : null;
3433
3437
  }
3434
- var res = yield _this38.getEventContext(timelineSet.room.roomId, eventId);
3438
+ var res = yield _this39.getEventContext(timelineSet.room.roomId, eventId);
3435
3439
 
3436
3440
  // by the time the request completes, the event might have ended up in the timeline.
3437
3441
  if (timelineSet.getTimelineForEvent(eventId)) {
3438
3442
  return timelineSet.getTimelineForEvent(eventId);
3439
3443
  }
3440
- var mapper = _this38.getEventMapper();
3444
+ var mapper = _this39.getEventMapper();
3441
3445
  var event = mapper(res.event);
3442
3446
  if (event.isRelation(THREAD_RELATION_TYPE.name)) {
3443
- _this38.logger.warn("Tried loading a regular timeline at the position of a thread event");
3447
+ _this39.logger.warn("Tried loading a regular timeline at the position of a thread event");
3444
3448
  return null;
3445
3449
  }
3446
3450
  var events = [
@@ -3462,8 +3466,8 @@ export class MatrixClient extends TypedEventEmitter {
3462
3466
  var [timelineEvents, threadedEvents, unknownRelations] = timelineSet.room.partitionThreadedEvents(events);
3463
3467
  timelineSet.addEventsToTimeline(timelineEvents, true, false, timeline, res.start);
3464
3468
  // The target event is not in a thread but process the contextual events, so we can show any threads around it.
3465
- _this38.processThreadEvents(timelineSet.room, threadedEvents, true);
3466
- _this38.processAggregatedTimelineEvents(timelineSet.room, timelineEvents);
3469
+ _this39.processThreadEvents(timelineSet.room, threadedEvents, true);
3470
+ _this39.processAggregatedTimelineEvents(timelineSet.room, timelineEvents);
3467
3471
  unknownRelations.forEach(event => timelineSet.relations.aggregateChildEvent(event));
3468
3472
 
3469
3473
  // There is no guarantee that the event ended up in "timeline" (we might have switched to a neighbouring
@@ -3475,9 +3479,9 @@ export class MatrixClient extends TypedEventEmitter {
3475
3479
  })();
3476
3480
  }
3477
3481
  getThreadTimeline(timelineSet, eventId) {
3478
- var _this39 = this;
3482
+ var _this40 = this;
3479
3483
  return _asyncToGenerator(function* () {
3480
- if (!_this39.supportsThreads()) {
3484
+ if (!_this40.supportsThreads()) {
3481
3485
  throw new Error("could not get thread timeline: no client support");
3482
3486
  }
3483
3487
  if (!timelineSet.room) {
@@ -3486,13 +3490,13 @@ export class MatrixClient extends TypedEventEmitter {
3486
3490
  if (!timelineSet.thread) {
3487
3491
  throw new Error("could not get thread timeline: not a thread timeline");
3488
3492
  }
3489
- var res = yield _this39.getEventContext(timelineSet.room.roomId, eventId);
3490
- var mapper = _this39.getEventMapper();
3493
+ var res = yield _this40.getEventContext(timelineSet.room.roomId, eventId);
3494
+ var mapper = _this40.getEventMapper();
3491
3495
  var event = mapper(res.event);
3492
3496
  if (!timelineSet.canContain(event)) {
3493
3497
  return undefined;
3494
3498
  }
3495
- var recurse = _this39.canSupport.get(Feature.RelationsRecursion) !== ServerSupport.Unsupported;
3499
+ var recurse = _this40.canSupport.get(Feature.RelationsRecursion) !== ServerSupport.Unsupported;
3496
3500
  if (Thread.hasServerSideSupport) {
3497
3501
  if (Thread.hasServerSideFwdPaginationSupport) {
3498
3502
  var _resOlder$next_batch, _resNewer$next_batch, _timelineSet$getTimel2;
@@ -3500,12 +3504,12 @@ export class MatrixClient extends TypedEventEmitter {
3500
3504
  throw new Error("could not get thread timeline: not a thread timeline");
3501
3505
  }
3502
3506
  var thread = timelineSet.thread;
3503
- var resOlder = yield _this39.fetchRelations(timelineSet.room.roomId, thread.id, null, null, {
3507
+ var resOlder = yield _this40.fetchRelations(timelineSet.room.roomId, thread.id, null, null, {
3504
3508
  dir: Direction.Backward,
3505
3509
  from: res.start,
3506
3510
  recurse: recurse || undefined
3507
3511
  });
3508
- var resNewer = yield _this39.fetchRelations(timelineSet.room.roomId, thread.id, null, null, {
3512
+ var resNewer = yield _this40.fetchRelations(timelineSet.room.roomId, thread.id, null, null, {
3509
3513
  dir: Direction.Forward,
3510
3514
  from: res.end,
3511
3515
  recurse: recurse || undefined
@@ -3530,12 +3534,12 @@ export class MatrixClient extends TypedEventEmitter {
3530
3534
  }
3531
3535
  timelineSet.addEventsToTimeline(events, true, false, timeline, resNewer.next_batch);
3532
3536
  if (!resOlder.next_batch) {
3533
- var originalEvent = yield _this39.fetchRoomEvent(timelineSet.room.roomId, thread.id);
3537
+ var originalEvent = yield _this40.fetchRoomEvent(timelineSet.room.roomId, thread.id);
3534
3538
  timelineSet.addEventsToTimeline([mapper(originalEvent)], true, false, timeline, null);
3535
3539
  }
3536
3540
  timeline.setPaginationToken((_resOlder$next_batch = resOlder.next_batch) !== null && _resOlder$next_batch !== void 0 ? _resOlder$next_batch : null, Direction.Backward);
3537
3541
  timeline.setPaginationToken((_resNewer$next_batch = resNewer.next_batch) !== null && _resNewer$next_batch !== void 0 ? _resNewer$next_batch : null, Direction.Forward);
3538
- _this39.processAggregatedTimelineEvents(timelineSet.room, events);
3542
+ _this40.processAggregatedTimelineEvents(timelineSet.room, events);
3539
3543
 
3540
3544
  // There is no guarantee that the event ended up in "timeline" (we might have switched to a neighbouring
3541
3545
  // timeline) - so check the room's index again. On the other hand, there's no guarantee the event ended up
@@ -3548,7 +3552,7 @@ export class MatrixClient extends TypedEventEmitter {
3548
3552
  // XXX: workaround for https://github.com/vector-im/element-meta/issues/150
3549
3553
 
3550
3554
  var _thread = timelineSet.thread;
3551
- var _resOlder = yield _this39.fetchRelations(timelineSet.room.roomId, _thread.id, THREAD_RELATION_TYPE.name, null, {
3555
+ var _resOlder = yield _this40.fetchRelations(timelineSet.room.roomId, _thread.id, THREAD_RELATION_TYPE.name, null, {
3552
3556
  dir: Direction.Backward,
3553
3557
  from: res.start,
3554
3558
  recurse: recurse || undefined
@@ -3556,7 +3560,7 @@ export class MatrixClient extends TypedEventEmitter {
3556
3560
  var eventsNewer = [];
3557
3561
  var nextBatch = res.end;
3558
3562
  while (nextBatch) {
3559
- var _resNewer = yield _this39.fetchRelations(timelineSet.room.roomId, _thread.id, THREAD_RELATION_TYPE.name, null, {
3563
+ var _resNewer = yield _this40.fetchRelations(timelineSet.room.roomId, _thread.id, THREAD_RELATION_TYPE.name, null, {
3560
3564
  dir: Direction.Forward,
3561
3565
  from: nextBatch,
3562
3566
  recurse: recurse || undefined
@@ -3580,12 +3584,12 @@ export class MatrixClient extends TypedEventEmitter {
3580
3584
  _timeline.getState(EventTimeline.BACKWARDS).setUnknownStateEvents(res.state.map(mapper));
3581
3585
  timelineSet.addEventsToTimeline(_events, true, false, _timeline, null);
3582
3586
  if (!_resOlder.next_batch) {
3583
- var _originalEvent = yield _this39.fetchRoomEvent(timelineSet.room.roomId, _thread.id);
3587
+ var _originalEvent = yield _this40.fetchRoomEvent(timelineSet.room.roomId, _thread.id);
3584
3588
  timelineSet.addEventsToTimeline([mapper(_originalEvent)], true, false, _timeline, null);
3585
3589
  }
3586
3590
  _timeline.setPaginationToken((_resOlder$next_batch2 = _resOlder.next_batch) !== null && _resOlder$next_batch2 !== void 0 ? _resOlder$next_batch2 : null, Direction.Backward);
3587
3591
  _timeline.setPaginationToken(null, Direction.Forward);
3588
- _this39.processAggregatedTimelineEvents(timelineSet.room, _events);
3592
+ _this40.processAggregatedTimelineEvents(timelineSet.room, _events);
3589
3593
  return _timeline;
3590
3594
  }
3591
3595
  }
@@ -3603,10 +3607,10 @@ export class MatrixClient extends TypedEventEmitter {
3603
3607
  * {@link EventTimeline} timeline with the latest events in the room
3604
3608
  */
3605
3609
  getLatestTimeline(timelineSet) {
3606
- var _this40 = this;
3610
+ var _this41 = this;
3607
3611
  return _asyncToGenerator(function* () {
3608
3612
  // don't allow any timeline support unless it's been enabled.
3609
- if (!_this40.timelineSupport) {
3613
+ if (!_this41.timelineSupport) {
3610
3614
  throw new Error("timeline support is disabled. Set the 'timelineSupport'" + " parameter to true when creating MatrixClient to enable it.");
3611
3615
  }
3612
3616
  if (!timelineSet.room) {
@@ -3615,35 +3619,35 @@ export class MatrixClient extends TypedEventEmitter {
3615
3619
  var event;
3616
3620
  if (timelineSet.threadListType !== null) {
3617
3621
  var _res$chunk;
3618
- var res = yield _this40.createThreadListMessagesRequest(timelineSet.room.roomId, null, 1, Direction.Backward, timelineSet.threadListType, timelineSet.getFilter());
3622
+ var res = yield _this41.createThreadListMessagesRequest(timelineSet.room.roomId, null, 1, Direction.Backward, timelineSet.threadListType, timelineSet.getFilter());
3619
3623
  event = (_res$chunk = res.chunk) === null || _res$chunk === void 0 ? void 0 : _res$chunk[0];
3620
3624
  } else if (timelineSet.thread && Thread.hasServerSideSupport) {
3621
3625
  var _res$chunk2;
3622
- var recurse = _this40.canSupport.get(Feature.RelationsRecursion) !== ServerSupport.Unsupported;
3623
- var _res = yield _this40.fetchRelations(timelineSet.room.roomId, timelineSet.thread.id, THREAD_RELATION_TYPE.name, null, {
3626
+ var recurse = _this41.canSupport.get(Feature.RelationsRecursion) !== ServerSupport.Unsupported;
3627
+ var _res = yield _this41.fetchRelations(timelineSet.room.roomId, timelineSet.thread.id, THREAD_RELATION_TYPE.name, null, {
3624
3628
  dir: Direction.Backward,
3625
3629
  limit: 1,
3626
3630
  recurse: recurse || undefined
3627
3631
  });
3628
3632
  event = (_res$chunk2 = _res.chunk) === null || _res$chunk2 === void 0 ? void 0 : _res$chunk2[0];
3629
3633
  } else {
3630
- var _this40$clientOpts, _res2$chunk;
3634
+ var _this41$clientOpts, _res2$chunk;
3631
3635
  var messagesPath = utils.encodeUri("/rooms/$roomId/messages", {
3632
3636
  $roomId: timelineSet.room.roomId
3633
3637
  });
3634
3638
  var _params = {
3635
3639
  dir: "b"
3636
3640
  };
3637
- if ((_this40$clientOpts = _this40.clientOpts) !== null && _this40$clientOpts !== void 0 && _this40$clientOpts.lazyLoadMembers) {
3641
+ if ((_this41$clientOpts = _this41.clientOpts) !== null && _this41$clientOpts !== void 0 && _this41$clientOpts.lazyLoadMembers) {
3638
3642
  _params.filter = JSON.stringify(Filter.LAZY_LOADING_MESSAGES_FILTER);
3639
3643
  }
3640
- var _res2 = yield _this40.http.authedRequest(Method.Get, messagesPath, _params);
3644
+ var _res2 = yield _this41.http.authedRequest(Method.Get, messagesPath, _params);
3641
3645
  event = (_res2$chunk = _res2.chunk) === null || _res2$chunk === void 0 ? void 0 : _res2$chunk[0];
3642
3646
  }
3643
3647
  if (!event) {
3644
3648
  throw new Error("No message returned when trying to construct getLatestTimeline");
3645
3649
  }
3646
- return _this40.getEventTimeline(timelineSet, event.event_id);
3650
+ return _this41.getEventTimeline(timelineSet, event.event_id);
3647
3651
  })();
3648
3652
  }
3649
3653
 
@@ -3755,7 +3759,7 @@ export class MatrixClient extends TypedEventEmitter {
3755
3759
  * events and we reached either end of the timeline; else true.
3756
3760
  */
3757
3761
  paginateEventTimeline(eventTimeline, opts) {
3758
- var _this41 = this;
3762
+ var _this42 = this;
3759
3763
  var isNotifTimeline = eventTimeline.getTimelineSet() === this.notifTimelineSet;
3760
3764
  var room = this.getRoom(eventTimeline.getRoomId());
3761
3765
  var threadListType = eventTimeline.getTimelineSet().threadListType;
@@ -3797,11 +3801,11 @@ export class MatrixClient extends TypedEventEmitter {
3797
3801
  res.notifications = res.notifications.filter(noUnsafeEventProps);
3798
3802
  for (var i = 0; i < res.notifications.length; i++) {
3799
3803
  var notification = res.notifications[i];
3800
- var _event4 = _this41.getEventMapper()(notification.event);
3804
+ var _event4 = _this42.getEventMapper()(notification.event);
3801
3805
 
3802
3806
  // @TODO(kerrya) reprocessing every notification is ugly
3803
3807
  // remove if we get server MSC3994 support
3804
- _this41.getPushDetailsForEvent(_event4, true);
3808
+ _this42.getPushDetailsForEvent(_event4, true);
3805
3809
  _event4.event.room_id = notification.room_id; // XXX: gutwrenching
3806
3810
  matrixEvents[i] = _event4;
3807
3811
  }
@@ -3810,7 +3814,7 @@ export class MatrixClient extends TypedEventEmitter {
3810
3814
  // in the notification timeline set
3811
3815
  var timelineSet = eventTimeline.getTimelineSet();
3812
3816
  timelineSet.addEventsToTimeline(matrixEvents, backwards, false, eventTimeline, token);
3813
- _this41.processAggregatedTimelineEvents(timelineSet.room, matrixEvents);
3817
+ _this42.processAggregatedTimelineEvents(timelineSet.room, matrixEvents);
3814
3818
 
3815
3819
  // if we've hit the end of the timeline, we need to stop trying to
3816
3820
  // paginate. We need to keep the 'forwards' token though, to make sure
@@ -3872,7 +3876,7 @@ export class MatrixClient extends TypedEventEmitter {
3872
3876
  recurse: recurse || undefined
3873
3877
  }).then(/*#__PURE__*/function () {
3874
3878
  var _ref6 = _asyncToGenerator(function* (res) {
3875
- var mapper = _this41.getEventMapper();
3879
+ var mapper = _this42.getEventMapper();
3876
3880
  var matrixEvents = res.chunk.filter(noUnsafeEventProps).filter(getRelationsThreadFilter(thread.id)).map(mapper);
3877
3881
 
3878
3882
  // Process latest events first
@@ -3888,10 +3892,10 @@ export class MatrixClient extends TypedEventEmitter {
3888
3892
  timelineSet.addEventsToTimeline(matrixEvents, backwards, false, eventTimeline, newToken !== null && newToken !== void 0 ? newToken : null);
3889
3893
  if (!newToken && backwards) {
3890
3894
  var _thread$rootEvent, _eventTimeline$getRoo3;
3891
- var originalEvent = (_thread$rootEvent = thread.rootEvent) !== null && _thread$rootEvent !== void 0 ? _thread$rootEvent : mapper(yield _this41.fetchRoomEvent((_eventTimeline$getRoo3 = eventTimeline.getRoomId()) !== null && _eventTimeline$getRoo3 !== void 0 ? _eventTimeline$getRoo3 : "", thread.id));
3895
+ var originalEvent = (_thread$rootEvent = thread.rootEvent) !== null && _thread$rootEvent !== void 0 ? _thread$rootEvent : mapper(yield _this42.fetchRoomEvent((_eventTimeline$getRoo3 = eventTimeline.getRoomId()) !== null && _eventTimeline$getRoo3 !== void 0 ? _eventTimeline$getRoo3 : "", thread.id));
3892
3896
  timelineSet.addEventsToTimeline([originalEvent], true, false, eventTimeline, null);
3893
3897
  }
3894
- _this41.processAggregatedTimelineEvents(timelineSet.room, matrixEvents);
3898
+ _this42.processAggregatedTimelineEvents(timelineSet.room, matrixEvents);
3895
3899
 
3896
3900
  // if we've hit the end of the timeline, we need to stop trying to
3897
3901
  // paginate. We need to keep the 'forwards' token though, to make sure
@@ -4177,10 +4181,10 @@ export class MatrixClient extends TypedEventEmitter {
4177
4181
  * @returns Promise which resolves: As requestEmailToken
4178
4182
  */
4179
4183
  requestTokenFromEndpoint(endpoint, params) {
4180
- var _this42 = this;
4184
+ var _this43 = this;
4181
4185
  return _asyncToGenerator(function* () {
4182
4186
  var postParams = Object.assign({}, params);
4183
- return _this42.http.request(Method.Post, endpoint, undefined, postParams);
4187
+ return _this43.http.request(Method.Post, endpoint, undefined, postParams);
4184
4188
  })();
4185
4189
  }
4186
4190
 
@@ -4473,14 +4477,14 @@ export class MatrixClient extends TypedEventEmitter {
4473
4477
  * @returns Filter ID
4474
4478
  */
4475
4479
  getOrCreateFilter(filterName, filter) {
4476
- var _this43 = this;
4480
+ var _this44 = this;
4477
4481
  return _asyncToGenerator(function* () {
4478
- var filterId = _this43.store.getFilterIdByName(filterName);
4482
+ var filterId = _this44.store.getFilterIdByName(filterName);
4479
4483
  var existingId;
4480
4484
  if (filterId) {
4481
4485
  // check that the existing filter matches our expectations
4482
4486
  try {
4483
- var existingFilter = yield _this43.getFilter(_this43.credentials.userId, filterId, true);
4487
+ var existingFilter = yield _this44.getFilter(_this44.credentials.userId, filterId, true);
4484
4488
  if (existingFilter) {
4485
4489
  var oldDef = existingFilter.getDefinition();
4486
4490
  var newDef = filter.getDefinition();
@@ -4504,7 +4508,7 @@ export class MatrixClient extends TypedEventEmitter {
4504
4508
  }
4505
4509
  // if the filter doesn't exist anymore on the server, remove from store
4506
4510
  if (!existingId) {
4507
- _this43.store.setFilterIdByName(filterName, undefined);
4511
+ _this44.store.setFilterIdByName(filterName, undefined);
4508
4512
  }
4509
4513
  }
4510
4514
  if (existingId) {
@@ -4512,8 +4516,8 @@ export class MatrixClient extends TypedEventEmitter {
4512
4516
  }
4513
4517
 
4514
4518
  // create a new filter
4515
- var createdFilter = yield _this43.createFilter(filter.getDefinition());
4516
- _this43.store.setFilterIdByName(filterName, createdFilter.filterId);
4519
+ var createdFilter = yield _this44.createFilter(filter.getDefinition());
4520
+ _this44.store.setFilterIdByName(filterName, createdFilter.filterId);
4517
4521
  return createdFilter.filterId;
4518
4522
  })();
4519
4523
  }
@@ -4561,47 +4565,47 @@ export class MatrixClient extends TypedEventEmitter {
4561
4565
 
4562
4566
  // XXX: Intended private, used in code.
4563
4567
  checkTurnServers() {
4564
- var _this44 = this;
4568
+ var _this45 = this;
4565
4569
  return _asyncToGenerator(function* () {
4566
- if (!_this44.supportsVoip()) {
4570
+ if (!_this45.supportsVoip()) {
4567
4571
  return;
4568
4572
  }
4569
4573
  var credentialsGood = false;
4570
- var remainingTime = _this44.turnServersExpiry - Date.now();
4574
+ var remainingTime = _this45.turnServersExpiry - Date.now();
4571
4575
  if (remainingTime > TURN_CHECK_INTERVAL) {
4572
- _this44.logger.debug("TURN creds are valid for another " + remainingTime + " ms: not fetching new ones.");
4576
+ _this45.logger.debug("TURN creds are valid for another " + remainingTime + " ms: not fetching new ones.");
4573
4577
  credentialsGood = true;
4574
4578
  } else {
4575
- _this44.logger.debug("Fetching new TURN credentials");
4579
+ _this45.logger.debug("Fetching new TURN credentials");
4576
4580
  try {
4577
- var res = yield _this44.turnServer();
4581
+ var res = yield _this45.turnServer();
4578
4582
  if (res.uris) {
4579
- _this44.logger.debug("Got TURN URIs: " + res.uris + " refresh in " + res.ttl + " secs");
4583
+ _this45.logger.debug("Got TURN URIs: " + res.uris + " refresh in " + res.ttl + " secs");
4580
4584
  // map the response to a format that can be fed to RTCPeerConnection
4581
4585
  var servers = {
4582
4586
  urls: res.uris,
4583
4587
  username: res.username,
4584
4588
  credential: res.password
4585
4589
  };
4586
- _this44.turnServers = [servers];
4590
+ _this45.turnServers = [servers];
4587
4591
  // The TTL is in seconds but we work in ms
4588
- _this44.turnServersExpiry = Date.now() + res.ttl * 1000;
4592
+ _this45.turnServersExpiry = Date.now() + res.ttl * 1000;
4589
4593
  credentialsGood = true;
4590
- _this44.emit(ClientEvent.TurnServers, _this44.turnServers);
4594
+ _this45.emit(ClientEvent.TurnServers, _this45.turnServers);
4591
4595
  }
4592
4596
  } catch (err) {
4593
- _this44.logger.error("Failed to get TURN URIs", err);
4597
+ _this45.logger.error("Failed to get TURN URIs", err);
4594
4598
  if (err.httpStatus === 403) {
4595
4599
  // We got a 403, so there's no point in looping forever.
4596
- _this44.logger.info("TURN access unavailable for this account: stopping credentials checks");
4597
- if (_this44.checkTurnServersIntervalID !== null) {
4598
- globalThis.clearInterval(_this44.checkTurnServersIntervalID);
4600
+ _this45.logger.info("TURN access unavailable for this account: stopping credentials checks");
4601
+ if (_this45.checkTurnServersIntervalID !== null) {
4602
+ globalThis.clearInterval(_this45.checkTurnServersIntervalID);
4599
4603
  }
4600
- _this44.checkTurnServersIntervalID = undefined;
4601
- _this44.emit(ClientEvent.TurnServersError, err, true); // fatal
4604
+ _this45.checkTurnServersIntervalID = undefined;
4605
+ _this45.emit(ClientEvent.TurnServersError, err, true); // fatal
4602
4606
  } else {
4603
4607
  // otherwise, if we failed for whatever reason, try again the next time we're called.
4604
- _this44.emit(ClientEvent.TurnServersError, err, false); // non-fatal
4608
+ _this45.emit(ClientEvent.TurnServersError, err, false); // non-fatal
4605
4609
  }
4606
4610
  }
4607
4611
  }
@@ -4677,14 +4681,14 @@ export class MatrixClient extends TypedEventEmitter {
4677
4681
  });
4678
4682
  }
4679
4683
  fetchClientWellKnown() {
4680
- var _this45 = this;
4684
+ var _this46 = this;
4681
4685
  return _asyncToGenerator(function* () {
4682
- var _this45$getDomain;
4686
+ var _this46$getDomain;
4683
4687
  // `getRawClientConfig` does not throw or reject on network errors, instead
4684
4688
  // it absorbs errors and returns `{}`.
4685
- _this45.clientWellKnownPromise = AutoDiscovery.getRawClientConfig((_this45$getDomain = _this45.getDomain()) !== null && _this45$getDomain !== void 0 ? _this45$getDomain : undefined);
4686
- _this45.clientWellKnown = yield _this45.clientWellKnownPromise;
4687
- _this45.emit(ClientEvent.ClientWellKnown, _this45.clientWellKnown);
4689
+ _this46.clientWellKnownPromise = AutoDiscovery.getRawClientConfig((_this46$getDomain = _this46.getDomain()) !== null && _this46$getDomain !== void 0 ? _this46$getDomain : undefined);
4690
+ _this46.clientWellKnown = yield _this46.clientWellKnownPromise;
4691
+ _this46.emit(ClientEvent.ClientWellKnown, _this46.clientWellKnown);
4688
4692
  })();
4689
4693
  }
4690
4694
  getClientWellKnown() {
@@ -4730,16 +4734,16 @@ export class MatrixClient extends TypedEventEmitter {
4730
4734
  // TODO: on spec release, rename this to getMutualRooms
4731
4735
  // eslint-disable-next-line
4732
4736
  _unstable_getSharedRooms(userId) {
4733
- var _this46 = this;
4737
+ var _this47 = this;
4734
4738
  return _asyncToGenerator(function* () {
4735
4739
  // Initial variant of the MSC
4736
- var sharedRoomsSupport = yield _this46.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_SHARED_ROOMS);
4740
+ var sharedRoomsSupport = yield _this47.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_SHARED_ROOMS);
4737
4741
 
4738
4742
  // Newer variant that renamed shared rooms to mutual rooms
4739
- var mutualRoomsSupport = yield _this46.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_MUTUAL_ROOMS);
4743
+ var mutualRoomsSupport = yield _this47.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_MUTUAL_ROOMS);
4740
4744
 
4741
4745
  // Latest variant that changed from path elements to query elements
4742
- var queryMutualRoomsSupport = yield _this46.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_QUERY_MUTUAL_ROOMS);
4746
+ var queryMutualRoomsSupport = yield _this47.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_QUERY_MUTUAL_ROOMS);
4743
4747
  if (!sharedRoomsSupport && !mutualRoomsSupport && !queryMutualRoomsSupport) {
4744
4748
  throw Error("Server does not support the Mutual Rooms API");
4745
4749
  }
@@ -4767,7 +4771,7 @@ export class MatrixClient extends TypedEventEmitter {
4767
4771
  if (token != null && queryMutualRoomsSupport) {
4768
4772
  tokenQuery["batch_token"] = token;
4769
4773
  }
4770
- var res = yield _this46.http.authedRequest(Method.Get, path, _objectSpread(_objectSpread({}, query), tokenQuery), undefined, {
4774
+ var res = yield _this47.http.authedRequest(Method.Get, path, _objectSpread(_objectSpread({}, query), tokenQuery), undefined, {
4771
4775
  prefix: ClientPrefix.Unstable
4772
4776
  });
4773
4777
  rooms.push(...res.joined);
@@ -4788,10 +4792,10 @@ export class MatrixClient extends TypedEventEmitter {
4788
4792
  */
4789
4793
  // eslint-disable-next-line @typescript-eslint/naming-convention
4790
4794
  _unstable_getRTCTransports() {
4791
- var _this47 = this;
4795
+ var _this48 = this;
4792
4796
  return _asyncToGenerator(function* () {
4793
4797
  // There is no /versions endpoint to check for support, so we just have to attempt a request.
4794
- return (yield _this47.http.authedRequest(Method.Get, "/rtc/transports", undefined, undefined, {
4798
+ return (yield _this48.http.authedRequest(Method.Get, "/rtc/transports", undefined, undefined, {
4795
4799
  prefix: "".concat(ClientPrefix.Unstable, "/org.matrix.msc4143")
4796
4800
  })).rtc_transports;
4797
4801
  })();
@@ -4803,24 +4807,24 @@ export class MatrixClient extends TypedEventEmitter {
4803
4807
  * @returns The server /versions response
4804
4808
  */
4805
4809
  getVersions() {
4806
- var _this48 = this;
4810
+ var _this49 = this;
4807
4811
  return _asyncToGenerator(function* () {
4808
- if (_this48.serverVersionsPromise) {
4809
- return _this48.serverVersionsPromise;
4812
+ if (_this49.serverVersionsPromise) {
4813
+ return _this49.serverVersionsPromise;
4810
4814
  }
4811
4815
 
4812
4816
  // We send an authenticated request as of MSC4026
4813
- _this48.serverVersionsPromise = _this48.http.authedRequest(Method.Get, "/_matrix/client/versions", undefined, undefined, {
4817
+ _this49.serverVersionsPromise = _this49.http.authedRequest(Method.Get, "/_matrix/client/versions", undefined, undefined, {
4814
4818
  prefix: ""
4815
4819
  }).catch(e => {
4816
4820
  // Need to unset this if it fails, otherwise we'll never retry
4817
- _this48.serverVersionsPromise = undefined;
4821
+ _this49.serverVersionsPromise = undefined;
4818
4822
  // but rethrow the exception to anything that was waiting
4819
4823
  throw e;
4820
4824
  });
4821
- var serverVersions = yield _this48.serverVersionsPromise;
4822
- _this48.canSupport = yield buildFeatureSupportMap(serverVersions);
4823
- return _this48.serverVersionsPromise;
4825
+ var serverVersions = yield _this49.serverVersionsPromise;
4826
+ _this49.canSupport = yield buildFeatureSupportMap(serverVersions);
4827
+ return _this49.serverVersionsPromise;
4824
4828
  })();
4825
4829
  }
4826
4830
 
@@ -4830,11 +4834,11 @@ export class MatrixClient extends TypedEventEmitter {
4830
4834
  * @returns Whether it is supported
4831
4835
  */
4832
4836
  isVersionSupported(version) {
4833
- var _this49 = this;
4837
+ var _this50 = this;
4834
4838
  return _asyncToGenerator(function* () {
4835
4839
  var {
4836
4840
  versions
4837
- } = yield _this49.getVersions();
4841
+ } = yield _this50.getVersions();
4838
4842
  return versions && versions.includes(version);
4839
4843
  })();
4840
4844
  }
@@ -4846,9 +4850,9 @@ export class MatrixClient extends TypedEventEmitter {
4846
4850
  * @returns true if the feature is supported
4847
4851
  */
4848
4852
  doesServerSupportUnstableFeature(feature) {
4849
- var _this50 = this;
4853
+ var _this51 = this;
4850
4854
  return _asyncToGenerator(function* () {
4851
- var response = yield _this50.getVersions();
4855
+ var response = yield _this51.getVersions();
4852
4856
  if (!response) return false;
4853
4857
  var unstableFeatures = response["unstable_features"];
4854
4858
  return unstableFeatures && !!unstableFeatures[feature];
@@ -4863,9 +4867,9 @@ export class MatrixClient extends TypedEventEmitter {
4863
4867
  * for the preset.
4864
4868
  */
4865
4869
  doesServerForceEncryptionForPreset(presetName) {
4866
- var _this51 = this;
4870
+ var _this52 = this;
4867
4871
  return _asyncToGenerator(function* () {
4868
- var response = yield _this51.getVersions();
4872
+ var response = yield _this52.getVersions();
4869
4873
  if (!response) return false;
4870
4874
  var unstableFeatures = response["unstable_features"];
4871
4875
 
@@ -4875,9 +4879,9 @@ export class MatrixClient extends TypedEventEmitter {
4875
4879
  })();
4876
4880
  }
4877
4881
  doesServerSupportThread() {
4878
- var _this52 = this;
4882
+ var _this53 = this;
4879
4883
  return _asyncToGenerator(function* () {
4880
- if (yield _this52.isVersionSupported("v1.4")) {
4884
+ if (yield _this53.isVersionSupported("v1.4")) {
4881
4885
  return {
4882
4886
  threads: FeatureSupport.Stable,
4883
4887
  list: FeatureSupport.Stable,
@@ -4885,7 +4889,7 @@ export class MatrixClient extends TypedEventEmitter {
4885
4889
  };
4886
4890
  }
4887
4891
  try {
4888
- var [threadUnstable, threadStable, listUnstable, listStable, fwdPaginationUnstable, fwdPaginationStable] = yield Promise.all([_this52.doesServerSupportUnstableFeature("org.matrix.msc3440"), _this52.doesServerSupportUnstableFeature("org.matrix.msc3440.stable"), _this52.doesServerSupportUnstableFeature("org.matrix.msc3856"), _this52.doesServerSupportUnstableFeature("org.matrix.msc3856.stable"), _this52.doesServerSupportUnstableFeature("org.matrix.msc3715"), _this52.doesServerSupportUnstableFeature("org.matrix.msc3715.stable")]);
4892
+ var [threadUnstable, threadStable, listUnstable, listStable, fwdPaginationUnstable, fwdPaginationStable] = yield Promise.all([_this53.doesServerSupportUnstableFeature("org.matrix.msc3440"), _this53.doesServerSupportUnstableFeature("org.matrix.msc3440.stable"), _this53.doesServerSupportUnstableFeature("org.matrix.msc3856"), _this53.doesServerSupportUnstableFeature("org.matrix.msc3856.stable"), _this53.doesServerSupportUnstableFeature("org.matrix.msc3715"), _this53.doesServerSupportUnstableFeature("org.matrix.msc3715.stable")]);
4889
4893
  return {
4890
4894
  threads: determineFeatureSupport(threadStable, threadUnstable),
4891
4895
  list: determineFeatureSupport(listStable, listUnstable),
@@ -4944,20 +4948,20 @@ export class MatrixClient extends TypedEventEmitter {
4944
4948
  */
4945
4949
  relations(roomId, eventId, relationType, eventType) {
4946
4950
  var _arguments12 = arguments,
4947
- _this53 = this;
4951
+ _this54 = this;
4948
4952
  return _asyncToGenerator(function* () {
4949
4953
  var _result$next_batch, _result$prev_batch;
4950
4954
  var opts = _arguments12.length > 4 && _arguments12[4] !== undefined ? _arguments12[4] : {
4951
4955
  dir: Direction.Backward
4952
4956
  };
4953
- var fetchedEventType = eventType ? _this53.getEncryptedIfNeededEventType(roomId, eventType) : null;
4954
- var [eventResult, result] = yield Promise.all([_this53.fetchRoomEvent(roomId, eventId), _this53.fetchRelations(roomId, eventId, relationType, fetchedEventType, opts)]);
4955
- var mapper = _this53.getEventMapper();
4957
+ var fetchedEventType = eventType ? _this54.getEncryptedIfNeededEventType(roomId, eventType) : null;
4958
+ var [eventResult, result] = yield Promise.all([_this54.fetchRoomEvent(roomId, eventId), _this54.fetchRelations(roomId, eventId, relationType, fetchedEventType, opts)]);
4959
+ var mapper = _this54.getEventMapper();
4956
4960
  var originalEvent = eventResult ? mapper(eventResult) : undefined;
4957
4961
  var events = result.chunk.map(mapper);
4958
4962
  if (fetchedEventType === EventType.RoomMessageEncrypted) {
4959
4963
  var allEvents = originalEvent ? events.concat(originalEvent) : events;
4960
- yield Promise.all(allEvents.map(e => _this53.decryptEventIfNeeded(e)));
4964
+ yield Promise.all(allEvents.map(e => _this54.decryptEventIfNeeded(e)));
4961
4965
  if (eventType !== null) {
4962
4966
  events = events.filter(e => e.getType() === eventType);
4963
4967
  }
@@ -5312,9 +5316,9 @@ export class MatrixClient extends TypedEventEmitter {
5312
5316
  * @param data - Credentials and other details for the login request.
5313
5317
  */
5314
5318
  loginRequest(data) {
5315
- var _this54 = this;
5319
+ var _this55 = this;
5316
5320
  return _asyncToGenerator(function* () {
5317
- return yield _this54.http.authedRequest(Method.Post, "/login", undefined, data);
5321
+ return yield _this55.http.authedRequest(Method.Post, "/login", undefined, data);
5318
5322
  })();
5319
5323
  }
5320
5324
 
@@ -5329,14 +5333,14 @@ export class MatrixClient extends TypedEventEmitter {
5329
5333
  */
5330
5334
  logout() {
5331
5335
  var _arguments13 = arguments,
5332
- _this55 = this;
5336
+ _this56 = this;
5333
5337
  return _asyncToGenerator(function* () {
5334
5338
  var stopClient = _arguments13.length > 0 && _arguments13[0] !== undefined ? _arguments13[0] : false;
5335
5339
  if (stopClient) {
5336
- _this55.stopClient();
5337
- _this55.http.abort();
5340
+ _this56.stopClient();
5341
+ _this56.http.abort();
5338
5342
  }
5339
- return _this55.http.authedRequest(Method.Post, "/logout");
5343
+ return _this56.http.authedRequest(Method.Post, "/logout");
5340
5344
  })();
5341
5345
  }
5342
5346
 
@@ -5374,12 +5378,12 @@ export class MatrixClient extends TypedEventEmitter {
5374
5378
  * or UIA auth data.
5375
5379
  */
5376
5380
  requestLoginToken(auth) {
5377
- var _this56 = this;
5381
+ var _this57 = this;
5378
5382
  return _asyncToGenerator(function* () {
5379
5383
  var body = {
5380
5384
  auth
5381
5385
  };
5382
- return _this56.http.authedRequest(Method.Post, "/login/get_token", undefined,
5386
+ return _this57.http.authedRequest(Method.Post, "/login/get_token", undefined,
5383
5387
  // no query params
5384
5388
  body, {
5385
5389
  prefix: ClientPrefix.V1
@@ -5411,23 +5415,23 @@ export class MatrixClient extends TypedEventEmitter {
5411
5415
  * @returns Rejects: with an error response.
5412
5416
  */
5413
5417
  createRoom(options) {
5414
- var _this57 = this;
5418
+ var _this58 = this;
5415
5419
  return _asyncToGenerator(function* () {
5416
- var _this57$identityServe;
5420
+ var _this58$identityServe;
5417
5421
  // eslint-disable-line camelcase
5418
5422
  // some valid options include: room_alias_name, visibility, invite
5419
5423
 
5420
5424
  // inject the id_access_token if inviting 3rd party addresses
5421
5425
  var invitesNeedingToken = (options.invite_3pid || []).filter(i => !i.id_access_token);
5422
- if (invitesNeedingToken.length > 0 && (_this57$identityServe = _this57.identityServer) !== null && _this57$identityServe !== void 0 && _this57$identityServe.getAccessToken) {
5423
- var identityAccessToken = yield _this57.identityServer.getAccessToken();
5426
+ if (invitesNeedingToken.length > 0 && (_this58$identityServe = _this58.identityServer) !== null && _this58$identityServe !== void 0 && _this58$identityServe.getAccessToken) {
5427
+ var identityAccessToken = yield _this58.identityServer.getAccessToken();
5424
5428
  if (identityAccessToken) {
5425
5429
  for (var invite of invitesNeedingToken) {
5426
5430
  invite.id_access_token = identityAccessToken;
5427
5431
  }
5428
5432
  }
5429
5433
  }
5430
- return _this57.http.authedRequest(Method.Post, "/createRoom", undefined, options);
5434
+ return _this58.http.authedRequest(Method.Post, "/createRoom", undefined, options);
5431
5435
  })();
5432
5436
  }
5433
5437
 
@@ -5573,11 +5577,11 @@ export class MatrixClient extends TypedEventEmitter {
5573
5577
  */
5574
5578
  sendStateEvent(roomId, eventType, content) {
5575
5579
  var _arguments14 = arguments,
5576
- _this58 = this;
5580
+ _this59 = this;
5577
5581
  return _asyncToGenerator(function* () {
5578
5582
  var stateKey = _arguments14.length > 3 && _arguments14[3] !== undefined ? _arguments14[3] : "";
5579
5583
  var opts = _arguments14.length > 4 && _arguments14[4] !== undefined ? _arguments14[4] : {};
5580
- var room = _this58.getRoom(roomId);
5584
+ var room = _this59.getRoom(roomId);
5581
5585
  var event = new MatrixEvent({
5582
5586
  room_id: roomId,
5583
5587
  type: eventType,
@@ -5585,7 +5589,7 @@ export class MatrixClient extends TypedEventEmitter {
5585
5589
  // Cast safety: StateEvents[K] is a stronger bound than IContent, which has [key: string]: any
5586
5590
  content: content
5587
5591
  });
5588
- yield _this58.encryptStateEventIfNeeded(event, room !== null && room !== void 0 ? room : undefined);
5592
+ yield _this59.encryptStateEventIfNeeded(event, room !== null && room !== void 0 ? room : undefined);
5589
5593
  var pathParams = {
5590
5594
  $roomId: roomId,
5591
5595
  $eventType: event.getWireType(),
@@ -5595,36 +5599,36 @@ export class MatrixClient extends TypedEventEmitter {
5595
5599
  if (stateKey !== undefined) {
5596
5600
  path = utils.encodeUri(path + "/$stateKey", pathParams);
5597
5601
  }
5598
- return _this58.http.authedRequest(Method.Put, path, undefined, event.getWireContent(), opts);
5602
+ return _this59.http.authedRequest(Method.Put, path, undefined, event.getWireContent(), opts);
5599
5603
  })();
5600
5604
  }
5601
5605
  encryptStateEventIfNeeded(event, room) {
5602
- var _this59 = this;
5606
+ var _this60 = this;
5603
5607
  return _asyncToGenerator(function* () {
5604
- if (!_this59.enableEncryptedStateEvents) {
5608
+ if (!_this60.enableEncryptedStateEvents) {
5605
5609
  return;
5606
5610
  }
5607
5611
 
5608
5612
  // If the room is unknown, we cannot encrypt for it
5609
5613
  if (!room) return;
5610
- if (!_this59.cryptoBackend && _this59.usingExternalCrypto) {
5614
+ if (!_this60.cryptoBackend && _this60.usingExternalCrypto) {
5611
5615
  // The client has opted to allow sending messages to encrypted
5612
5616
  // rooms even if the room is encrypted, and we haven't set up
5613
5617
  // crypto. This is useful for users of matrix-org/pantalaimon
5614
5618
  return;
5615
5619
  }
5616
- if (!_this59.cryptoBackend) {
5620
+ if (!_this60.cryptoBackend) {
5617
5621
  throw new Error("This room is configured to use encryption, but your client does not support encryption.");
5618
5622
  }
5619
5623
 
5620
5624
  // Check regular encryption conditions.
5621
- if (!(yield _this59.shouldEncryptEventForRoom(event, room))) {
5625
+ if (!(yield _this60.shouldEncryptEventForRoom(event, room))) {
5622
5626
  return;
5623
5627
  }
5624
5628
 
5625
5629
  // If the crypto impl thinks we shouldn't encrypt, then we shouldn't.
5626
5630
  // Safety: we checked the crypto impl exists above.
5627
- if (!(yield _this59.cryptoBackend.isStateEncryptionEnabledInRoom(room.roomId))) {
5631
+ if (!(yield _this60.cryptoBackend.isStateEncryptionEnabledInRoom(room.roomId))) {
5628
5632
  return;
5629
5633
  }
5630
5634
 
@@ -5632,7 +5636,7 @@ export class MatrixClient extends TypedEventEmitter {
5632
5636
  if (["m.room.create", "m.room.member", "m.room.join_rules", "m.room.power_levels", "m.room.third_party_invite", "m.room.history_visibility", "m.room.guest_access", "m.room.encryption"].includes(event.getType())) {
5633
5637
  return;
5634
5638
  }
5635
- yield _this59.cryptoBackend.encryptEvent(event, room);
5639
+ yield _this60.cryptoBackend.encryptEvent(event, room);
5636
5640
  })();
5637
5641
  }
5638
5642
 
@@ -5665,7 +5669,7 @@ export class MatrixClient extends TypedEventEmitter {
5665
5669
  * @returns Promise which resolves: the empty object, `{}`.
5666
5670
  */
5667
5671
  setRoomReadMarkersHttpRequest(roomId, rmEventId, rrEventId, rpEventId) {
5668
- var _this60 = this;
5672
+ var _this61 = this;
5669
5673
  return _asyncToGenerator(function* () {
5670
5674
  var path = utils.encodeUri("/rooms/$roomId/read_markers", {
5671
5675
  $roomId: roomId
@@ -5674,10 +5678,10 @@ export class MatrixClient extends TypedEventEmitter {
5674
5678
  [ReceiptType.FullyRead]: rmEventId,
5675
5679
  [ReceiptType.Read]: rrEventId
5676
5680
  };
5677
- if ((yield _this60.doesServerSupportUnstableFeature("org.matrix.msc2285.stable")) || (yield _this60.isVersionSupported("v1.4"))) {
5681
+ if ((yield _this61.doesServerSupportUnstableFeature("org.matrix.msc2285.stable")) || (yield _this61.isVersionSupported("v1.4"))) {
5678
5682
  content[ReceiptType.ReadPrivate] = rpEventId;
5679
5683
  }
5680
- return _this60.http.authedRequest(Method.Post, path, undefined, content);
5684
+ return _this61.http.authedRequest(Method.Post, path, undefined, content);
5681
5685
  })();
5682
5686
  }
5683
5687
 
@@ -5911,9 +5915,9 @@ export class MatrixClient extends TypedEventEmitter {
5911
5915
  * @returns `true` if supported, otherwise `false`
5912
5916
  */
5913
5917
  doesServerSupportExtendedProfiles() {
5914
- var _this61 = this;
5918
+ var _this62 = this;
5915
5919
  return _asyncToGenerator(function* () {
5916
- return (yield _this61.isVersionSupported("v1.16")) || (yield _this61.doesServerSupportUnstableFeature(UNSTABLE_MSC4133_EXTENDED_PROFILES)) || (yield _this61.doesServerSupportUnstableFeature(STABLE_MSC4133_EXTENDED_PROFILES));
5920
+ return (yield _this62.isVersionSupported("v1.16")) || (yield _this62.doesServerSupportUnstableFeature(UNSTABLE_MSC4133_EXTENDED_PROFILES)) || (yield _this62.doesServerSupportUnstableFeature(STABLE_MSC4133_EXTENDED_PROFILES));
5917
5921
  })();
5918
5922
  }
5919
5923
 
@@ -5923,9 +5927,9 @@ export class MatrixClient extends TypedEventEmitter {
5923
5927
  * @returns The prefix for use with `authedRequest`
5924
5928
  */
5925
5929
  getExtendedProfileRequestPrefix() {
5926
- var _this62 = this;
5930
+ var _this63 = this;
5927
5931
  return _asyncToGenerator(function* () {
5928
- if ((yield _this62.isVersionSupported("v1.16")) || (yield _this62.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable"))) {
5932
+ if ((yield _this63.isVersionSupported("v1.16")) || (yield _this63.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable"))) {
5929
5933
  return ClientPrefix.V3;
5930
5934
  }
5931
5935
  return "/_matrix/client/unstable/uk.tcpip.msc4133";
@@ -5943,15 +5947,15 @@ export class MatrixClient extends TypedEventEmitter {
5943
5947
  * @throws A M_NOT_FOUND error if the profile could not be found.
5944
5948
  */
5945
5949
  getExtendedProfile(userId) {
5946
- var _this63 = this;
5950
+ var _this64 = this;
5947
5951
  return _asyncToGenerator(function* () {
5948
- if (!(yield _this63.doesServerSupportExtendedProfiles())) {
5952
+ if (!(yield _this64.doesServerSupportExtendedProfiles())) {
5949
5953
  throw new Error("Server does not support extended profiles");
5950
5954
  }
5951
- return _this63.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId", {
5955
+ return _this64.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId", {
5952
5956
  $userId: userId
5953
5957
  }), undefined, undefined, {
5954
- prefix: yield _this63.getExtendedProfileRequestPrefix()
5958
+ prefix: yield _this64.getExtendedProfileRequestPrefix()
5955
5959
  });
5956
5960
  })();
5957
5961
  }
@@ -5968,16 +5972,16 @@ export class MatrixClient extends TypedEventEmitter {
5968
5972
  * @throws A M_NOT_FOUND error if the key was not set OR the profile could not be found.
5969
5973
  */
5970
5974
  getExtendedProfileProperty(userId, key) {
5971
- var _this64 = this;
5975
+ var _this65 = this;
5972
5976
  return _asyncToGenerator(function* () {
5973
- if (!(yield _this64.doesServerSupportExtendedProfiles())) {
5977
+ if (!(yield _this65.doesServerSupportExtendedProfiles())) {
5974
5978
  throw new Error("Server does not support extended profiles");
5975
5979
  }
5976
- var profile = yield _this64.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId/$key", {
5980
+ var profile = yield _this65.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId/$key", {
5977
5981
  $userId: userId,
5978
5982
  $key: key
5979
5983
  }), undefined, undefined, {
5980
- prefix: yield _this64.getExtendedProfileRequestPrefix()
5984
+ prefix: yield _this65.getExtendedProfileRequestPrefix()
5981
5985
  });
5982
5986
  return profile[key];
5983
5987
  })();
@@ -5993,19 +5997,19 @@ export class MatrixClient extends TypedEventEmitter {
5993
5997
  * @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
5994
5998
  */
5995
5999
  setExtendedProfileProperty(key, value) {
5996
- var _this65 = this;
6000
+ var _this66 = this;
5997
6001
  return _asyncToGenerator(function* () {
5998
- if (!(yield _this65.doesServerSupportExtendedProfiles())) {
6002
+ if (!(yield _this66.doesServerSupportExtendedProfiles())) {
5999
6003
  throw new Error("Server does not support extended profiles");
6000
6004
  }
6001
- var userId = _this65.getUserId();
6002
- yield _this65.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId/$key", {
6005
+ var userId = _this66.getUserId();
6006
+ yield _this66.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId/$key", {
6003
6007
  $userId: userId,
6004
6008
  $key: key
6005
6009
  }), undefined, {
6006
6010
  [key]: value
6007
6011
  }, {
6008
- prefix: yield _this65.getExtendedProfileRequestPrefix()
6012
+ prefix: yield _this66.getExtendedProfileRequestPrefix()
6009
6013
  });
6010
6014
  })();
6011
6015
  }
@@ -6019,17 +6023,17 @@ export class MatrixClient extends TypedEventEmitter {
6019
6023
  * @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
6020
6024
  */
6021
6025
  deleteExtendedProfileProperty(key) {
6022
- var _this66 = this;
6026
+ var _this67 = this;
6023
6027
  return _asyncToGenerator(function* () {
6024
- if (!(yield _this66.doesServerSupportExtendedProfiles())) {
6028
+ if (!(yield _this67.doesServerSupportExtendedProfiles())) {
6025
6029
  throw new Error("Server does not support extended profiles");
6026
6030
  }
6027
- var userId = _this66.getUserId();
6028
- yield _this66.http.authedRequest(Method.Delete, utils.encodeUri("/profile/$userId/$key", {
6031
+ var userId = _this67.getUserId();
6032
+ yield _this67.http.authedRequest(Method.Delete, utils.encodeUri("/profile/$userId/$key", {
6029
6033
  $userId: userId,
6030
6034
  $key: key
6031
6035
  }), undefined, undefined, {
6032
- prefix: yield _this66.getExtendedProfileRequestPrefix()
6036
+ prefix: yield _this67.getExtendedProfileRequestPrefix()
6033
6037
  });
6034
6038
  })();
6035
6039
  }
@@ -6045,16 +6049,16 @@ export class MatrixClient extends TypedEventEmitter {
6045
6049
  * @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
6046
6050
  */
6047
6051
  patchExtendedProfile(profile) {
6048
- var _this67 = this;
6052
+ var _this68 = this;
6049
6053
  return _asyncToGenerator(function* () {
6050
- if (!(yield _this67.doesServerSupportExtendedProfiles())) {
6054
+ if (!(yield _this68.doesServerSupportExtendedProfiles())) {
6051
6055
  throw new Error("Server does not support extended profiles");
6052
6056
  }
6053
- var userId = _this67.getUserId();
6054
- return _this67.http.authedRequest(Method.Patch, utils.encodeUri("/profile/$userId", {
6057
+ var userId = _this68.getUserId();
6058
+ return _this68.http.authedRequest(Method.Patch, utils.encodeUri("/profile/$userId", {
6055
6059
  $userId: userId
6056
6060
  }), {}, profile, {
6057
- prefix: yield _this67.getExtendedProfileRequestPrefix()
6061
+ prefix: yield _this68.getExtendedProfileRequestPrefix()
6058
6062
  });
6059
6063
  })();
6060
6064
  }
@@ -6069,16 +6073,16 @@ export class MatrixClient extends TypedEventEmitter {
6069
6073
  * @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
6070
6074
  */
6071
6075
  setExtendedProfile(profile) {
6072
- var _this68 = this;
6076
+ var _this69 = this;
6073
6077
  return _asyncToGenerator(function* () {
6074
- if (!(yield _this68.doesServerSupportExtendedProfiles())) {
6078
+ if (!(yield _this69.doesServerSupportExtendedProfiles())) {
6075
6079
  throw new Error("Server does not support extended profiles");
6076
6080
  }
6077
- var userId = _this68.getUserId();
6078
- yield _this68.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId", {
6081
+ var userId = _this69.getUserId();
6082
+ yield _this69.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId", {
6079
6083
  $userId: userId
6080
6084
  }), {}, profile, {
6081
- prefix: yield _this68.getExtendedProfileRequestPrefix()
6085
+ prefix: yield _this69.getExtendedProfileRequestPrefix()
6082
6086
  });
6083
6087
  })();
6084
6088
  }
@@ -6101,10 +6105,10 @@ export class MatrixClient extends TypedEventEmitter {
6101
6105
  * @returns Rejects: with an error response.
6102
6106
  */
6103
6107
  addThreePidOnly(data) {
6104
- var _this69 = this;
6108
+ var _this70 = this;
6105
6109
  return _asyncToGenerator(function* () {
6106
6110
  var path = "/account/3pid/add";
6107
- return _this69.http.authedRequest(Method.Post, path, undefined, data);
6111
+ return _this70.http.authedRequest(Method.Post, path, undefined, data);
6108
6112
  })();
6109
6113
  }
6110
6114
 
@@ -6120,10 +6124,10 @@ export class MatrixClient extends TypedEventEmitter {
6120
6124
  * @returns Rejects: with an error response.
6121
6125
  */
6122
6126
  bindThreePid(data) {
6123
- var _this70 = this;
6127
+ var _this71 = this;
6124
6128
  return _asyncToGenerator(function* () {
6125
6129
  var path = "/account/3pid/bind";
6126
- return _this70.http.authedRequest(Method.Post, path, undefined, data);
6130
+ return _this71.http.authedRequest(Method.Post, path, undefined, data);
6127
6131
  })();
6128
6132
  }
6129
6133
 
@@ -6141,15 +6145,15 @@ export class MatrixClient extends TypedEventEmitter {
6141
6145
  unbindThreePid(medium, address
6142
6146
  // eslint-disable-next-line camelcase
6143
6147
  ) {
6144
- var _this71 = this;
6148
+ var _this72 = this;
6145
6149
  return _asyncToGenerator(function* () {
6146
6150
  var path = "/account/3pid/unbind";
6147
6151
  var data = {
6148
6152
  medium,
6149
6153
  address,
6150
- id_server: _this71.getIdentityServerUrl(true)
6154
+ id_server: _this72.getIdentityServerUrl(true)
6151
6155
  };
6152
- return _this71.http.authedRequest(Method.Post, path, undefined, data);
6156
+ return _this72.http.authedRequest(Method.Post, path, undefined, data);
6153
6157
  })();
6154
6158
  }
6155
6159
 
@@ -6271,13 +6275,13 @@ export class MatrixClient extends TypedEventEmitter {
6271
6275
  * @returns Rejects: with an error response.
6272
6276
  */
6273
6277
  getPushers() {
6274
- var _this72 = this;
6278
+ var _this73 = this;
6275
6279
  return _asyncToGenerator(function* () {
6276
- var response = yield _this72.http.authedRequest(Method.Get, "/pushers");
6280
+ var response = yield _this73.http.authedRequest(Method.Get, "/pushers");
6277
6281
 
6278
6282
  // Migration path for clients that connect to a homeserver that does not support
6279
6283
  // MSC3881 yet, see https://github.com/matrix-org/matrix-spec-proposals/blob/kerry/remote-push-toggle/proposals/3881-remote-push-notification-toggling.md#migration
6280
- if (!(yield _this72.doesServerSupportUnstableFeature("org.matrix.msc3881"))) {
6284
+ if (!(yield _this73.doesServerSupportUnstableFeature("org.matrix.msc3881"))) {
6281
6285
  response.pushers = response.pushers.map(pusher => {
6282
6286
  if (!pusher.hasOwnProperty(PUSHER_ENABLED.name)) {
6283
6287
  pusher[PUSHER_ENABLED.name] = true;
@@ -6707,7 +6711,7 @@ export class MatrixClient extends TypedEventEmitter {
6707
6711
  * found MXIDs. Results where no user could be found will not be listed.
6708
6712
  */
6709
6713
  identityHashedLookup(addressPairs, identityAccessToken) {
6710
- var _this73 = this;
6714
+ var _this74 = this;
6711
6715
  return _asyncToGenerator(function* () {
6712
6716
  var params = {
6713
6717
  // addresses: ["email@example.org", "10005550000"],
@@ -6716,7 +6720,7 @@ export class MatrixClient extends TypedEventEmitter {
6716
6720
  };
6717
6721
 
6718
6722
  // Get hash information first before trying to do a lookup
6719
- var hashes = yield _this73.getIdentityHashDetails(identityAccessToken);
6723
+ var hashes = yield _this74.getIdentityHashDetails(identityAccessToken);
6720
6724
  if (!hashes || !hashes["lookup_pepper"] || !hashes["algorithms"]) {
6721
6725
  throw new Error("Unsupported identity server: bad response");
6722
6726
  }
@@ -6759,7 +6763,7 @@ export class MatrixClient extends TypedEventEmitter {
6759
6763
  } else {
6760
6764
  throw new Error("Unsupported identity server: unknown hash algorithm");
6761
6765
  }
6762
- var response = yield _this73.http.idServerRequest(Method.Post, "/lookup", params, IdentityPrefix.V2, identityAccessToken);
6766
+ var response = yield _this74.http.idServerRequest(Method.Post, "/lookup", params, IdentityPrefix.V2, identityAccessToken);
6763
6767
  if (!(response !== null && response !== void 0 && response["mappings"])) return []; // no results
6764
6768
 
6765
6769
  var foundAddresses = [];
@@ -6793,12 +6797,12 @@ export class MatrixClient extends TypedEventEmitter {
6793
6797
  * @returns Rejects: with an error response.
6794
6798
  */
6795
6799
  lookupThreePid(medium, address, identityAccessToken) {
6796
- var _this74 = this;
6800
+ var _this75 = this;
6797
6801
  return _asyncToGenerator(function* () {
6798
6802
  // Note: we're using the V2 API by calling this function, but our
6799
6803
  // function contract requires a V1 response. We therefore have to
6800
6804
  // convert it manually.
6801
- var response = yield _this74.identityHashedLookup([[address, medium]], identityAccessToken);
6805
+ var response = yield _this75.identityHashedLookup([[address, medium]], identityAccessToken);
6802
6806
  var result = response.find(p => p.address === address);
6803
6807
  if (!result) {
6804
6808
  return {};
@@ -6830,12 +6834,12 @@ export class MatrixClient extends TypedEventEmitter {
6830
6834
  * @returns Rejects: with an error response.
6831
6835
  */
6832
6836
  bulkLookupThreePids(query, identityAccessToken) {
6833
- var _this75 = this;
6837
+ var _this76 = this;
6834
6838
  return _asyncToGenerator(function* () {
6835
6839
  // Note: we're using the V2 API by calling this function, but our
6836
6840
  // function contract requires a V1 response. We therefore have to
6837
6841
  // convert it manually.
6838
- var response = yield _this75.identityHashedLookup(
6842
+ var response = yield _this76.identityHashedLookup(
6839
6843
  // We have to reverse the query order to get [address, medium] pairs
6840
6844
  query.map(p => [p[1], p[0]]), identityAccessToken);
6841
6845
  var v1results = [];
@@ -6909,16 +6913,16 @@ export class MatrixClient extends TypedEventEmitter {
6909
6913
  * @returns Promise which resolves once queued there is no error feedback when sending fails.
6910
6914
  */
6911
6915
  encryptAndSendToDevice(eventType, devices, payload) {
6912
- var _this76 = this;
6916
+ var _this77 = this;
6913
6917
  return _asyncToGenerator(function* () {
6914
- if (!_this76.cryptoBackend) {
6918
+ if (!_this77.cryptoBackend) {
6915
6919
  throw new Error("Cannot encrypt to device event, your client does not support encryption.");
6916
6920
  }
6917
- var batch = yield _this76.cryptoBackend.encryptToDeviceMessages(eventType, devices, payload);
6921
+ var batch = yield _this77.cryptoBackend.encryptToDeviceMessages(eventType, devices, payload);
6918
6922
 
6919
6923
  // TODO The batch mechanism removes all possibility to get error feedbacks..
6920
6924
  // We might want instead to do the API call directly and pass the errors back.
6921
- yield _this76.queueToDevice(batch);
6925
+ yield _this77.queueToDevice(batch);
6922
6926
  })();
6923
6927
  }
6924
6928
 
@@ -7075,16 +7079,16 @@ export class MatrixClient extends TypedEventEmitter {
7075
7079
  * @returns Promise which resolves to the created space.
7076
7080
  */
7077
7081
  unstableCreateFileTree(name) {
7078
- var _this77 = this;
7082
+ var _this78 = this;
7079
7083
  return _asyncToGenerator(function* () {
7080
7084
  var {
7081
7085
  room_id: roomId
7082
- } = yield _this77.createRoom({
7086
+ } = yield _this78.createRoom({
7083
7087
  name: name,
7084
7088
  preset: Preset.PrivateChat,
7085
7089
  power_level_content_override: _objectSpread(_objectSpread({}, DEFAULT_TREE_POWER_LEVELS_TEMPLATE), {}, {
7086
7090
  users: {
7087
- [_this77.getUserId()]: 100
7091
+ [_this78.getUserId()]: 100
7088
7092
  }
7089
7093
  }),
7090
7094
  creation_content: {
@@ -7104,7 +7108,7 @@ export class MatrixClient extends TypedEventEmitter {
7104
7108
  }
7105
7109
  }]
7106
7110
  });
7107
- return new MSC3089TreeSpace(_this77, roomId);
7111
+ return new MSC3089TreeSpace(_this78, roomId);
7108
7112
  })();
7109
7113
  }
7110
7114
 
@@ -7181,7 +7185,7 @@ export class MatrixClient extends TypedEventEmitter {
7181
7185
  * @param via - The list of servers which know about the room if only an ID was provided.
7182
7186
  */
7183
7187
  getRoomSummary(roomIdOrAlias, via) {
7184
- var _this78 = this;
7188
+ var _this79 = this;
7185
7189
  return _asyncToGenerator(function* () {
7186
7190
  var paramOpts = {
7187
7191
  prefix: "/_matrix/client/unstable/im.nheko.summary"
@@ -7190,7 +7194,7 @@ export class MatrixClient extends TypedEventEmitter {
7190
7194
  var path = utils.encodeUri("/summary/$roomid", {
7191
7195
  $roomid: roomIdOrAlias
7192
7196
  });
7193
- return yield _this78.http.authedRequest(Method.Get, path, {
7197
+ return yield _this79.http.authedRequest(Method.Get, path, {
7194
7198
  via
7195
7199
  }, undefined, paramOpts);
7196
7200
  } catch (e) {
@@ -7198,7 +7202,7 @@ export class MatrixClient extends TypedEventEmitter {
7198
7202
  var _path = utils.encodeUri("/rooms/$roomid/summary", {
7199
7203
  $roomid: roomIdOrAlias
7200
7204
  });
7201
- return yield _this78.http.authedRequest(Method.Get, _path, {
7205
+ return yield _this79.http.authedRequest(Method.Get, _path, {
7202
7206
  via
7203
7207
  }, undefined, paramOpts);
7204
7208
  } else {
@@ -7250,9 +7254,9 @@ export class MatrixClient extends TypedEventEmitter {
7250
7254
  * Fetches information about the user for the configured access token.
7251
7255
  */
7252
7256
  whoami() {
7253
- var _this79 = this;
7257
+ var _this80 = this;
7254
7258
  return _asyncToGenerator(function* () {
7255
- return _this79.http.authedRequest(Method.Get, "/account/whoami");
7259
+ return _this80.http.authedRequest(Method.Get, "/account/whoami");
7256
7260
  })();
7257
7261
  }
7258
7262
 
@@ -7263,7 +7267,7 @@ export class MatrixClient extends TypedEventEmitter {
7263
7267
  * @returns Rejects: when the request fails (module:http-api.MatrixError)
7264
7268
  */
7265
7269
  timestampToEvent(roomId, timestamp, dir) {
7266
- var _this80 = this;
7270
+ var _this81 = this;
7267
7271
  return _asyncToGenerator(function* () {
7268
7272
  var path = utils.encodeUri("/rooms/$roomId/timestamp_to_event", {
7269
7273
  $roomId: roomId
@@ -7273,7 +7277,7 @@ export class MatrixClient extends TypedEventEmitter {
7273
7277
  dir: dir
7274
7278
  };
7275
7279
  try {
7276
- return yield _this80.http.authedRequest(Method.Get, path, queryParams, undefined, {
7280
+ return yield _this81.http.authedRequest(Method.Get, path, queryParams, undefined, {
7277
7281
  prefix: ClientPrefix.V1
7278
7282
  });
7279
7283
  } catch (err) {
@@ -7289,7 +7293,7 @@ export class MatrixClient extends TypedEventEmitter {
7289
7293
  // both indicate that this endpoint+verb combination is
7290
7294
  // not supported.
7291
7295
  err.httpStatus === 404 || err.httpStatus === 405)) {
7292
- return yield _this80.http.authedRequest(Method.Get, path, queryParams, undefined, {
7296
+ return yield _this81.http.authedRequest(Method.Get, path, queryParams, undefined, {
7293
7297
  prefix: "/_matrix/client/unstable/org.matrix.msc3030"
7294
7298
  });
7295
7299
  }
@@ -7309,12 +7313,12 @@ export class MatrixClient extends TypedEventEmitter {
7309
7313
  * @throws when delegated auth config is invalid or unreachable
7310
7314
  */
7311
7315
  getAuthMetadata() {
7312
- var _this81 = this;
7316
+ var _this82 = this;
7313
7317
  return _asyncToGenerator(function* () {
7314
7318
  var authMetadata;
7315
7319
  try {
7316
- var useStable = yield _this81.isVersionSupported("v1.15");
7317
- authMetadata = yield _this81.http.request(Method.Get, "/auth_metadata", undefined, undefined, {
7320
+ var useStable = yield _this82.isVersionSupported("v1.15");
7321
+ authMetadata = yield _this82.http.request(Method.Get, "/auth_metadata", undefined, undefined, {
7318
7322
  prefix: useStable ? ClientPrefix.V1 : ClientPrefix.Unstable + "/org.matrix.msc2965"
7319
7323
  });
7320
7324
  } catch (e) {
@@ -7322,7 +7326,7 @@ export class MatrixClient extends TypedEventEmitter {
7322
7326
  // Fall back to older variant of MSC2965
7323
7327
  var {
7324
7328
  issuer
7325
- } = yield _this81.http.request(Method.Get, "/auth_issuer", undefined, undefined, {
7329
+ } = yield _this82.http.request(Method.Get, "/auth_issuer", undefined, undefined, {
7326
7330
  prefix: ClientPrefix.Unstable + "/org.matrix.msc2965"
7327
7331
  });
7328
7332
  return discoverAndValidateOIDCIssuerWellKnown(issuer);