matrix-js-sdk 34.2.0 → 34.3.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/git-revision.txt +1 -1
- package/lib/@types/global.d.js.map +1 -1
- package/lib/@types/requests.d.ts +37 -0
- package/lib/@types/requests.d.ts.map +1 -1
- package/lib/@types/requests.js +28 -1
- package/lib/@types/requests.js.map +1 -1
- package/lib/client.d.ts +48 -4
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +412 -257
- package/lib/client.js.map +1 -1
- package/lib/crypto/algorithms/base.d.ts +0 -2
- package/lib/crypto/algorithms/base.d.ts.map +1 -1
- package/lib/crypto/algorithms/base.js +0 -4
- package/lib/crypto/algorithms/base.js.map +1 -1
- package/lib/digest.d.ts +10 -0
- package/lib/digest.d.ts.map +1 -0
- package/lib/digest.js +40 -0
- package/lib/digest.js.map +1 -0
- package/lib/embedded.d.ts +24 -1
- package/lib/embedded.d.ts.map +1 -1
- package/lib/embedded.js +84 -26
- package/lib/embedded.js.map +1 -1
- package/lib/matrixrtc/MatrixRTCSession.d.ts +2 -0
- package/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -1
- package/lib/matrixrtc/MatrixRTCSession.js +44 -15
- package/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
- package/lib/matrixrtc/index.d.ts +7 -0
- package/lib/matrixrtc/index.d.ts.map +1 -0
- package/lib/matrixrtc/index.js +23 -0
- package/lib/matrixrtc/index.js.map +1 -0
- package/lib/models/event.js.map +1 -1
- package/lib/oidc/authorize.d.ts.map +1 -1
- package/lib/oidc/authorize.js +4 -3
- package/lib/oidc/authorize.js.map +1 -1
- package/lib/rust-crypto/RoomEncryptor.d.ts +1 -1
- package/lib/rust-crypto/RoomEncryptor.d.ts.map +1 -1
- package/lib/rust-crypto/RoomEncryptor.js +6 -2
- package/lib/rust-crypto/RoomEncryptor.js.map +1 -1
- package/lib/rust-crypto/index.js +1 -0
- package/lib/rust-crypto/index.js.map +1 -1
- package/lib/rust-crypto/rust-crypto.d.ts +9 -0
- package/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
- package/lib/rust-crypto/rust-crypto.js +83 -58
- package/lib/rust-crypto/rust-crypto.js.map +1 -1
- package/lib/sync-accumulator.js.map +1 -1
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js.map +1 -1
- package/package.json +5 -5
- package/src/@types/global.d.ts +0 -45
- package/src/@types/requests.ts +50 -0
- package/src/client.ts +237 -46
- package/src/crypto/algorithms/base.ts +0 -4
- package/src/digest.ts +34 -0
- package/src/embedded.ts +109 -5
- package/src/matrixrtc/MatrixRTCSession.ts +52 -20
- package/src/matrixrtc/index.ts +22 -0
- package/src/models/event.ts +1 -1
- package/src/oidc/authorize.ts +4 -7
- package/src/rust-crypto/RoomEncryptor.ts +10 -6
- package/src/rust-crypto/index.ts +3 -0
- package/src/rust-crypto/rust-crypto.ts +51 -24
- package/src/sync-accumulator.ts +1 -1
- package/src/sync.ts +3 -1
package/lib/client.js
CHANGED
|
@@ -37,7 +37,7 @@ import { Direction, EventTimeline } from "./models/event-timeline";
|
|
|
37
37
|
import { PushProcessor } from "./pushprocessor";
|
|
38
38
|
import { AutoDiscovery } from "./autodiscovery";
|
|
39
39
|
import * as olmlib from "./crypto/olmlib";
|
|
40
|
-
import { decodeBase64, encodeBase64 } from "./base64";
|
|
40
|
+
import { decodeBase64, encodeBase64, encodeUnpaddedBase64Url } from "./base64";
|
|
41
41
|
import { TypedReEmitter } from "./ReEmitter";
|
|
42
42
|
import { logger } from "./logger";
|
|
43
43
|
import { SERVICE_TYPES } from "./service-types";
|
|
@@ -78,6 +78,7 @@ import { MatrixRTCSessionManager } from "./matrixrtc/MatrixRTCSessionManager";
|
|
|
78
78
|
import { getRelationsThreadFilter } from "./thread-utils";
|
|
79
79
|
import { KnownMembership } from "./@types/membership";
|
|
80
80
|
import { ServerCapabilities } from "./serverCapabilities";
|
|
81
|
+
import { sha256 } from "./digest";
|
|
81
82
|
var SCROLLBACK_DELAY_MS = 3000;
|
|
82
83
|
export var CRYPTO_ENABLED = isCryptoAvailable();
|
|
83
84
|
var TURN_CHECK_INTERVAL = 10 * 60 * 1000; // poll for turn credentials every 10 minutes
|
|
@@ -92,6 +93,7 @@ export var GET_LOGIN_TOKEN_CAPABILITY = new NamespacedValue("m.get_login_token",
|
|
|
92
93
|
export var UNSTABLE_MSC2666_SHARED_ROOMS = "uk.half-shot.msc2666";
|
|
93
94
|
export var UNSTABLE_MSC2666_MUTUAL_ROOMS = "uk.half-shot.msc2666.mutual_rooms";
|
|
94
95
|
export var UNSTABLE_MSC2666_QUERY_MUTUAL_ROOMS = "uk.half-shot.msc2666.query_mutual_rooms";
|
|
96
|
+
export var UNSTABLE_MSC4140_DELAYED_EVENTS = "org.matrix.msc4140";
|
|
95
97
|
var CrossSigningKeyType = /*#__PURE__*/function (CrossSigningKeyType) {
|
|
96
98
|
CrossSigningKeyType["MasterKey"] = "master_key";
|
|
97
99
|
CrossSigningKeyType["SelfSigningKey"] = "self_signing_key";
|
|
@@ -266,9 +268,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
266
268
|
var unreadRooms = ((_this$getRooms = this.getRooms()) !== null && _this$getRooms !== void 0 ? _this$getRooms : []).filter(room => {
|
|
267
269
|
return room.getUnreadNotificationCount(NotificationCountType.Total) > 0;
|
|
268
270
|
});
|
|
269
|
-
for (var
|
|
271
|
+
for (var _room of unreadRooms) {
|
|
270
272
|
var currentUserId = this.getSafeUserId();
|
|
271
|
-
|
|
273
|
+
_room.fixupNotifications(currentUserId);
|
|
272
274
|
}
|
|
273
275
|
this.off(ClientEvent.Sync, this.fixupRoomNotifications);
|
|
274
276
|
}
|
|
@@ -2931,13 +2933,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
2931
2933
|
var _this29 = this;
|
|
2932
2934
|
return _asyncToGenerator(function* () {
|
|
2933
2935
|
if (_this29.isInitialSyncComplete()) {
|
|
2934
|
-
var
|
|
2935
|
-
if (!
|
|
2936
|
+
var _event = _this29.store.getAccountData(eventType);
|
|
2937
|
+
if (!_event) {
|
|
2936
2938
|
return null;
|
|
2937
2939
|
}
|
|
2938
2940
|
// The network version below returns just the content, so this branch
|
|
2939
2941
|
// does the same to match.
|
|
2940
|
-
return
|
|
2942
|
+
return _event.getContent();
|
|
2941
2943
|
}
|
|
2942
2944
|
var path = utils.encodeUri("/user/$userId/account_data/$type", {
|
|
2943
2945
|
$userId: _this29.credentials.userId,
|
|
@@ -3292,7 +3294,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
3292
3294
|
})();
|
|
3293
3295
|
}
|
|
3294
3296
|
sendEvent(roomId, threadIdOrEventType, eventTypeOrContent, contentOrTxnId, txnIdOrVoid) {
|
|
3295
|
-
var _mRelates_to;
|
|
3296
3297
|
var threadId;
|
|
3297
3298
|
var eventType;
|
|
3298
3299
|
var content;
|
|
@@ -3308,12 +3309,22 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
3308
3309
|
eventType = eventTypeOrContent;
|
|
3309
3310
|
threadId = threadIdOrEventType;
|
|
3310
3311
|
}
|
|
3312
|
+
this.addThreadRelationIfNeeded(content, threadId, roomId);
|
|
3313
|
+
return this.sendCompleteEvent(roomId, threadId, {
|
|
3314
|
+
type: eventType,
|
|
3315
|
+
content
|
|
3316
|
+
}, txnId);
|
|
3317
|
+
}
|
|
3311
3318
|
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3319
|
+
/**
|
|
3320
|
+
* If we expect that an event is part of a thread but is missing the relation
|
|
3321
|
+
* we need to add it manually, as well as the reply fallback
|
|
3322
|
+
*/
|
|
3323
|
+
addThreadRelationIfNeeded(content, threadId, roomId) {
|
|
3324
|
+
var _content$mRelates_to;
|
|
3325
|
+
if (threadId && !((_content$mRelates_to = content["m.relates_to"]) !== null && _content$mRelates_to !== void 0 && _content$mRelates_to.rel_type)) {
|
|
3326
|
+
var _content$mRelates_to2, _this$getRoom;
|
|
3327
|
+
var isReply = !!((_content$mRelates_to2 = content["m.relates_to"]) !== null && _content$mRelates_to2 !== void 0 && _content$mRelates_to2["m.in_reply_to"]);
|
|
3317
3328
|
content["m.relates_to"] = _objectSpread(_objectSpread({}, content["m.relates_to"]), {}, {
|
|
3318
3329
|
rel_type: THREAD_RELATION_TYPE.name,
|
|
3319
3330
|
event_id: threadId,
|
|
@@ -3330,10 +3341,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
3330
3341
|
};
|
|
3331
3342
|
}
|
|
3332
3343
|
}
|
|
3333
|
-
return this.sendCompleteEvent(roomId, threadId, {
|
|
3334
|
-
type: eventType,
|
|
3335
|
-
content
|
|
3336
|
-
}, txnId);
|
|
3337
3344
|
}
|
|
3338
3345
|
|
|
3339
3346
|
/**
|
|
@@ -3342,7 +3349,25 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
3342
3349
|
* @returns Promise which resolves: to an empty object `{}`
|
|
3343
3350
|
* @returns Rejects: with an error response.
|
|
3344
3351
|
*/
|
|
3345
|
-
|
|
3352
|
+
|
|
3353
|
+
/**
|
|
3354
|
+
* Sends a delayed event (MSC4140).
|
|
3355
|
+
* @param eventObject - An object with the partial structure of an event, to which event_id, user_id, room_id and origin_server_ts will be added.
|
|
3356
|
+
* @param delayOpts - Properties of the delay for this event.
|
|
3357
|
+
* @param txnId - Optional.
|
|
3358
|
+
* @returns Promise which resolves: to an empty object `{}`
|
|
3359
|
+
* @returns Rejects: with an error response.
|
|
3360
|
+
*/
|
|
3361
|
+
|
|
3362
|
+
sendCompleteEvent(roomId, threadId, eventObject, delayOptsOrTxnId, txnIdOrVoid) {
|
|
3363
|
+
var delayOpts;
|
|
3364
|
+
var txnId;
|
|
3365
|
+
if (typeof delayOptsOrTxnId === "string") {
|
|
3366
|
+
txnId = delayOptsOrTxnId;
|
|
3367
|
+
} else {
|
|
3368
|
+
delayOpts = delayOptsOrTxnId;
|
|
3369
|
+
txnId = txnIdOrVoid;
|
|
3370
|
+
}
|
|
3346
3371
|
if (!txnId) {
|
|
3347
3372
|
txnId = this.makeTxnId();
|
|
3348
3373
|
}
|
|
@@ -3361,10 +3386,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
3361
3386
|
if (thread) {
|
|
3362
3387
|
localEvent.setThread(thread);
|
|
3363
3388
|
}
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3389
|
+
if (!delayOpts) {
|
|
3390
|
+
// set up re-emitter for this new event - this is normally the job of EventMapper but we don't use it here
|
|
3391
|
+
this.reEmitter.reEmit(localEvent, [MatrixEventEvent.Replaced, MatrixEventEvent.VisibilityChange]);
|
|
3392
|
+
room === null || room === void 0 || room.reEmitter.reEmit(localEvent, [MatrixEventEvent.BeforeRedaction]);
|
|
3393
|
+
}
|
|
3368
3394
|
|
|
3369
3395
|
// if this is a relation or redaction of an event
|
|
3370
3396
|
// that hasn't been sent yet (e.g. with a local id starting with a ~)
|
|
@@ -3378,29 +3404,45 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
3378
3404
|
});
|
|
3379
3405
|
}
|
|
3380
3406
|
var type = localEvent.getType();
|
|
3381
|
-
this.logger.debug("sendEvent of type ".concat(type, " in ").concat(roomId, " with txnId ").concat(txnId));
|
|
3407
|
+
this.logger.debug("sendEvent of type ".concat(type, " in ").concat(roomId, " with txnId ").concat(txnId).concat(delayOpts ? " (delayed event)" : ""));
|
|
3382
3408
|
localEvent.setTxnId(txnId);
|
|
3383
3409
|
localEvent.setStatus(EventStatus.SENDING);
|
|
3384
3410
|
|
|
3385
|
-
//
|
|
3386
|
-
|
|
3411
|
+
// TODO: separate store for delayed events?
|
|
3412
|
+
if (!delayOpts) {
|
|
3413
|
+
// add this event immediately to the local store as 'sending'.
|
|
3414
|
+
room === null || room === void 0 || room.addPendingEvent(localEvent, txnId);
|
|
3387
3415
|
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3416
|
+
// addPendingEvent can change the state to NOT_SENT if it believes
|
|
3417
|
+
// that there's other events that have failed. We won't bother to
|
|
3418
|
+
// try sending the event if the state has changed as such.
|
|
3419
|
+
if (localEvent.status === EventStatus.NOT_SENT) {
|
|
3420
|
+
return Promise.reject(new Error("Event blocked by other events not yet sent"));
|
|
3421
|
+
}
|
|
3422
|
+
return this.encryptAndSendEvent(room, localEvent);
|
|
3423
|
+
} else {
|
|
3424
|
+
return this.encryptAndSendEvent(room, localEvent, delayOpts);
|
|
3393
3425
|
}
|
|
3394
|
-
return this.encryptAndSendEvent(room, localEvent);
|
|
3395
3426
|
}
|
|
3396
3427
|
|
|
3397
3428
|
/**
|
|
3398
3429
|
* encrypts the event if necessary; adds the event to the queue, or sends it; marks the event as sent/unsent
|
|
3399
3430
|
* @returns returns a promise which resolves with the result of the send request
|
|
3400
3431
|
*/
|
|
3401
|
-
|
|
3432
|
+
|
|
3433
|
+
/**
|
|
3434
|
+
* Simply sends a delayed event without encrypting it.
|
|
3435
|
+
* TODO: Allow encrypted delayed events, and encrypt them properly
|
|
3436
|
+
* @param delayOpts - Properties of the delay for this event.
|
|
3437
|
+
* @returns returns a promise which resolves with the result of the delayed send request
|
|
3438
|
+
*/
|
|
3439
|
+
|
|
3440
|
+
encryptAndSendEvent(room, event, delayOpts) {
|
|
3402
3441
|
var _this35 = this;
|
|
3403
3442
|
return _asyncToGenerator(function* () {
|
|
3443
|
+
if (delayOpts) {
|
|
3444
|
+
return _this35.sendEventHttpRequest(event, delayOpts);
|
|
3445
|
+
}
|
|
3404
3446
|
try {
|
|
3405
3447
|
var cancelled;
|
|
3406
3448
|
_this35.eventsBeingEncrypted.add(event.getId());
|
|
@@ -3544,7 +3586,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
3544
3586
|
event.setStatus(newStatus);
|
|
3545
3587
|
}
|
|
3546
3588
|
}
|
|
3547
|
-
sendEventHttpRequest(event) {
|
|
3589
|
+
sendEventHttpRequest(event, delayOpts) {
|
|
3548
3590
|
var txnId = event.getTxnId();
|
|
3549
3591
|
if (!txnId) {
|
|
3550
3592
|
txnId = this.makeTxnId();
|
|
@@ -3571,10 +3613,15 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
3571
3613
|
} else {
|
|
3572
3614
|
path = utils.encodeUri("/rooms/$roomId/send/$eventType/$txnId", pathParams);
|
|
3573
3615
|
}
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
return res
|
|
3577
|
-
|
|
3616
|
+
var content = event.getWireContent();
|
|
3617
|
+
if (!delayOpts) {
|
|
3618
|
+
return this.http.authedRequest(Method.Put, path, undefined, content).then(res => {
|
|
3619
|
+
this.logger.debug("Event sent to ".concat(event.getRoomId(), " with event id ").concat(res.event_id));
|
|
3620
|
+
return res;
|
|
3621
|
+
});
|
|
3622
|
+
} else {
|
|
3623
|
+
return this.http.authedRequest(Method.Put, path, getUnstableDelayQueryOpts(delayOpts), content);
|
|
3624
|
+
}
|
|
3578
3625
|
}
|
|
3579
3626
|
|
|
3580
3627
|
/**
|
|
@@ -3773,6 +3820,103 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
3773
3820
|
return this.sendMessage(roomId, threadId, content);
|
|
3774
3821
|
}
|
|
3775
3822
|
|
|
3823
|
+
/**
|
|
3824
|
+
* Send a delayed timeline event.
|
|
3825
|
+
*
|
|
3826
|
+
* Note: This endpoint is unstable, and can throw an `Error`.
|
|
3827
|
+
* Check progress on [MSC4140](https://github.com/matrix-org/matrix-spec-proposals/pull/4140) for more details.
|
|
3828
|
+
*/
|
|
3829
|
+
// eslint-disable-next-line
|
|
3830
|
+
_unstable_sendDelayedEvent(roomId, delayOpts, threadId, eventType, content, txnId) {
|
|
3831
|
+
var _this38 = this;
|
|
3832
|
+
return _asyncToGenerator(function* () {
|
|
3833
|
+
if (!(yield _this38.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
|
3834
|
+
throw Error("Server does not support the delayed events API");
|
|
3835
|
+
}
|
|
3836
|
+
_this38.addThreadRelationIfNeeded(content, threadId, roomId);
|
|
3837
|
+
return _this38.sendCompleteEvent(roomId, threadId, {
|
|
3838
|
+
type: eventType,
|
|
3839
|
+
content
|
|
3840
|
+
}, delayOpts, txnId);
|
|
3841
|
+
})();
|
|
3842
|
+
}
|
|
3843
|
+
|
|
3844
|
+
/**
|
|
3845
|
+
* Send a delayed state event.
|
|
3846
|
+
*
|
|
3847
|
+
* Note: This endpoint is unstable, and can throw an `Error`.
|
|
3848
|
+
* Check progress on [MSC4140](https://github.com/matrix-org/matrix-spec-proposals/pull/4140) for more details.
|
|
3849
|
+
*/
|
|
3850
|
+
// eslint-disable-next-line
|
|
3851
|
+
_unstable_sendDelayedStateEvent(roomId, delayOpts, eventType, content) {
|
|
3852
|
+
var _arguments4 = arguments,
|
|
3853
|
+
_this39 = this;
|
|
3854
|
+
return _asyncToGenerator(function* () {
|
|
3855
|
+
var stateKey = _arguments4.length > 4 && _arguments4[4] !== undefined ? _arguments4[4] : "";
|
|
3856
|
+
var opts = _arguments4.length > 5 && _arguments4[5] !== undefined ? _arguments4[5] : {};
|
|
3857
|
+
if (!(yield _this39.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
|
3858
|
+
throw Error("Server does not support the delayed events API");
|
|
3859
|
+
}
|
|
3860
|
+
var pathParams = {
|
|
3861
|
+
$roomId: roomId,
|
|
3862
|
+
$eventType: eventType,
|
|
3863
|
+
$stateKey: stateKey
|
|
3864
|
+
};
|
|
3865
|
+
var path = utils.encodeUri("/rooms/$roomId/state/$eventType", pathParams);
|
|
3866
|
+
if (stateKey !== undefined) {
|
|
3867
|
+
path = utils.encodeUri(path + "/$stateKey", pathParams);
|
|
3868
|
+
}
|
|
3869
|
+
return _this39.http.authedRequest(Method.Put, path, getUnstableDelayQueryOpts(delayOpts), content, opts);
|
|
3870
|
+
})();
|
|
3871
|
+
}
|
|
3872
|
+
|
|
3873
|
+
/**
|
|
3874
|
+
* Get all pending delayed events for the calling user.
|
|
3875
|
+
*
|
|
3876
|
+
* Note: This endpoint is unstable, and can throw an `Error`.
|
|
3877
|
+
* Check progress on [MSC4140](https://github.com/matrix-org/matrix-spec-proposals/pull/4140) for more details.
|
|
3878
|
+
*/
|
|
3879
|
+
// eslint-disable-next-line
|
|
3880
|
+
_unstable_getDelayedEvents(fromToken) {
|
|
3881
|
+
var _this40 = this;
|
|
3882
|
+
return _asyncToGenerator(function* () {
|
|
3883
|
+
if (!(yield _this40.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
|
3884
|
+
throw Error("Server does not support the delayed events API");
|
|
3885
|
+
}
|
|
3886
|
+
var queryDict = fromToken ? {
|
|
3887
|
+
from: fromToken
|
|
3888
|
+
} : undefined;
|
|
3889
|
+
return yield _this40.http.authedRequest(Method.Get, "/delayed_events", queryDict, undefined, {
|
|
3890
|
+
prefix: "".concat(ClientPrefix.Unstable, "/").concat(UNSTABLE_MSC4140_DELAYED_EVENTS)
|
|
3891
|
+
});
|
|
3892
|
+
})();
|
|
3893
|
+
}
|
|
3894
|
+
|
|
3895
|
+
/**
|
|
3896
|
+
* Manage a delayed event associated with the given delay_id.
|
|
3897
|
+
*
|
|
3898
|
+
* Note: This endpoint is unstable, and can throw an `Error`.
|
|
3899
|
+
* Check progress on [MSC4140](https://github.com/matrix-org/matrix-spec-proposals/pull/4140) for more details.
|
|
3900
|
+
*/
|
|
3901
|
+
// eslint-disable-next-line
|
|
3902
|
+
_unstable_updateDelayedEvent(delayId, action) {
|
|
3903
|
+
var _this41 = this;
|
|
3904
|
+
return _asyncToGenerator(function* () {
|
|
3905
|
+
if (!(yield _this41.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
|
3906
|
+
throw Error("Server does not support the delayed events API");
|
|
3907
|
+
}
|
|
3908
|
+
var path = utils.encodeUri("/delayed_events/$delayId", {
|
|
3909
|
+
$delayId: delayId
|
|
3910
|
+
});
|
|
3911
|
+
var data = {
|
|
3912
|
+
action
|
|
3913
|
+
};
|
|
3914
|
+
return yield _this41.http.authedRequest(Method.Post, path, undefined, data, {
|
|
3915
|
+
prefix: "".concat(ClientPrefix.Unstable, "/").concat(UNSTABLE_MSC4140_DELAYED_EVENTS)
|
|
3916
|
+
});
|
|
3917
|
+
})();
|
|
3918
|
+
}
|
|
3919
|
+
|
|
3776
3920
|
/**
|
|
3777
3921
|
* Send a receipt.
|
|
3778
3922
|
* @param event - The event being acknowledged
|
|
@@ -3784,11 +3928,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
3784
3928
|
* @returns Rejects: with an error response.
|
|
3785
3929
|
*/
|
|
3786
3930
|
sendReceipt(event, receiptType, body) {
|
|
3787
|
-
var
|
|
3788
|
-
|
|
3931
|
+
var _arguments5 = arguments,
|
|
3932
|
+
_this42 = this;
|
|
3789
3933
|
return _asyncToGenerator(function* () {
|
|
3790
|
-
var unthreaded =
|
|
3791
|
-
if (
|
|
3934
|
+
var unthreaded = _arguments5.length > 3 && _arguments5[3] !== undefined ? _arguments5[3] : false;
|
|
3935
|
+
if (_this42.isGuest()) {
|
|
3792
3936
|
return Promise.resolve({}); // guests cannot send receipts so don't bother.
|
|
3793
3937
|
}
|
|
3794
3938
|
var path = utils.encodeUri("/rooms/$roomId/receipt/$receiptType/$eventId", {
|
|
@@ -3799,14 +3943,14 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
3799
3943
|
|
|
3800
3944
|
// Unless we're explicitly making an unthreaded receipt or we don't
|
|
3801
3945
|
// support threads, include the `thread_id` property in the body.
|
|
3802
|
-
var shouldAddThreadId = !unthreaded &&
|
|
3946
|
+
var shouldAddThreadId = !unthreaded && _this42.supportsThreads();
|
|
3803
3947
|
var fullBody = shouldAddThreadId ? _objectSpread(_objectSpread({}, body), {}, {
|
|
3804
3948
|
thread_id: threadIdForReceipt(event)
|
|
3805
3949
|
}) : body;
|
|
3806
|
-
var promise =
|
|
3807
|
-
var room =
|
|
3808
|
-
if (room &&
|
|
3809
|
-
room.addLocalEchoReceipt(
|
|
3950
|
+
var promise = _this42.http.authedRequest(Method.Post, path, undefined, fullBody || {});
|
|
3951
|
+
var room = _this42.getRoom(event.getRoomId());
|
|
3952
|
+
if (room && _this42.credentials.userId) {
|
|
3953
|
+
room.addLocalEchoReceipt(_this42.credentials.userId, event, receiptType, unthreaded);
|
|
3810
3954
|
}
|
|
3811
3955
|
return promise;
|
|
3812
3956
|
})();
|
|
@@ -3820,18 +3964,18 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
3820
3964
|
* @returns Rejects: with an error response.
|
|
3821
3965
|
*/
|
|
3822
3966
|
sendReadReceipt(event) {
|
|
3823
|
-
var
|
|
3824
|
-
|
|
3967
|
+
var _arguments6 = arguments,
|
|
3968
|
+
_this43 = this;
|
|
3825
3969
|
return _asyncToGenerator(function* () {
|
|
3826
|
-
var receiptType =
|
|
3827
|
-
var unthreaded =
|
|
3970
|
+
var receiptType = _arguments6.length > 1 && _arguments6[1] !== undefined ? _arguments6[1] : ReceiptType.Read;
|
|
3971
|
+
var unthreaded = _arguments6.length > 2 && _arguments6[2] !== undefined ? _arguments6[2] : false;
|
|
3828
3972
|
if (!event) return;
|
|
3829
3973
|
var eventId = event.getId();
|
|
3830
|
-
var room =
|
|
3974
|
+
var room = _this43.getRoom(event.getRoomId());
|
|
3831
3975
|
if (room !== null && room !== void 0 && room.hasPendingEvent(eventId)) {
|
|
3832
3976
|
throw new Error("Cannot set read receipt to a pending event (".concat(eventId, ")"));
|
|
3833
3977
|
}
|
|
3834
|
-
return
|
|
3978
|
+
return _this43.sendReceipt(event, receiptType, {}, unthreaded);
|
|
3835
3979
|
})();
|
|
3836
3980
|
}
|
|
3837
3981
|
|
|
@@ -3850,9 +3994,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
3850
3994
|
* @returns Promise which resolves: the empty object, `{}`.
|
|
3851
3995
|
*/
|
|
3852
3996
|
setRoomReadMarkers(roomId, rmEventId, rrEvent, rpEvent) {
|
|
3853
|
-
var
|
|
3997
|
+
var _this44 = this;
|
|
3854
3998
|
return _asyncToGenerator(function* () {
|
|
3855
|
-
var room =
|
|
3999
|
+
var room = _this44.getRoom(roomId);
|
|
3856
4000
|
if (room !== null && room !== void 0 && room.hasPendingEvent(rmEventId)) {
|
|
3857
4001
|
throw new Error("Cannot set read marker to a pending event (".concat(rmEventId, ")"));
|
|
3858
4002
|
}
|
|
@@ -3864,7 +4008,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
3864
4008
|
if (room !== null && room !== void 0 && room.hasPendingEvent(rrEventId)) {
|
|
3865
4009
|
throw new Error("Cannot set read receipt to a pending event (".concat(rrEventId, ")"));
|
|
3866
4010
|
}
|
|
3867
|
-
room === null || room === void 0 || room.addLocalEchoReceipt(
|
|
4011
|
+
room === null || room === void 0 || room.addLocalEchoReceipt(_this44.credentials.userId, rrEvent, ReceiptType.Read);
|
|
3868
4012
|
}
|
|
3869
4013
|
|
|
3870
4014
|
// Add the optional private RR update, do local echo like `sendReceipt`
|
|
@@ -3874,9 +4018,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
3874
4018
|
if (room !== null && room !== void 0 && room.hasPendingEvent(rpEventId)) {
|
|
3875
4019
|
throw new Error("Cannot set read receipt to a pending event (".concat(rpEventId, ")"));
|
|
3876
4020
|
}
|
|
3877
|
-
room === null || room === void 0 || room.addLocalEchoReceipt(
|
|
4021
|
+
room === null || room === void 0 || room.addLocalEchoReceipt(_this44.credentials.userId, rpEvent, ReceiptType.ReadPrivate);
|
|
3878
4022
|
}
|
|
3879
|
-
return yield
|
|
4023
|
+
return yield _this44.setRoomReadMarkersHttpRequest(roomId, rmEventId, rrEventId, rpEventId);
|
|
3880
4024
|
})();
|
|
3881
4025
|
}
|
|
3882
4026
|
|
|
@@ -4055,13 +4199,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4055
4199
|
* @returns Rejects: with an error response.
|
|
4056
4200
|
*/
|
|
4057
4201
|
inviteByThreePid(roomId, medium, address) {
|
|
4058
|
-
var
|
|
4202
|
+
var _this45 = this;
|
|
4059
4203
|
return _asyncToGenerator(function* () {
|
|
4060
|
-
var
|
|
4204
|
+
var _this45$identityServe;
|
|
4061
4205
|
var path = utils.encodeUri("/rooms/$roomId/invite", {
|
|
4062
4206
|
$roomId: roomId
|
|
4063
4207
|
});
|
|
4064
|
-
var identityServerUrl =
|
|
4208
|
+
var identityServerUrl = _this45.getIdentityServerUrl(true);
|
|
4065
4209
|
if (!identityServerUrl) {
|
|
4066
4210
|
return Promise.reject(new MatrixError({
|
|
4067
4211
|
error: "No supplied identity server URL",
|
|
@@ -4073,13 +4217,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4073
4217
|
medium: medium,
|
|
4074
4218
|
address: address
|
|
4075
4219
|
};
|
|
4076
|
-
if ((
|
|
4077
|
-
var identityAccessToken = yield
|
|
4220
|
+
if ((_this45$identityServe = _this45.identityServer) !== null && _this45$identityServe !== void 0 && _this45$identityServe.getAccessToken) {
|
|
4221
|
+
var identityAccessToken = yield _this45.identityServer.getAccessToken();
|
|
4078
4222
|
if (identityAccessToken) {
|
|
4079
4223
|
params["id_access_token"] = identityAccessToken;
|
|
4080
4224
|
}
|
|
4081
4225
|
}
|
|
4082
|
-
return
|
|
4226
|
+
return _this45.http.authedRequest(Method.Post, path, undefined, params);
|
|
4083
4227
|
})();
|
|
4084
4228
|
}
|
|
4085
4229
|
|
|
@@ -4108,9 +4252,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4108
4252
|
var eligibleToLeave = upgradeHistory;
|
|
4109
4253
|
if (!includeFuture) {
|
|
4110
4254
|
eligibleToLeave = [];
|
|
4111
|
-
for (var
|
|
4112
|
-
eligibleToLeave.push(
|
|
4113
|
-
if (
|
|
4255
|
+
for (var _room2 of upgradeHistory) {
|
|
4256
|
+
eligibleToLeave.push(_room2);
|
|
4257
|
+
if (_room2.roomId === roomId) {
|
|
4114
4258
|
break;
|
|
4115
4259
|
}
|
|
4116
4260
|
}
|
|
@@ -4125,8 +4269,8 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4125
4269
|
populationResults[roomId] = err;
|
|
4126
4270
|
});
|
|
4127
4271
|
};
|
|
4128
|
-
for (var
|
|
4129
|
-
promises.push(doLeave(
|
|
4272
|
+
for (var _room3 of eligibleToLeave) {
|
|
4273
|
+
promises.push(doLeave(_room3.roomId));
|
|
4130
4274
|
}
|
|
4131
4275
|
return Promise.all(promises).then(() => populationResults);
|
|
4132
4276
|
}
|
|
@@ -4267,13 +4411,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4267
4411
|
* @returns Rejects: with an error response.
|
|
4268
4412
|
*/
|
|
4269
4413
|
setDisplayName(name) {
|
|
4270
|
-
var
|
|
4414
|
+
var _this46 = this;
|
|
4271
4415
|
return _asyncToGenerator(function* () {
|
|
4272
|
-
var prom = yield
|
|
4416
|
+
var prom = yield _this46.setProfileInfo("displayname", {
|
|
4273
4417
|
displayname: name
|
|
4274
4418
|
});
|
|
4275
4419
|
// XXX: synthesise a profile update for ourselves because Synapse is broken and won't
|
|
4276
|
-
var user =
|
|
4420
|
+
var user = _this46.getUser(_this46.getUserId());
|
|
4277
4421
|
if (user) {
|
|
4278
4422
|
user.displayName = name;
|
|
4279
4423
|
user.emit(UserEvent.DisplayName, user.events.presence, user);
|
|
@@ -4287,13 +4431,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4287
4431
|
* @returns Rejects: with an error response.
|
|
4288
4432
|
*/
|
|
4289
4433
|
setAvatarUrl(url) {
|
|
4290
|
-
var
|
|
4434
|
+
var _this47 = this;
|
|
4291
4435
|
return _asyncToGenerator(function* () {
|
|
4292
|
-
var prom = yield
|
|
4436
|
+
var prom = yield _this47.setProfileInfo("avatar_url", {
|
|
4293
4437
|
avatar_url: url
|
|
4294
4438
|
});
|
|
4295
4439
|
// XXX: synthesise a profile update for ourselves because Synapse is broken and won't
|
|
4296
|
-
var user =
|
|
4440
|
+
var user = _this47.getUser(_this47.getUserId());
|
|
4297
4441
|
if (user) {
|
|
4298
4442
|
user.avatarUrl = url;
|
|
4299
4443
|
user.emit(UserEvent.AvatarUrl, user.events.presence, user);
|
|
@@ -4334,10 +4478,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4334
4478
|
* @param presence - the presence to specify to set_presence of sync calls
|
|
4335
4479
|
*/
|
|
4336
4480
|
setSyncPresence(presence) {
|
|
4337
|
-
var
|
|
4481
|
+
var _this48 = this;
|
|
4338
4482
|
return _asyncToGenerator(function* () {
|
|
4339
|
-
var
|
|
4340
|
-
(
|
|
4483
|
+
var _this48$syncApi;
|
|
4484
|
+
(_this48$syncApi = _this48.syncApi) === null || _this48$syncApi === void 0 || _this48$syncApi.setPresence(presence);
|
|
4341
4485
|
})();
|
|
4342
4486
|
}
|
|
4343
4487
|
|
|
@@ -4348,16 +4492,16 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4348
4492
|
* @throws If 'presence' isn't a valid presence enum value.
|
|
4349
4493
|
*/
|
|
4350
4494
|
setPresence(opts) {
|
|
4351
|
-
var
|
|
4495
|
+
var _this49 = this;
|
|
4352
4496
|
return _asyncToGenerator(function* () {
|
|
4353
4497
|
var path = utils.encodeUri("/presence/$userId/status", {
|
|
4354
|
-
$userId:
|
|
4498
|
+
$userId: _this49.credentials.userId
|
|
4355
4499
|
});
|
|
4356
4500
|
var validStates = ["offline", "online", "unavailable"];
|
|
4357
4501
|
if (validStates.indexOf(opts.presence) === -1) {
|
|
4358
4502
|
throw new Error("Bad presence value: " + opts.presence);
|
|
4359
4503
|
}
|
|
4360
|
-
yield
|
|
4504
|
+
yield _this49.http.authedRequest(Method.Put, path, undefined, opts);
|
|
4361
4505
|
})();
|
|
4362
4506
|
}
|
|
4363
4507
|
|
|
@@ -4466,11 +4610,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4466
4610
|
* {@link EventTimeline} including the given event
|
|
4467
4611
|
*/
|
|
4468
4612
|
getEventTimeline(timelineSet, eventId) {
|
|
4469
|
-
var
|
|
4613
|
+
var _this50 = this;
|
|
4470
4614
|
return _asyncToGenerator(function* () {
|
|
4471
|
-
var
|
|
4615
|
+
var _this50$clientOpts, _ref5, _timelineSet$getTimel, _timelineSet$room$fin;
|
|
4472
4616
|
// don't allow any timeline support unless it's been enabled.
|
|
4473
|
-
if (!
|
|
4617
|
+
if (!_this50.timelineSupport) {
|
|
4474
4618
|
throw new Error("timeline support is disabled. Set the 'timelineSupport'" + " parameter to true when creating MatrixClient to enable it.");
|
|
4475
4619
|
}
|
|
4476
4620
|
if (!(timelineSet !== null && timelineSet !== void 0 && timelineSet.room)) {
|
|
@@ -4479,22 +4623,22 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4479
4623
|
if (timelineSet.getTimelineForEvent(eventId)) {
|
|
4480
4624
|
return timelineSet.getTimelineForEvent(eventId);
|
|
4481
4625
|
}
|
|
4482
|
-
if (timelineSet.thread &&
|
|
4483
|
-
return
|
|
4626
|
+
if (timelineSet.thread && _this50.supportsThreads()) {
|
|
4627
|
+
return _this50.getThreadTimeline(timelineSet, eventId);
|
|
4484
4628
|
}
|
|
4485
4629
|
var path = utils.encodeUri("/rooms/$roomId/context/$eventId", {
|
|
4486
4630
|
$roomId: timelineSet.room.roomId,
|
|
4487
4631
|
$eventId: eventId
|
|
4488
4632
|
});
|
|
4489
4633
|
var params = undefined;
|
|
4490
|
-
if ((
|
|
4634
|
+
if ((_this50$clientOpts = _this50.clientOpts) !== null && _this50$clientOpts !== void 0 && _this50$clientOpts.lazyLoadMembers) {
|
|
4491
4635
|
params = {
|
|
4492
4636
|
filter: JSON.stringify(Filter.LAZY_LOADING_MESSAGES_FILTER)
|
|
4493
4637
|
};
|
|
4494
4638
|
}
|
|
4495
4639
|
|
|
4496
4640
|
// TODO: we should implement a backoff (as per scrollback()) to deal more nicely with HTTP errors.
|
|
4497
|
-
var res = yield
|
|
4641
|
+
var res = yield _this50.http.authedRequest(Method.Get, path, params);
|
|
4498
4642
|
if (!res.event) {
|
|
4499
4643
|
throw new Error("'event' not in '/context' result - homeserver too old?");
|
|
4500
4644
|
}
|
|
@@ -4503,10 +4647,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4503
4647
|
if (timelineSet.getTimelineForEvent(eventId)) {
|
|
4504
4648
|
return timelineSet.getTimelineForEvent(eventId);
|
|
4505
4649
|
}
|
|
4506
|
-
var mapper =
|
|
4650
|
+
var mapper = _this50.getEventMapper();
|
|
4507
4651
|
var event = mapper(res.event);
|
|
4508
4652
|
if (event.isRelation(THREAD_RELATION_TYPE.name)) {
|
|
4509
|
-
|
|
4653
|
+
_this50.logger.warn("Tried loading a regular timeline at the position of a thread event");
|
|
4510
4654
|
return undefined;
|
|
4511
4655
|
}
|
|
4512
4656
|
var events = [
|
|
@@ -4527,8 +4671,8 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4527
4671
|
var [timelineEvents, threadedEvents, unknownRelations] = timelineSet.room.partitionThreadedEvents(events);
|
|
4528
4672
|
timelineSet.addEventsToTimeline(timelineEvents, true, timeline, res.start);
|
|
4529
4673
|
// The target event is not in a thread but process the contextual events, so we can show any threads around it.
|
|
4530
|
-
|
|
4531
|
-
|
|
4674
|
+
_this50.processThreadEvents(timelineSet.room, threadedEvents, true);
|
|
4675
|
+
_this50.processAggregatedTimelineEvents(timelineSet.room, timelineEvents);
|
|
4532
4676
|
unknownRelations.forEach(event => timelineSet.relations.aggregateChildEvent(event));
|
|
4533
4677
|
|
|
4534
4678
|
// There is no guarantee that the event ended up in "timeline" (we might have switched to a neighbouring
|
|
@@ -4540,10 +4684,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4540
4684
|
})();
|
|
4541
4685
|
}
|
|
4542
4686
|
getThreadTimeline(timelineSet, eventId) {
|
|
4543
|
-
var
|
|
4687
|
+
var _this51 = this;
|
|
4544
4688
|
return _asyncToGenerator(function* () {
|
|
4545
|
-
var
|
|
4546
|
-
if (!
|
|
4689
|
+
var _this51$clientOpts;
|
|
4690
|
+
if (!_this51.supportsThreads()) {
|
|
4547
4691
|
throw new Error("could not get thread timeline: no client support");
|
|
4548
4692
|
}
|
|
4549
4693
|
if (!timelineSet.room) {
|
|
@@ -4559,18 +4703,18 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4559
4703
|
var params = {
|
|
4560
4704
|
limit: "0"
|
|
4561
4705
|
};
|
|
4562
|
-
if ((
|
|
4706
|
+
if ((_this51$clientOpts = _this51.clientOpts) !== null && _this51$clientOpts !== void 0 && _this51$clientOpts.lazyLoadMembers) {
|
|
4563
4707
|
params.filter = JSON.stringify(Filter.LAZY_LOADING_MESSAGES_FILTER);
|
|
4564
4708
|
}
|
|
4565
4709
|
|
|
4566
4710
|
// TODO: we should implement a backoff (as per scrollback()) to deal more nicely with HTTP errors.
|
|
4567
|
-
var res = yield
|
|
4568
|
-
var mapper =
|
|
4711
|
+
var res = yield _this51.http.authedRequest(Method.Get, path, params);
|
|
4712
|
+
var mapper = _this51.getEventMapper();
|
|
4569
4713
|
var event = mapper(res.event);
|
|
4570
4714
|
if (!timelineSet.canContain(event)) {
|
|
4571
4715
|
return undefined;
|
|
4572
4716
|
}
|
|
4573
|
-
var recurse =
|
|
4717
|
+
var recurse = _this51.canSupport.get(Feature.RelationsRecursion) !== ServerSupport.Unsupported;
|
|
4574
4718
|
if (Thread.hasServerSideSupport) {
|
|
4575
4719
|
if (Thread.hasServerSideFwdPaginationSupport) {
|
|
4576
4720
|
var _resOlder$next_batch, _resNewer$next_batch, _timelineSet$getTimel2;
|
|
@@ -4578,12 +4722,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4578
4722
|
throw new Error("could not get thread timeline: not a thread timeline");
|
|
4579
4723
|
}
|
|
4580
4724
|
var thread = timelineSet.thread;
|
|
4581
|
-
var resOlder = yield
|
|
4725
|
+
var resOlder = yield _this51.fetchRelations(timelineSet.room.roomId, thread.id, null, null, {
|
|
4582
4726
|
dir: Direction.Backward,
|
|
4583
4727
|
from: res.start,
|
|
4584
4728
|
recurse: recurse || undefined
|
|
4585
4729
|
});
|
|
4586
|
-
var resNewer = yield
|
|
4730
|
+
var resNewer = yield _this51.fetchRelations(timelineSet.room.roomId, thread.id, null, null, {
|
|
4587
4731
|
dir: Direction.Forward,
|
|
4588
4732
|
from: res.end,
|
|
4589
4733
|
recurse: recurse || undefined
|
|
@@ -4593,9 +4737,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4593
4737
|
// We start with the last event, since that's the point at which we have known state.
|
|
4594
4738
|
// events_after is already backwards; events_before is forwards.
|
|
4595
4739
|
...resNewer.chunk.reverse().filter(getRelationsThreadFilter(thread.id)).map(mapper), event, ...resOlder.chunk.filter(getRelationsThreadFilter(thread.id)).map(mapper)];
|
|
4596
|
-
for (var
|
|
4740
|
+
for (var _event2 of events) {
|
|
4597
4741
|
var _timelineSet$thread;
|
|
4598
|
-
yield (_timelineSet$thread = timelineSet.thread) === null || _timelineSet$thread === void 0 ? void 0 : _timelineSet$thread.processEvent(
|
|
4742
|
+
yield (_timelineSet$thread = timelineSet.thread) === null || _timelineSet$thread === void 0 ? void 0 : _timelineSet$thread.processEvent(_event2);
|
|
4599
4743
|
}
|
|
4600
4744
|
|
|
4601
4745
|
// Here we handle non-thread timelines only, but still process any thread events to populate thread summaries.
|
|
@@ -4608,12 +4752,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4608
4752
|
}
|
|
4609
4753
|
timelineSet.addEventsToTimeline(events, true, timeline, resNewer.next_batch);
|
|
4610
4754
|
if (!resOlder.next_batch) {
|
|
4611
|
-
var originalEvent = yield
|
|
4755
|
+
var originalEvent = yield _this51.fetchRoomEvent(timelineSet.room.roomId, thread.id);
|
|
4612
4756
|
timelineSet.addEventsToTimeline([mapper(originalEvent)], true, timeline, null);
|
|
4613
4757
|
}
|
|
4614
4758
|
timeline.setPaginationToken((_resOlder$next_batch = resOlder.next_batch) !== null && _resOlder$next_batch !== void 0 ? _resOlder$next_batch : null, Direction.Backward);
|
|
4615
4759
|
timeline.setPaginationToken((_resNewer$next_batch = resNewer.next_batch) !== null && _resNewer$next_batch !== void 0 ? _resNewer$next_batch : null, Direction.Forward);
|
|
4616
|
-
|
|
4760
|
+
_this51.processAggregatedTimelineEvents(timelineSet.room, events);
|
|
4617
4761
|
|
|
4618
4762
|
// There is no guarantee that the event ended up in "timeline" (we might have switched to a neighbouring
|
|
4619
4763
|
// timeline) - so check the room's index again. On the other hand, there's no guarantee the event ended up
|
|
@@ -4626,7 +4770,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4626
4770
|
// XXX: workaround for https://github.com/vector-im/element-meta/issues/150
|
|
4627
4771
|
|
|
4628
4772
|
var _thread = timelineSet.thread;
|
|
4629
|
-
var _resOlder = yield
|
|
4773
|
+
var _resOlder = yield _this51.fetchRelations(timelineSet.room.roomId, _thread.id, THREAD_RELATION_TYPE.name, null, {
|
|
4630
4774
|
dir: Direction.Backward,
|
|
4631
4775
|
from: res.start,
|
|
4632
4776
|
recurse: recurse || undefined
|
|
@@ -4635,7 +4779,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4635
4779
|
var nextBatch = res.end;
|
|
4636
4780
|
while (nextBatch) {
|
|
4637
4781
|
var _resNewer$next_batch2;
|
|
4638
|
-
var _resNewer = yield
|
|
4782
|
+
var _resNewer = yield _this51.fetchRelations(timelineSet.room.roomId, _thread.id, THREAD_RELATION_TYPE.name, null, {
|
|
4639
4783
|
dir: Direction.Forward,
|
|
4640
4784
|
from: nextBatch,
|
|
4641
4785
|
recurse: recurse || undefined
|
|
@@ -4648,9 +4792,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4648
4792
|
// We start with the last event, since that's the point at which we have known state.
|
|
4649
4793
|
// events_after is already backwards; events_before is forwards.
|
|
4650
4794
|
...eventsNewer.reverse().map(mapper), event, ..._resOlder.chunk.map(mapper)];
|
|
4651
|
-
for (var
|
|
4795
|
+
for (var _event3 of _events) {
|
|
4652
4796
|
var _timelineSet$thread2;
|
|
4653
|
-
yield (_timelineSet$thread2 = timelineSet.thread) === null || _timelineSet$thread2 === void 0 ? void 0 : _timelineSet$thread2.processEvent(
|
|
4797
|
+
yield (_timelineSet$thread2 = timelineSet.thread) === null || _timelineSet$thread2 === void 0 ? void 0 : _timelineSet$thread2.processEvent(_event3);
|
|
4654
4798
|
}
|
|
4655
4799
|
|
|
4656
4800
|
// Here we handle non-thread timelines only, but still process any thread events to populate thread
|
|
@@ -4659,12 +4803,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4659
4803
|
_timeline.getState(EventTimeline.BACKWARDS).setUnknownStateEvents(res.state.map(mapper));
|
|
4660
4804
|
timelineSet.addEventsToTimeline(_events, true, _timeline, null);
|
|
4661
4805
|
if (!_resOlder.next_batch) {
|
|
4662
|
-
var _originalEvent = yield
|
|
4806
|
+
var _originalEvent = yield _this51.fetchRoomEvent(timelineSet.room.roomId, _thread.id);
|
|
4663
4807
|
timelineSet.addEventsToTimeline([mapper(_originalEvent)], true, _timeline, null);
|
|
4664
4808
|
}
|
|
4665
4809
|
_timeline.setPaginationToken((_resOlder$next_batch2 = _resOlder.next_batch) !== null && _resOlder$next_batch2 !== void 0 ? _resOlder$next_batch2 : null, Direction.Backward);
|
|
4666
4810
|
_timeline.setPaginationToken(null, Direction.Forward);
|
|
4667
|
-
|
|
4811
|
+
_this51.processAggregatedTimelineEvents(timelineSet.room, _events);
|
|
4668
4812
|
return _timeline;
|
|
4669
4813
|
}
|
|
4670
4814
|
}
|
|
@@ -4682,10 +4826,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4682
4826
|
* {@link EventTimeline} timeline with the latest events in the room
|
|
4683
4827
|
*/
|
|
4684
4828
|
getLatestTimeline(timelineSet) {
|
|
4685
|
-
var
|
|
4829
|
+
var _this52 = this;
|
|
4686
4830
|
return _asyncToGenerator(function* () {
|
|
4687
4831
|
// don't allow any timeline support unless it's been enabled.
|
|
4688
|
-
if (!
|
|
4832
|
+
if (!_this52.timelineSupport) {
|
|
4689
4833
|
throw new Error("timeline support is disabled. Set the 'timelineSupport'" + " parameter to true when creating MatrixClient to enable it.");
|
|
4690
4834
|
}
|
|
4691
4835
|
if (!timelineSet.room) {
|
|
@@ -4694,35 +4838,35 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4694
4838
|
var event;
|
|
4695
4839
|
if (timelineSet.threadListType !== null) {
|
|
4696
4840
|
var _res$chunk;
|
|
4697
|
-
var res = yield
|
|
4841
|
+
var res = yield _this52.createThreadListMessagesRequest(timelineSet.room.roomId, null, 1, Direction.Backward, timelineSet.threadListType, timelineSet.getFilter());
|
|
4698
4842
|
event = (_res$chunk = res.chunk) === null || _res$chunk === void 0 ? void 0 : _res$chunk[0];
|
|
4699
4843
|
} else if (timelineSet.thread && Thread.hasServerSideSupport) {
|
|
4700
4844
|
var _res$chunk2;
|
|
4701
|
-
var recurse =
|
|
4702
|
-
var _res = yield
|
|
4845
|
+
var recurse = _this52.canSupport.get(Feature.RelationsRecursion) !== ServerSupport.Unsupported;
|
|
4846
|
+
var _res = yield _this52.fetchRelations(timelineSet.room.roomId, timelineSet.thread.id, THREAD_RELATION_TYPE.name, null, {
|
|
4703
4847
|
dir: Direction.Backward,
|
|
4704
4848
|
limit: 1,
|
|
4705
4849
|
recurse: recurse || undefined
|
|
4706
4850
|
});
|
|
4707
4851
|
event = (_res$chunk2 = _res.chunk) === null || _res$chunk2 === void 0 ? void 0 : _res$chunk2[0];
|
|
4708
4852
|
} else {
|
|
4709
|
-
var
|
|
4853
|
+
var _this52$clientOpts, _res2$chunk;
|
|
4710
4854
|
var messagesPath = utils.encodeUri("/rooms/$roomId/messages", {
|
|
4711
4855
|
$roomId: timelineSet.room.roomId
|
|
4712
4856
|
});
|
|
4713
4857
|
var params = {
|
|
4714
4858
|
dir: "b"
|
|
4715
4859
|
};
|
|
4716
|
-
if ((
|
|
4860
|
+
if ((_this52$clientOpts = _this52.clientOpts) !== null && _this52$clientOpts !== void 0 && _this52$clientOpts.lazyLoadMembers) {
|
|
4717
4861
|
params.filter = JSON.stringify(Filter.LAZY_LOADING_MESSAGES_FILTER);
|
|
4718
4862
|
}
|
|
4719
|
-
var _res2 = yield
|
|
4863
|
+
var _res2 = yield _this52.http.authedRequest(Method.Get, messagesPath, params);
|
|
4720
4864
|
event = (_res2$chunk = _res2.chunk) === null || _res2$chunk === void 0 ? void 0 : _res2$chunk[0];
|
|
4721
4865
|
}
|
|
4722
4866
|
if (!event) {
|
|
4723
4867
|
throw new Error("No message returned when trying to construct getLatestTimeline");
|
|
4724
4868
|
}
|
|
4725
|
-
return
|
|
4869
|
+
return _this52.getEventTimeline(timelineSet, event.event_id);
|
|
4726
4870
|
})();
|
|
4727
4871
|
}
|
|
4728
4872
|
|
|
@@ -4834,7 +4978,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4834
4978
|
* events and we reached either end of the timeline; else true.
|
|
4835
4979
|
*/
|
|
4836
4980
|
paginateEventTimeline(eventTimeline, opts) {
|
|
4837
|
-
var
|
|
4981
|
+
var _this53 = this;
|
|
4838
4982
|
var isNotifTimeline = eventTimeline.getTimelineSet() === this.notifTimelineSet;
|
|
4839
4983
|
var room = this.getRoom(eventTimeline.getRoomId());
|
|
4840
4984
|
var threadListType = eventTimeline.getTimelineSet().threadListType;
|
|
@@ -4876,20 +5020,20 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4876
5020
|
res.notifications = res.notifications.filter(noUnsafeEventProps);
|
|
4877
5021
|
for (var i = 0; i < res.notifications.length; i++) {
|
|
4878
5022
|
var notification = res.notifications[i];
|
|
4879
|
-
var
|
|
5023
|
+
var _event4 = _this53.getEventMapper()(notification.event);
|
|
4880
5024
|
|
|
4881
5025
|
// @TODO(kerrya) reprocessing every notification is ugly
|
|
4882
5026
|
// remove if we get server MSC3994 support
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
matrixEvents[i] =
|
|
5027
|
+
_this53.getPushDetailsForEvent(_event4, true);
|
|
5028
|
+
_event4.event.room_id = notification.room_id; // XXX: gutwrenching
|
|
5029
|
+
matrixEvents[i] = _event4;
|
|
4886
5030
|
}
|
|
4887
5031
|
|
|
4888
5032
|
// No need to partition events for threads here, everything lives
|
|
4889
5033
|
// in the notification timeline set
|
|
4890
5034
|
var timelineSet = eventTimeline.getTimelineSet();
|
|
4891
5035
|
timelineSet.addEventsToTimeline(matrixEvents, backwards, eventTimeline, token);
|
|
4892
|
-
|
|
5036
|
+
_this53.processAggregatedTimelineEvents(timelineSet.room, matrixEvents);
|
|
4893
5037
|
|
|
4894
5038
|
// if we've hit the end of the timeline, we need to stop trying to
|
|
4895
5039
|
// paginate. We need to keep the 'forwards' token though, to make sure
|
|
@@ -4939,8 +5083,8 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4939
5083
|
eventTimeline.paginationRequests[dir] = promise;
|
|
4940
5084
|
} else if (thread) {
|
|
4941
5085
|
var _eventTimeline$getRoo, _eventTimeline$getRoo2;
|
|
4942
|
-
var
|
|
4943
|
-
if (!
|
|
5086
|
+
var _room4 = this.getRoom((_eventTimeline$getRoo = eventTimeline.getRoomId()) !== null && _eventTimeline$getRoo !== void 0 ? _eventTimeline$getRoo : undefined);
|
|
5087
|
+
if (!_room4) {
|
|
4944
5088
|
throw new Error("Unknown room " + eventTimeline.getRoomId());
|
|
4945
5089
|
}
|
|
4946
5090
|
var recurse = this.canSupport.get(Feature.RelationsRecursion) !== ServerSupport.Unsupported;
|
|
@@ -4951,15 +5095,15 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4951
5095
|
recurse: recurse || undefined
|
|
4952
5096
|
}).then( /*#__PURE__*/function () {
|
|
4953
5097
|
var _ref7 = _asyncToGenerator(function* (res) {
|
|
4954
|
-
var mapper =
|
|
5098
|
+
var mapper = _this53.getEventMapper();
|
|
4955
5099
|
var matrixEvents = res.chunk.filter(noUnsafeEventProps).filter(getRelationsThreadFilter(thread.id)).map(mapper);
|
|
4956
5100
|
|
|
4957
5101
|
// Process latest events first
|
|
4958
|
-
for (var
|
|
4959
|
-
yield thread === null || thread === void 0 ? void 0 : thread.processEvent(
|
|
4960
|
-
var sender =
|
|
5102
|
+
for (var _event5 of matrixEvents.slice().reverse()) {
|
|
5103
|
+
yield thread === null || thread === void 0 ? void 0 : thread.processEvent(_event5);
|
|
5104
|
+
var sender = _event5.getSender();
|
|
4961
5105
|
if (!backwards || (thread === null || thread === void 0 ? void 0 : thread.getEventReadUpTo(sender)) === null) {
|
|
4962
|
-
|
|
5106
|
+
_room4.addLocalEchoReceipt(sender, _event5, ReceiptType.Read);
|
|
4963
5107
|
}
|
|
4964
5108
|
}
|
|
4965
5109
|
var newToken = res.next_batch;
|
|
@@ -4967,10 +5111,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
4967
5111
|
timelineSet.addEventsToTimeline(matrixEvents, backwards, eventTimeline, newToken !== null && newToken !== void 0 ? newToken : null);
|
|
4968
5112
|
if (!newToken && backwards) {
|
|
4969
5113
|
var _thread$rootEvent, _eventTimeline$getRoo3;
|
|
4970
|
-
var originalEvent = (_thread$rootEvent = thread.rootEvent) !== null && _thread$rootEvent !== void 0 ? _thread$rootEvent : mapper(yield
|
|
5114
|
+
var originalEvent = (_thread$rootEvent = thread.rootEvent) !== null && _thread$rootEvent !== void 0 ? _thread$rootEvent : mapper(yield _this53.fetchRoomEvent((_eventTimeline$getRoo3 = eventTimeline.getRoomId()) !== null && _eventTimeline$getRoo3 !== void 0 ? _eventTimeline$getRoo3 : "", thread.id));
|
|
4971
5115
|
timelineSet.addEventsToTimeline([originalEvent], true, eventTimeline, null);
|
|
4972
5116
|
}
|
|
4973
|
-
|
|
5117
|
+
_this53.processAggregatedTimelineEvents(timelineSet.room, matrixEvents);
|
|
4974
5118
|
|
|
4975
5119
|
// if we've hit the end of the timeline, we need to stop trying to
|
|
4976
5120
|
// paginate. We need to keep the 'forwards' token though, to make sure
|
|
@@ -5256,10 +5400,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
5256
5400
|
* @returns Promise which resolves: As requestEmailToken
|
|
5257
5401
|
*/
|
|
5258
5402
|
requestTokenFromEndpoint(endpoint, params) {
|
|
5259
|
-
var
|
|
5403
|
+
var _this54 = this;
|
|
5260
5404
|
return _asyncToGenerator(function* () {
|
|
5261
5405
|
var postParams = Object.assign({}, params);
|
|
5262
|
-
return
|
|
5406
|
+
return _this54.http.request(Method.Post, endpoint, undefined, postParams);
|
|
5263
5407
|
})();
|
|
5264
5408
|
}
|
|
5265
5409
|
|
|
@@ -5464,11 +5608,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
5464
5608
|
var resultsLength = (_roomEvents$results$l = (_roomEvents$results = roomEvents.results) === null || _roomEvents$results === void 0 ? void 0 : _roomEvents$results.length) !== null && _roomEvents$results$l !== void 0 ? _roomEvents$results$l : 0;
|
|
5465
5609
|
for (var i = 0; i < resultsLength; i++) {
|
|
5466
5610
|
var sr = SearchResult.fromJson(roomEvents.results[i], mapper);
|
|
5467
|
-
var
|
|
5468
|
-
if (
|
|
5611
|
+
var _room5 = this.getRoom(sr.context.getEvent().getRoomId());
|
|
5612
|
+
if (_room5) {
|
|
5469
5613
|
// Copy over a known event sender if we can
|
|
5470
5614
|
for (var ev of sr.context.getTimeline()) {
|
|
5471
|
-
var sender =
|
|
5615
|
+
var sender = _room5.getMember(ev.getSender());
|
|
5472
5616
|
if (!ev.sender && sender) ev.sender = sender;
|
|
5473
5617
|
}
|
|
5474
5618
|
}
|
|
@@ -5554,14 +5698,14 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
5554
5698
|
* @returns Filter ID
|
|
5555
5699
|
*/
|
|
5556
5700
|
getOrCreateFilter(filterName, filter) {
|
|
5557
|
-
var
|
|
5701
|
+
var _this55 = this;
|
|
5558
5702
|
return _asyncToGenerator(function* () {
|
|
5559
|
-
var filterId =
|
|
5703
|
+
var filterId = _this55.store.getFilterIdByName(filterName);
|
|
5560
5704
|
var existingId;
|
|
5561
5705
|
if (filterId) {
|
|
5562
5706
|
// check that the existing filter matches our expectations
|
|
5563
5707
|
try {
|
|
5564
|
-
var existingFilter = yield
|
|
5708
|
+
var existingFilter = yield _this55.getFilter(_this55.credentials.userId, filterId, true);
|
|
5565
5709
|
if (existingFilter) {
|
|
5566
5710
|
var oldDef = existingFilter.getDefinition();
|
|
5567
5711
|
var newDef = filter.getDefinition();
|
|
@@ -5585,7 +5729,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
5585
5729
|
}
|
|
5586
5730
|
// if the filter doesn't exist anymore on the server, remove from store
|
|
5587
5731
|
if (!existingId) {
|
|
5588
|
-
|
|
5732
|
+
_this55.store.setFilterIdByName(filterName, undefined);
|
|
5589
5733
|
}
|
|
5590
5734
|
}
|
|
5591
5735
|
if (existingId) {
|
|
@@ -5593,8 +5737,8 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
5593
5737
|
}
|
|
5594
5738
|
|
|
5595
5739
|
// create a new filter
|
|
5596
|
-
var createdFilter = yield
|
|
5597
|
-
|
|
5740
|
+
var createdFilter = yield _this55.createFilter(filter.getDefinition());
|
|
5741
|
+
_this55.store.setFilterIdByName(filterName, createdFilter.filterId);
|
|
5598
5742
|
return createdFilter.filterId;
|
|
5599
5743
|
})();
|
|
5600
5744
|
}
|
|
@@ -5642,45 +5786,45 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
5642
5786
|
|
|
5643
5787
|
// XXX: Intended private, used in code.
|
|
5644
5788
|
checkTurnServers() {
|
|
5645
|
-
var
|
|
5789
|
+
var _this56 = this;
|
|
5646
5790
|
return _asyncToGenerator(function* () {
|
|
5647
|
-
if (!
|
|
5791
|
+
if (!_this56.canSupportVoip) {
|
|
5648
5792
|
return;
|
|
5649
5793
|
}
|
|
5650
5794
|
var credentialsGood = false;
|
|
5651
|
-
var remainingTime =
|
|
5795
|
+
var remainingTime = _this56.turnServersExpiry - Date.now();
|
|
5652
5796
|
if (remainingTime > TURN_CHECK_INTERVAL) {
|
|
5653
|
-
|
|
5797
|
+
_this56.logger.debug("TURN creds are valid for another " + remainingTime + " ms: not fetching new ones.");
|
|
5654
5798
|
credentialsGood = true;
|
|
5655
5799
|
} else {
|
|
5656
|
-
|
|
5800
|
+
_this56.logger.debug("Fetching new TURN credentials");
|
|
5657
5801
|
try {
|
|
5658
|
-
var res = yield
|
|
5802
|
+
var res = yield _this56.turnServer();
|
|
5659
5803
|
if (res.uris) {
|
|
5660
|
-
|
|
5804
|
+
_this56.logger.debug("Got TURN URIs: " + res.uris + " refresh in " + res.ttl + " secs");
|
|
5661
5805
|
// map the response to a format that can be fed to RTCPeerConnection
|
|
5662
5806
|
var servers = {
|
|
5663
5807
|
urls: res.uris,
|
|
5664
5808
|
username: res.username,
|
|
5665
5809
|
credential: res.password
|
|
5666
5810
|
};
|
|
5667
|
-
|
|
5811
|
+
_this56.turnServers = [servers];
|
|
5668
5812
|
// The TTL is in seconds but we work in ms
|
|
5669
|
-
|
|
5813
|
+
_this56.turnServersExpiry = Date.now() + res.ttl * 1000;
|
|
5670
5814
|
credentialsGood = true;
|
|
5671
|
-
|
|
5815
|
+
_this56.emit(ClientEvent.TurnServers, _this56.turnServers);
|
|
5672
5816
|
}
|
|
5673
5817
|
} catch (err) {
|
|
5674
|
-
|
|
5818
|
+
_this56.logger.error("Failed to get TURN URIs", err);
|
|
5675
5819
|
if (err.httpStatus === 403) {
|
|
5676
5820
|
// We got a 403, so there's no point in looping forever.
|
|
5677
|
-
|
|
5678
|
-
if (
|
|
5679
|
-
|
|
5680
|
-
|
|
5821
|
+
_this56.logger.info("TURN access unavailable for this account: stopping credentials checks");
|
|
5822
|
+
if (_this56.checkTurnServersIntervalID !== null) global.clearInterval(_this56.checkTurnServersIntervalID);
|
|
5823
|
+
_this56.checkTurnServersIntervalID = undefined;
|
|
5824
|
+
_this56.emit(ClientEvent.TurnServersError, err, true); // fatal
|
|
5681
5825
|
} else {
|
|
5682
5826
|
// otherwise, if we failed for whatever reason, try again the next time we're called.
|
|
5683
|
-
|
|
5827
|
+
_this56.emit(ClientEvent.TurnServersError, err, false); // non-fatal
|
|
5684
5828
|
}
|
|
5685
5829
|
}
|
|
5686
5830
|
}
|
|
@@ -5756,14 +5900,14 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
5756
5900
|
});
|
|
5757
5901
|
}
|
|
5758
5902
|
fetchClientWellKnown() {
|
|
5759
|
-
var
|
|
5903
|
+
var _this57 = this;
|
|
5760
5904
|
return _asyncToGenerator(function* () {
|
|
5761
|
-
var
|
|
5905
|
+
var _this57$getDomain;
|
|
5762
5906
|
// `getRawClientConfig` does not throw or reject on network errors, instead
|
|
5763
5907
|
// it absorbs errors and returns `{}`.
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5908
|
+
_this57.clientWellKnownPromise = AutoDiscovery.getRawClientConfig((_this57$getDomain = _this57.getDomain()) !== null && _this57$getDomain !== void 0 ? _this57$getDomain : undefined);
|
|
5909
|
+
_this57.clientWellKnown = yield _this57.clientWellKnownPromise;
|
|
5910
|
+
_this57.emit(ClientEvent.ClientWellKnown, _this57.clientWellKnown);
|
|
5767
5911
|
})();
|
|
5768
5912
|
}
|
|
5769
5913
|
getClientWellKnown() {
|
|
@@ -5809,16 +5953,16 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
5809
5953
|
// TODO: on spec release, rename this to getMutualRooms
|
|
5810
5954
|
// eslint-disable-next-line
|
|
5811
5955
|
_unstable_getSharedRooms(userId) {
|
|
5812
|
-
var
|
|
5956
|
+
var _this58 = this;
|
|
5813
5957
|
return _asyncToGenerator(function* () {
|
|
5814
5958
|
// Initial variant of the MSC
|
|
5815
|
-
var sharedRoomsSupport = yield
|
|
5959
|
+
var sharedRoomsSupport = yield _this58.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_SHARED_ROOMS);
|
|
5816
5960
|
|
|
5817
5961
|
// Newer variant that renamed shared rooms to mutual rooms
|
|
5818
|
-
var mutualRoomsSupport = yield
|
|
5962
|
+
var mutualRoomsSupport = yield _this58.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_MUTUAL_ROOMS);
|
|
5819
5963
|
|
|
5820
5964
|
// Latest variant that changed from path elements to query elements
|
|
5821
|
-
var queryMutualRoomsSupport = yield
|
|
5965
|
+
var queryMutualRoomsSupport = yield _this58.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_QUERY_MUTUAL_ROOMS);
|
|
5822
5966
|
if (!sharedRoomsSupport && !mutualRoomsSupport && !queryMutualRoomsSupport) {
|
|
5823
5967
|
throw Error("Server does not support the Mutual Rooms API");
|
|
5824
5968
|
}
|
|
@@ -5846,7 +5990,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
5846
5990
|
if (token != null && queryMutualRoomsSupport) {
|
|
5847
5991
|
tokenQuery["batch_token"] = token;
|
|
5848
5992
|
}
|
|
5849
|
-
var res = yield
|
|
5993
|
+
var res = yield _this58.http.authedRequest(Method.Get, path, _objectSpread(_objectSpread({}, query), tokenQuery), undefined, {
|
|
5850
5994
|
prefix: ClientPrefix.Unstable
|
|
5851
5995
|
});
|
|
5852
5996
|
rooms.push(...res.joined);
|
|
@@ -5866,24 +6010,24 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
5866
6010
|
* @returns The server /versions response
|
|
5867
6011
|
*/
|
|
5868
6012
|
getVersions() {
|
|
5869
|
-
var
|
|
6013
|
+
var _this59 = this;
|
|
5870
6014
|
return _asyncToGenerator(function* () {
|
|
5871
|
-
if (
|
|
5872
|
-
return
|
|
6015
|
+
if (_this59.serverVersionsPromise) {
|
|
6016
|
+
return _this59.serverVersionsPromise;
|
|
5873
6017
|
}
|
|
5874
6018
|
|
|
5875
6019
|
// We send an authenticated request as of MSC4026
|
|
5876
|
-
|
|
6020
|
+
_this59.serverVersionsPromise = _this59.http.authedRequest(Method.Get, "/_matrix/client/versions", undefined, undefined, {
|
|
5877
6021
|
prefix: ""
|
|
5878
6022
|
}).catch(e => {
|
|
5879
6023
|
// Need to unset this if it fails, otherwise we'll never retry
|
|
5880
|
-
|
|
6024
|
+
_this59.serverVersionsPromise = undefined;
|
|
5881
6025
|
// but rethrow the exception to anything that was waiting
|
|
5882
6026
|
throw e;
|
|
5883
6027
|
});
|
|
5884
|
-
var serverVersions = yield
|
|
5885
|
-
|
|
5886
|
-
return
|
|
6028
|
+
var serverVersions = yield _this59.serverVersionsPromise;
|
|
6029
|
+
_this59.canSupport = yield buildFeatureSupportMap(serverVersions);
|
|
6030
|
+
return _this59.serverVersionsPromise;
|
|
5887
6031
|
})();
|
|
5888
6032
|
}
|
|
5889
6033
|
|
|
@@ -5893,11 +6037,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
5893
6037
|
* @returns Whether it is supported
|
|
5894
6038
|
*/
|
|
5895
6039
|
isVersionSupported(version) {
|
|
5896
|
-
var
|
|
6040
|
+
var _this60 = this;
|
|
5897
6041
|
return _asyncToGenerator(function* () {
|
|
5898
6042
|
var {
|
|
5899
6043
|
versions
|
|
5900
|
-
} = yield
|
|
6044
|
+
} = yield _this60.getVersions();
|
|
5901
6045
|
return versions && versions.includes(version);
|
|
5902
6046
|
})();
|
|
5903
6047
|
}
|
|
@@ -5909,9 +6053,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
5909
6053
|
* @returns true if the feature is supported
|
|
5910
6054
|
*/
|
|
5911
6055
|
doesServerSupportUnstableFeature(feature) {
|
|
5912
|
-
var
|
|
6056
|
+
var _this61 = this;
|
|
5913
6057
|
return _asyncToGenerator(function* () {
|
|
5914
|
-
var response = yield
|
|
6058
|
+
var response = yield _this61.getVersions();
|
|
5915
6059
|
if (!response) return false;
|
|
5916
6060
|
var unstableFeatures = response["unstable_features"];
|
|
5917
6061
|
return unstableFeatures && !!unstableFeatures[feature];
|
|
@@ -5926,9 +6070,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
5926
6070
|
* for the preset.
|
|
5927
6071
|
*/
|
|
5928
6072
|
doesServerForceEncryptionForPreset(presetName) {
|
|
5929
|
-
var
|
|
6073
|
+
var _this62 = this;
|
|
5930
6074
|
return _asyncToGenerator(function* () {
|
|
5931
|
-
var response = yield
|
|
6075
|
+
var response = yield _this62.getVersions();
|
|
5932
6076
|
if (!response) return false;
|
|
5933
6077
|
var unstableFeatures = response["unstable_features"];
|
|
5934
6078
|
|
|
@@ -5938,9 +6082,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
5938
6082
|
})();
|
|
5939
6083
|
}
|
|
5940
6084
|
doesServerSupportThread() {
|
|
5941
|
-
var
|
|
6085
|
+
var _this63 = this;
|
|
5942
6086
|
return _asyncToGenerator(function* () {
|
|
5943
|
-
if (yield
|
|
6087
|
+
if (yield _this63.isVersionSupported("v1.4")) {
|
|
5944
6088
|
return {
|
|
5945
6089
|
threads: FeatureSupport.Stable,
|
|
5946
6090
|
list: FeatureSupport.Stable,
|
|
@@ -5948,7 +6092,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
5948
6092
|
};
|
|
5949
6093
|
}
|
|
5950
6094
|
try {
|
|
5951
|
-
var [threadUnstable, threadStable, listUnstable, listStable, fwdPaginationUnstable, fwdPaginationStable] = yield Promise.all([
|
|
6095
|
+
var [threadUnstable, threadStable, listUnstable, listStable, fwdPaginationUnstable, fwdPaginationStable] = yield Promise.all([_this63.doesServerSupportUnstableFeature("org.matrix.msc3440"), _this63.doesServerSupportUnstableFeature("org.matrix.msc3440.stable"), _this63.doesServerSupportUnstableFeature("org.matrix.msc3856"), _this63.doesServerSupportUnstableFeature("org.matrix.msc3856.stable"), _this63.doesServerSupportUnstableFeature("org.matrix.msc3715"), _this63.doesServerSupportUnstableFeature("org.matrix.msc3715.stable")]);
|
|
5952
6096
|
return {
|
|
5953
6097
|
threads: determineFeatureSupport(threadStable, threadUnstable),
|
|
5954
6098
|
list: determineFeatureSupport(listStable, listUnstable),
|
|
@@ -6006,21 +6150,21 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
6006
6150
|
* @returns an object with `events` as `MatrixEvent[]` and optionally `nextBatch` if more relations are available.
|
|
6007
6151
|
*/
|
|
6008
6152
|
relations(roomId, eventId, relationType, eventType) {
|
|
6009
|
-
var
|
|
6010
|
-
|
|
6153
|
+
var _arguments7 = arguments,
|
|
6154
|
+
_this64 = this;
|
|
6011
6155
|
return _asyncToGenerator(function* () {
|
|
6012
6156
|
var _result$next_batch, _result$prev_batch;
|
|
6013
|
-
var opts =
|
|
6157
|
+
var opts = _arguments7.length > 4 && _arguments7[4] !== undefined ? _arguments7[4] : {
|
|
6014
6158
|
dir: Direction.Backward
|
|
6015
6159
|
};
|
|
6016
|
-
var fetchedEventType = eventType ?
|
|
6017
|
-
var [eventResult, result] = yield Promise.all([
|
|
6018
|
-
var mapper =
|
|
6160
|
+
var fetchedEventType = eventType ? _this64.getEncryptedIfNeededEventType(roomId, eventType) : null;
|
|
6161
|
+
var [eventResult, result] = yield Promise.all([_this64.fetchRoomEvent(roomId, eventId), _this64.fetchRelations(roomId, eventId, relationType, fetchedEventType, opts)]);
|
|
6162
|
+
var mapper = _this64.getEventMapper();
|
|
6019
6163
|
var originalEvent = eventResult ? mapper(eventResult) : undefined;
|
|
6020
6164
|
var events = result.chunk.map(mapper);
|
|
6021
6165
|
if (fetchedEventType === EventType.RoomMessageEncrypted) {
|
|
6022
6166
|
var allEvents = originalEvent ? events.concat(originalEvent) : events;
|
|
6023
|
-
yield Promise.all(allEvents.map(e =>
|
|
6167
|
+
yield Promise.all(allEvents.map(e => _this64.decryptEventIfNeeded(e)));
|
|
6024
6168
|
if (eventType !== null) {
|
|
6025
6169
|
events = events.filter(e => e.getType() === eventType);
|
|
6026
6170
|
}
|
|
@@ -6368,23 +6512,23 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
6368
6512
|
* @returns Promise which resolves: On success, the empty object `{}`
|
|
6369
6513
|
*/
|
|
6370
6514
|
logout() {
|
|
6371
|
-
var
|
|
6372
|
-
|
|
6515
|
+
var _arguments8 = arguments,
|
|
6516
|
+
_this65 = this;
|
|
6373
6517
|
return _asyncToGenerator(function* () {
|
|
6374
|
-
var
|
|
6375
|
-
var stopClient =
|
|
6376
|
-
if ((
|
|
6518
|
+
var _this65$crypto;
|
|
6519
|
+
var stopClient = _arguments8.length > 0 && _arguments8[0] !== undefined ? _arguments8[0] : false;
|
|
6520
|
+
if ((_this65$crypto = _this65.crypto) !== null && _this65$crypto !== void 0 && (_this65$crypto = _this65$crypto.backupManager) !== null && _this65$crypto !== void 0 && _this65$crypto.getKeyBackupEnabled()) {
|
|
6377
6521
|
try {
|
|
6378
|
-
while ((yield
|
|
6522
|
+
while ((yield _this65.crypto.backupManager.backupPendingKeys(200)) > 0);
|
|
6379
6523
|
} catch (err) {
|
|
6380
|
-
|
|
6524
|
+
_this65.logger.error("Key backup request failed when logging out. Some keys may be missing from backup", err);
|
|
6381
6525
|
}
|
|
6382
6526
|
}
|
|
6383
6527
|
if (stopClient) {
|
|
6384
|
-
|
|
6385
|
-
|
|
6528
|
+
_this65.stopClient();
|
|
6529
|
+
_this65.http.abort();
|
|
6386
6530
|
}
|
|
6387
|
-
return
|
|
6531
|
+
return _this65.http.authedRequest(Method.Post, "/logout");
|
|
6388
6532
|
})();
|
|
6389
6533
|
}
|
|
6390
6534
|
|
|
@@ -6422,12 +6566,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
6422
6566
|
* or UIA auth data.
|
|
6423
6567
|
*/
|
|
6424
6568
|
requestLoginToken(auth) {
|
|
6425
|
-
var
|
|
6569
|
+
var _this66 = this;
|
|
6426
6570
|
return _asyncToGenerator(function* () {
|
|
6427
6571
|
var body = {
|
|
6428
6572
|
auth
|
|
6429
6573
|
};
|
|
6430
|
-
return
|
|
6574
|
+
return _this66.http.authedRequest(Method.Post, "/login/get_token", undefined,
|
|
6431
6575
|
// no query params
|
|
6432
6576
|
body, {
|
|
6433
6577
|
prefix: ClientPrefix.V1
|
|
@@ -6459,23 +6603,23 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
6459
6603
|
* @returns Rejects: with an error response.
|
|
6460
6604
|
*/
|
|
6461
6605
|
createRoom(options) {
|
|
6462
|
-
var
|
|
6606
|
+
var _this67 = this;
|
|
6463
6607
|
return _asyncToGenerator(function* () {
|
|
6464
|
-
var
|
|
6608
|
+
var _this67$identityServe;
|
|
6465
6609
|
// eslint-disable-line camelcase
|
|
6466
6610
|
// some valid options include: room_alias_name, visibility, invite
|
|
6467
6611
|
|
|
6468
6612
|
// inject the id_access_token if inviting 3rd party addresses
|
|
6469
6613
|
var invitesNeedingToken = (options.invite_3pid || []).filter(i => !i.id_access_token);
|
|
6470
|
-
if (invitesNeedingToken.length > 0 && (
|
|
6471
|
-
var identityAccessToken = yield
|
|
6614
|
+
if (invitesNeedingToken.length > 0 && (_this67$identityServe = _this67.identityServer) !== null && _this67$identityServe !== void 0 && _this67$identityServe.getAccessToken) {
|
|
6615
|
+
var identityAccessToken = yield _this67.identityServer.getAccessToken();
|
|
6472
6616
|
if (identityAccessToken) {
|
|
6473
6617
|
for (var invite of invitesNeedingToken) {
|
|
6474
6618
|
invite.id_access_token = identityAccessToken;
|
|
6475
6619
|
}
|
|
6476
6620
|
}
|
|
6477
6621
|
}
|
|
6478
|
-
return
|
|
6622
|
+
return _this67.http.authedRequest(Method.Post, "/createRoom", undefined, options);
|
|
6479
6623
|
})();
|
|
6480
6624
|
}
|
|
6481
6625
|
|
|
@@ -6659,7 +6803,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
6659
6803
|
* @returns Promise which resolves: the empty object, `{}`.
|
|
6660
6804
|
*/
|
|
6661
6805
|
setRoomReadMarkersHttpRequest(roomId, rmEventId, rrEventId, rpEventId) {
|
|
6662
|
-
var
|
|
6806
|
+
var _this68 = this;
|
|
6663
6807
|
return _asyncToGenerator(function* () {
|
|
6664
6808
|
var path = utils.encodeUri("/rooms/$roomId/read_markers", {
|
|
6665
6809
|
$roomId: roomId
|
|
@@ -6668,10 +6812,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
6668
6812
|
[ReceiptType.FullyRead]: rmEventId,
|
|
6669
6813
|
[ReceiptType.Read]: rrEventId
|
|
6670
6814
|
};
|
|
6671
|
-
if ((yield
|
|
6815
|
+
if ((yield _this68.doesServerSupportUnstableFeature("org.matrix.msc2285.stable")) || (yield _this68.isVersionSupported("v1.4"))) {
|
|
6672
6816
|
content[ReceiptType.ReadPrivate] = rpEventId;
|
|
6673
6817
|
}
|
|
6674
|
-
return
|
|
6818
|
+
return _this68.http.authedRequest(Method.Post, path, undefined, content);
|
|
6675
6819
|
})();
|
|
6676
6820
|
}
|
|
6677
6821
|
|
|
@@ -6916,10 +7060,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
6916
7060
|
* @returns Rejects: with an error response.
|
|
6917
7061
|
*/
|
|
6918
7062
|
addThreePidOnly(data) {
|
|
6919
|
-
var
|
|
7063
|
+
var _this69 = this;
|
|
6920
7064
|
return _asyncToGenerator(function* () {
|
|
6921
7065
|
var path = "/account/3pid/add";
|
|
6922
|
-
return
|
|
7066
|
+
return _this69.http.authedRequest(Method.Post, path, undefined, data);
|
|
6923
7067
|
})();
|
|
6924
7068
|
}
|
|
6925
7069
|
|
|
@@ -6935,10 +7079,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
6935
7079
|
* @returns Rejects: with an error response.
|
|
6936
7080
|
*/
|
|
6937
7081
|
bindThreePid(data) {
|
|
6938
|
-
var
|
|
7082
|
+
var _this70 = this;
|
|
6939
7083
|
return _asyncToGenerator(function* () {
|
|
6940
7084
|
var path = "/account/3pid/bind";
|
|
6941
|
-
return
|
|
7085
|
+
return _this70.http.authedRequest(Method.Post, path, undefined, data);
|
|
6942
7086
|
})();
|
|
6943
7087
|
}
|
|
6944
7088
|
|
|
@@ -6956,15 +7100,15 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
6956
7100
|
unbindThreePid(medium, address
|
|
6957
7101
|
// eslint-disable-next-line camelcase
|
|
6958
7102
|
) {
|
|
6959
|
-
var
|
|
7103
|
+
var _this71 = this;
|
|
6960
7104
|
return _asyncToGenerator(function* () {
|
|
6961
7105
|
var path = "/account/3pid/unbind";
|
|
6962
7106
|
var data = {
|
|
6963
7107
|
medium,
|
|
6964
7108
|
address,
|
|
6965
|
-
id_server:
|
|
7109
|
+
id_server: _this71.getIdentityServerUrl(true)
|
|
6966
7110
|
};
|
|
6967
|
-
return
|
|
7111
|
+
return _this71.http.authedRequest(Method.Post, path, undefined, data);
|
|
6968
7112
|
})();
|
|
6969
7113
|
}
|
|
6970
7114
|
|
|
@@ -7086,13 +7230,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
7086
7230
|
* @returns Rejects: with an error response.
|
|
7087
7231
|
*/
|
|
7088
7232
|
getPushers() {
|
|
7089
|
-
var
|
|
7233
|
+
var _this72 = this;
|
|
7090
7234
|
return _asyncToGenerator(function* () {
|
|
7091
|
-
var response = yield
|
|
7235
|
+
var response = yield _this72.http.authedRequest(Method.Get, "/pushers");
|
|
7092
7236
|
|
|
7093
7237
|
// Migration path for clients that connect to a homeserver that does not support
|
|
7094
7238
|
// MSC3881 yet, see https://github.com/matrix-org/matrix-spec-proposals/blob/kerry/remote-push-toggle/proposals/3881-remote-push-notification-toggling.md#migration
|
|
7095
|
-
if (!(yield
|
|
7239
|
+
if (!(yield _this72.doesServerSupportUnstableFeature("org.matrix.msc3881"))) {
|
|
7096
7240
|
response.pushers = response.pushers.map(pusher => {
|
|
7097
7241
|
if (!pusher.hasOwnProperty(PUSHER_ENABLED.name)) {
|
|
7098
7242
|
pusher[PUSHER_ENABLED.name] = true;
|
|
@@ -7522,7 +7666,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
7522
7666
|
* found MXIDs. Results where no user could be found will not be listed.
|
|
7523
7667
|
*/
|
|
7524
7668
|
identityHashedLookup(addressPairs, identityAccessToken) {
|
|
7525
|
-
var
|
|
7669
|
+
var _this73 = this;
|
|
7526
7670
|
return _asyncToGenerator(function* () {
|
|
7527
7671
|
var params = {
|
|
7528
7672
|
// addresses: ["email@example.org", "10005550000"],
|
|
@@ -7531,7 +7675,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
7531
7675
|
};
|
|
7532
7676
|
|
|
7533
7677
|
// Get hash information first before trying to do a lookup
|
|
7534
|
-
var hashes = yield
|
|
7678
|
+
var hashes = yield _this73.getIdentityHashDetails(identityAccessToken);
|
|
7535
7679
|
if (!hashes || !hashes["lookup_pepper"] || !hashes["algorithms"]) {
|
|
7536
7680
|
throw new Error("Unsupported identity server: bad response");
|
|
7537
7681
|
}
|
|
@@ -7543,17 +7687,22 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
7543
7687
|
|
|
7544
7688
|
// When picking an algorithm, we pick the hashed over no hashes
|
|
7545
7689
|
if (hashes["algorithms"].includes("sha256")) {
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7690
|
+
params["addresses"] = yield Promise.all(addressPairs.map( /*#__PURE__*/function () {
|
|
7691
|
+
var _ref13 = _asyncToGenerator(function* (p) {
|
|
7692
|
+
var addr = p[0].toLowerCase(); // lowercase to get consistent hashes
|
|
7693
|
+
var med = p[1].toLowerCase();
|
|
7694
|
+
var hashBuffer = yield sha256("".concat(addr, " ").concat(med, " ").concat(params["pepper"]));
|
|
7695
|
+
var hashed = encodeUnpaddedBase64Url(hashBuffer);
|
|
7696
|
+
|
|
7697
|
+
// Map the hash to a known (case-sensitive) address. We use the case
|
|
7698
|
+
// sensitive version because the caller might be expecting that.
|
|
7699
|
+
localMapping[hashed] = p[0];
|
|
7700
|
+
return hashed;
|
|
7701
|
+
});
|
|
7702
|
+
return function (_x6) {
|
|
7703
|
+
return _ref13.apply(this, arguments);
|
|
7704
|
+
};
|
|
7705
|
+
}()));
|
|
7557
7706
|
params["algorithm"] = "sha256";
|
|
7558
7707
|
} else if (hashes["algorithms"].includes("none")) {
|
|
7559
7708
|
params["addresses"] = addressPairs.map(p => {
|
|
@@ -7569,7 +7718,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
7569
7718
|
} else {
|
|
7570
7719
|
throw new Error("Unsupported identity server: unknown hash algorithm");
|
|
7571
7720
|
}
|
|
7572
|
-
var response = yield
|
|
7721
|
+
var response = yield _this73.http.idServerRequest(Method.Post, "/lookup", params, IdentityPrefix.V2, identityAccessToken);
|
|
7573
7722
|
if (!(response !== null && response !== void 0 && response["mappings"])) return []; // no results
|
|
7574
7723
|
|
|
7575
7724
|
var foundAddresses = [];
|
|
@@ -7603,12 +7752,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
7603
7752
|
* @returns Rejects: with an error response.
|
|
7604
7753
|
*/
|
|
7605
7754
|
lookupThreePid(medium, address, identityAccessToken) {
|
|
7606
|
-
var
|
|
7755
|
+
var _this74 = this;
|
|
7607
7756
|
return _asyncToGenerator(function* () {
|
|
7608
7757
|
// Note: we're using the V2 API by calling this function, but our
|
|
7609
7758
|
// function contract requires a V1 response. We therefore have to
|
|
7610
7759
|
// convert it manually.
|
|
7611
|
-
var response = yield
|
|
7760
|
+
var response = yield _this74.identityHashedLookup([[address, medium]], identityAccessToken);
|
|
7612
7761
|
var result = response.find(p => p.address === address);
|
|
7613
7762
|
if (!result) {
|
|
7614
7763
|
return {};
|
|
@@ -7640,12 +7789,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
7640
7789
|
* @returns Rejects: with an error response.
|
|
7641
7790
|
*/
|
|
7642
7791
|
bulkLookupThreePids(query, identityAccessToken) {
|
|
7643
|
-
var
|
|
7792
|
+
var _this75 = this;
|
|
7644
7793
|
return _asyncToGenerator(function* () {
|
|
7645
7794
|
// Note: we're using the V2 API by calling this function, but our
|
|
7646
7795
|
// function contract requires a V1 response. We therefore have to
|
|
7647
7796
|
// convert it manually.
|
|
7648
|
-
var response = yield
|
|
7797
|
+
var response = yield _this75.identityHashedLookup(
|
|
7649
7798
|
// We have to reverse the query order to get [address, medium] pairs
|
|
7650
7799
|
query.map(p => [p[1], p[0]]), identityAccessToken);
|
|
7651
7800
|
var v1results = [];
|
|
@@ -7846,16 +7995,16 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
7846
7995
|
* @returns Promise which resolves to the created space.
|
|
7847
7996
|
*/
|
|
7848
7997
|
unstableCreateFileTree(name) {
|
|
7849
|
-
var
|
|
7998
|
+
var _this76 = this;
|
|
7850
7999
|
return _asyncToGenerator(function* () {
|
|
7851
8000
|
var {
|
|
7852
8001
|
room_id: roomId
|
|
7853
|
-
} = yield
|
|
8002
|
+
} = yield _this76.createRoom({
|
|
7854
8003
|
name: name,
|
|
7855
8004
|
preset: Preset.PrivateChat,
|
|
7856
8005
|
power_level_content_override: _objectSpread(_objectSpread({}, DEFAULT_TREE_POWER_LEVELS_TEMPLATE), {}, {
|
|
7857
8006
|
users: {
|
|
7858
|
-
[
|
|
8007
|
+
[_this76.getUserId()]: 100
|
|
7859
8008
|
}
|
|
7860
8009
|
}),
|
|
7861
8010
|
creation_content: {
|
|
@@ -7875,7 +8024,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
7875
8024
|
}
|
|
7876
8025
|
}]
|
|
7877
8026
|
});
|
|
7878
|
-
return new MSC3089TreeSpace(
|
|
8027
|
+
return new MSC3089TreeSpace(_this76, roomId);
|
|
7879
8028
|
})();
|
|
7880
8029
|
}
|
|
7881
8030
|
|
|
@@ -7952,7 +8101,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
7952
8101
|
* @param via - The list of servers which know about the room if only an ID was provided.
|
|
7953
8102
|
*/
|
|
7954
8103
|
getRoomSummary(roomIdOrAlias, via) {
|
|
7955
|
-
var
|
|
8104
|
+
var _this77 = this;
|
|
7956
8105
|
return _asyncToGenerator(function* () {
|
|
7957
8106
|
var paramOpts = {
|
|
7958
8107
|
prefix: "/_matrix/client/unstable/im.nheko.summary"
|
|
@@ -7961,7 +8110,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
7961
8110
|
var path = utils.encodeUri("/summary/$roomid", {
|
|
7962
8111
|
$roomid: roomIdOrAlias
|
|
7963
8112
|
});
|
|
7964
|
-
return yield
|
|
8113
|
+
return yield _this77.http.authedRequest(Method.Get, path, {
|
|
7965
8114
|
via
|
|
7966
8115
|
}, undefined, paramOpts);
|
|
7967
8116
|
} catch (e) {
|
|
@@ -7969,7 +8118,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
7969
8118
|
var _path = utils.encodeUri("/rooms/$roomid/summary", {
|
|
7970
8119
|
$roomid: roomIdOrAlias
|
|
7971
8120
|
});
|
|
7972
|
-
return yield
|
|
8121
|
+
return yield _this77.http.authedRequest(Method.Get, _path, {
|
|
7973
8122
|
via
|
|
7974
8123
|
}, undefined, paramOpts);
|
|
7975
8124
|
} else {
|
|
@@ -8021,9 +8170,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
8021
8170
|
* Fetches information about the user for the configured access token.
|
|
8022
8171
|
*/
|
|
8023
8172
|
whoami() {
|
|
8024
|
-
var
|
|
8173
|
+
var _this78 = this;
|
|
8025
8174
|
return _asyncToGenerator(function* () {
|
|
8026
|
-
return
|
|
8175
|
+
return _this78.http.authedRequest(Method.Get, "/account/whoami");
|
|
8027
8176
|
})();
|
|
8028
8177
|
}
|
|
8029
8178
|
|
|
@@ -8034,7 +8183,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
8034
8183
|
* @returns Rejects: when the request fails (module:http-api.MatrixError)
|
|
8035
8184
|
*/
|
|
8036
8185
|
timestampToEvent(roomId, timestamp, dir) {
|
|
8037
|
-
var
|
|
8186
|
+
var _this79 = this;
|
|
8038
8187
|
return _asyncToGenerator(function* () {
|
|
8039
8188
|
var path = utils.encodeUri("/rooms/$roomId/timestamp_to_event", {
|
|
8040
8189
|
$roomId: roomId
|
|
@@ -8044,7 +8193,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
8044
8193
|
dir: dir
|
|
8045
8194
|
};
|
|
8046
8195
|
try {
|
|
8047
|
-
return yield
|
|
8196
|
+
return yield _this79.http.authedRequest(Method.Get, path, queryParams, undefined, {
|
|
8048
8197
|
prefix: ClientPrefix.V1
|
|
8049
8198
|
});
|
|
8050
8199
|
} catch (err) {
|
|
@@ -8060,7 +8209,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
8060
8209
|
// both indicate that this endpoint+verb combination is
|
|
8061
8210
|
// not supported.
|
|
8062
8211
|
err.httpStatus === 404 || err.httpStatus === 405)) {
|
|
8063
|
-
return yield
|
|
8212
|
+
return yield _this79.http.authedRequest(Method.Get, path, queryParams, undefined, {
|
|
8064
8213
|
prefix: "/_matrix/client/unstable/org.matrix.msc3030"
|
|
8065
8214
|
});
|
|
8066
8215
|
}
|
|
@@ -8076,21 +8225,27 @@ export class MatrixClient extends TypedEventEmitter {
|
|
|
8076
8225
|
* @experimental - part of MSC2965
|
|
8077
8226
|
*/
|
|
8078
8227
|
getAuthIssuer() {
|
|
8079
|
-
var
|
|
8228
|
+
var _this80 = this;
|
|
8080
8229
|
return _asyncToGenerator(function* () {
|
|
8081
|
-
return
|
|
8230
|
+
return _this80.http.request(Method.Get, "/auth_issuer", undefined, undefined, {
|
|
8082
8231
|
prefix: ClientPrefix.Unstable + "/org.matrix.msc2965"
|
|
8083
8232
|
});
|
|
8084
8233
|
})();
|
|
8085
8234
|
}
|
|
8086
8235
|
}
|
|
8236
|
+
_defineProperty(MatrixClient, "RESTORE_BACKUP_ERROR_BAD_KEY", "RESTORE_BACKUP_ERROR_BAD_KEY");
|
|
8237
|
+
function getUnstableDelayQueryOpts(delayOpts) {
|
|
8238
|
+
return Object.fromEntries(Object.entries(delayOpts).map(_ref14 => {
|
|
8239
|
+
var [k, v] = _ref14;
|
|
8240
|
+
return ["".concat(UNSTABLE_MSC4140_DELAYED_EVENTS, ".").concat(k), v];
|
|
8241
|
+
}));
|
|
8242
|
+
}
|
|
8087
8243
|
|
|
8088
8244
|
/**
|
|
8089
8245
|
* recalculates an accurate notifications count on event decryption.
|
|
8090
8246
|
* Servers do not have enough knowledge about encrypted events to calculate an
|
|
8091
8247
|
* accurate notification_count
|
|
8092
8248
|
*/
|
|
8093
|
-
_defineProperty(MatrixClient, "RESTORE_BACKUP_ERROR_BAD_KEY", "RESTORE_BACKUP_ERROR_BAD_KEY");
|
|
8094
8249
|
export function fixNotificationCountOnDecryption(cli, event) {
|
|
8095
8250
|
var _actions$tweaks;
|
|
8096
8251
|
var ourUserId = cli.getUserId();
|