@textrp/briij-js-sdk 42.0.0 → 43.0.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.
package/lib/client.js CHANGED
@@ -57,7 +57,7 @@ import { SearchOrderBy } from "./@types/search.js";
57
57
  import { PushRuleActionName, PushRuleKind } from "./@types/PushRules.js";
58
58
  import { GroupCall } from "./webrtc/groupCall.js";
59
59
  import { MediaHandler } from "./webrtc/mediaHandler.js";
60
- import { XRPL_WALLET_LOGIN_TYPE } from "./@types/auth.js";
60
+ import { WALLET_E2EE_RECOVERY_ACCOUNT_DATA_TYPE, WALLET_IDENTITY_ACCOUNT_DATA_TYPE, XRPL_WALLET_LOGIN_TYPE } from "./@types/auth.js";
61
61
  import { TypedEventEmitter } from "./models/typed-event-emitter.js";
62
62
  import { MAIN_ROOM_TIMELINE, ReceiptType } from "./@types/read_receipts.js";
63
63
  import { SlidingSyncSdk } from "./sliding-sync-sdk.js";
@@ -5296,27 +5296,118 @@ export class BriijClient extends TypedEventEmitter {
5296
5296
  }
5297
5297
 
5298
5298
  /**
5299
- * @param user - Matrix user ID localpart or fully qualified MXID.
5300
- * @param walletAddress - XRPL/Xahau classic wallet address.
5301
- * @param signature - Hex signature for the challenge message.
5302
- * @param challenge - Signed challenge payload.
5303
- * @param network - Ledger network identifier. Defaults to `xrpl`.
5299
+ * Request an XRPL login challenge from the homeserver.
5300
+ *
5301
+ * The briij homeserver responds with HTTP 401 as the successful challenge
5302
+ * response, so this helper normalizes that into a resolved promise.
5303
+ */
5304
+ getXrplAuthChallenge(request) {
5305
+ var _this56 = this;
5306
+ return _asyncToGenerator(function* () {
5307
+ try {
5308
+ var response = yield _this56.loginRequest(_objectSpread(_objectSpread({}, request), {}, {
5309
+ type: XRPL_WALLET_LOGIN_TYPE
5310
+ }));
5311
+ if (typeof response.session === "string" && typeof response.challenge === "string") {
5312
+ return response;
5313
+ }
5314
+ } catch (error) {
5315
+ if (error instanceof BriijError && error.httpStatus === 401) {
5316
+ var _error$data, _error$data2;
5317
+ var session = (_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.session;
5318
+ var challenge = (_error$data2 = error.data) === null || _error$data2 === void 0 ? void 0 : _error$data2.challenge;
5319
+ if (typeof session === "string" && typeof challenge === "string") {
5320
+ return {
5321
+ session,
5322
+ challenge
5323
+ };
5324
+ }
5325
+ }
5326
+ throw error;
5327
+ }
5328
+ throw new Error("XRPL challenge response was not returned by homeserver");
5329
+ })();
5330
+ }
5331
+
5332
+ /**
5333
+ * Complete XRPL login using the previously issued challenge session.
5334
+ *
5304
5335
  * @returns Promise which resolves to a LoginResponse object.
5305
5336
  * @returns Rejects: with an error response.
5306
5337
  */
5338
+ completeXrplAuth(request) {
5339
+ return this.loginRequest(_objectSpread(_objectSpread({}, request), {}, {
5340
+ type: XRPL_WALLET_LOGIN_TYPE
5341
+ }));
5342
+ }
5343
+
5344
+ /**
5345
+ * Store a chain-agnostic wallet recovery envelope in account data.
5346
+ *
5347
+ * This uses a stable account-data type and does not affect core E2EE state.
5348
+ *
5349
+ * @param envelope - Wallet recovery envelope payload.
5350
+ */
5351
+ setWalletRecoveryEnvelope(envelope) {
5352
+ return this.setAccountDataRaw(WALLET_E2EE_RECOVERY_ACCOUNT_DATA_TYPE, envelope);
5353
+ }
5354
+
5355
+ /**
5356
+ * Fetch wallet recovery envelope directly from the homeserver.
5357
+ *
5358
+ * @returns The stored envelope, or null if not found.
5359
+ */
5360
+ getWalletRecoveryEnvelopeFromServer() {
5361
+ return this.getAccountDataFromServer(WALLET_E2EE_RECOVERY_ACCOUNT_DATA_TYPE);
5362
+ }
5363
+
5364
+ /**
5365
+ * Fetch canonical wallet identity metadata from the homeserver.
5366
+ *
5367
+ * @returns Wallet identity metadata, or null if not found.
5368
+ */
5369
+ getWalletIdentityFromServer() {
5370
+ return this.getAccountDataFromServer(WALLET_IDENTITY_ACCOUNT_DATA_TYPE);
5371
+ }
5372
+
5373
+ /**
5374
+ * @deprecated Use `getXrplAuthChallenge` + `completeXrplAuth` for explicit
5375
+ * two-step XRPL login flow. This wrapper now expects `challenge` to include
5376
+ * the `session` and optional `public_key`.
5377
+ */
5307
5378
  loginWithXrplWallet(user, walletAddress, signature, challenge) {
5308
- var network = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "xrpl";
5309
- return this.login(XRPL_WALLET_LOGIN_TYPE, {
5310
- user: user,
5311
- identifier: {
5312
- type: "m.id.user",
5313
- user: user
5314
- },
5315
- wallet_address: walletAddress,
5316
- signature: signature,
5317
- challenge: typeof challenge === "string" ? challenge : JSON.stringify(challenge),
5318
- network: network
5319
- });
5379
+ var _arguments13 = arguments,
5380
+ _this57 = this;
5381
+ return _asyncToGenerator(function* () {
5382
+ var _parsedChallenge, _parsedChallenge2;
5383
+ var network = _arguments13.length > 4 && _arguments13[4] !== undefined ? _arguments13[4] : "xrpl";
5384
+ var parsedChallenge = null;
5385
+ if (typeof challenge === "string") {
5386
+ try {
5387
+ parsedChallenge = JSON.parse(challenge);
5388
+ } catch (_unused3) {
5389
+ throw new Error("XRPL challenge must be JSON with a session field");
5390
+ }
5391
+ } else {
5392
+ parsedChallenge = challenge;
5393
+ }
5394
+ var session = (_parsedChallenge = parsedChallenge) === null || _parsedChallenge === void 0 ? void 0 : _parsedChallenge.session;
5395
+ if (!session) {
5396
+ throw new Error("XRPL challenge payload is missing session; call getXrplAuthChallenge first");
5397
+ }
5398
+ return _this57.completeXrplAuth({
5399
+ user,
5400
+ identifier: {
5401
+ type: "m.id.user",
5402
+ user
5403
+ },
5404
+ session,
5405
+ address: walletAddress,
5406
+ signature,
5407
+ public_key: (_parsedChallenge2 = parsedChallenge) === null || _parsedChallenge2 === void 0 ? void 0 : _parsedChallenge2.public_key,
5408
+ network
5409
+ });
5410
+ })();
5320
5411
  }
5321
5412
 
5322
5413
  /**
@@ -5379,9 +5470,9 @@ export class BriijClient extends TypedEventEmitter {
5379
5470
  * @param data - Credentials and other details for the login request.
5380
5471
  */
5381
5472
  loginRequest(data) {
5382
- var _this56 = this;
5473
+ var _this58 = this;
5383
5474
  return _asyncToGenerator(function* () {
5384
- return yield _this56.http.authedRequest(Method.Post, "/login", undefined, data);
5475
+ return yield _this58.http.authedRequest(Method.Post, "/login", undefined, data);
5385
5476
  })();
5386
5477
  }
5387
5478
 
@@ -5395,15 +5486,15 @@ export class BriijClient extends TypedEventEmitter {
5395
5486
  * @returns Promise which resolves: On success, the empty object `{}`
5396
5487
  */
5397
5488
  logout() {
5398
- var _arguments13 = arguments,
5399
- _this57 = this;
5489
+ var _arguments14 = arguments,
5490
+ _this59 = this;
5400
5491
  return _asyncToGenerator(function* () {
5401
- var stopClient = _arguments13.length > 0 && _arguments13[0] !== undefined ? _arguments13[0] : false;
5492
+ var stopClient = _arguments14.length > 0 && _arguments14[0] !== undefined ? _arguments14[0] : false;
5402
5493
  if (stopClient) {
5403
- _this57.stopClient();
5404
- _this57.http.abort();
5494
+ _this59.stopClient();
5495
+ _this59.http.abort();
5405
5496
  }
5406
- return _this57.http.authedRequest(Method.Post, "/logout");
5497
+ return _this59.http.authedRequest(Method.Post, "/logout");
5407
5498
  })();
5408
5499
  }
5409
5500
 
@@ -5441,12 +5532,12 @@ export class BriijClient extends TypedEventEmitter {
5441
5532
  * or UIA auth data.
5442
5533
  */
5443
5534
  requestLoginToken(auth) {
5444
- var _this58 = this;
5535
+ var _this60 = this;
5445
5536
  return _asyncToGenerator(function* () {
5446
5537
  var body = {
5447
5538
  auth
5448
5539
  };
5449
- return _this58.http.authedRequest(Method.Post, "/login/get_token", undefined,
5540
+ return _this60.http.authedRequest(Method.Post, "/login/get_token", undefined,
5450
5541
  // no query params
5451
5542
  body, {
5452
5543
  prefix: ClientPrefix.V1
@@ -5478,23 +5569,23 @@ export class BriijClient extends TypedEventEmitter {
5478
5569
  * @returns Rejects: with an error response.
5479
5570
  */
5480
5571
  createRoom(options) {
5481
- var _this59 = this;
5572
+ var _this61 = this;
5482
5573
  return _asyncToGenerator(function* () {
5483
- var _this59$identityServe;
5574
+ var _this61$identityServe;
5484
5575
  // eslint-disable-line camelcase
5485
5576
  // some valid options include: room_alias_name, visibility, invite
5486
5577
 
5487
5578
  // inject the id_access_token if inviting 3rd party addresses
5488
5579
  var invitesNeedingToken = (options.invite_3pid || []).filter(i => !i.id_access_token);
5489
- if (invitesNeedingToken.length > 0 && (_this59$identityServe = _this59.identityServer) !== null && _this59$identityServe !== void 0 && _this59$identityServe.getAccessToken) {
5490
- var identityAccessToken = yield _this59.identityServer.getAccessToken();
5580
+ if (invitesNeedingToken.length > 0 && (_this61$identityServe = _this61.identityServer) !== null && _this61$identityServe !== void 0 && _this61$identityServe.getAccessToken) {
5581
+ var identityAccessToken = yield _this61.identityServer.getAccessToken();
5491
5582
  if (identityAccessToken) {
5492
5583
  for (var invite of invitesNeedingToken) {
5493
5584
  invite.id_access_token = identityAccessToken;
5494
5585
  }
5495
5586
  }
5496
5587
  }
5497
- return _this59.http.authedRequest(Method.Post, "/createRoom", undefined, options);
5588
+ return _this61.http.authedRequest(Method.Post, "/createRoom", undefined, options);
5498
5589
  })();
5499
5590
  }
5500
5591
 
@@ -5639,12 +5730,12 @@ export class BriijClient extends TypedEventEmitter {
5639
5730
  * @returns Rejects: with an error response.
5640
5731
  */
5641
5732
  sendStateEvent(roomId, eventType, content) {
5642
- var _arguments14 = arguments,
5643
- _this60 = this;
5733
+ var _arguments15 = arguments,
5734
+ _this62 = this;
5644
5735
  return _asyncToGenerator(function* () {
5645
- var stateKey = _arguments14.length > 3 && _arguments14[3] !== undefined ? _arguments14[3] : "";
5646
- var opts = _arguments14.length > 4 && _arguments14[4] !== undefined ? _arguments14[4] : {};
5647
- var room = _this60.getRoom(roomId);
5736
+ var stateKey = _arguments15.length > 3 && _arguments15[3] !== undefined ? _arguments15[3] : "";
5737
+ var opts = _arguments15.length > 4 && _arguments15[4] !== undefined ? _arguments15[4] : {};
5738
+ var room = _this62.getRoom(roomId);
5648
5739
  var event = new BriijEvent({
5649
5740
  room_id: roomId,
5650
5741
  type: eventType,
@@ -5652,7 +5743,7 @@ export class BriijClient extends TypedEventEmitter {
5652
5743
  // Cast safety: StateEvents[K] is a stronger bound than IContent, which has [key: string]: any
5653
5744
  content: content
5654
5745
  });
5655
- yield _this60.encryptStateEventIfNeeded(event, room !== null && room !== void 0 ? room : undefined);
5746
+ yield _this62.encryptStateEventIfNeeded(event, room !== null && room !== void 0 ? room : undefined);
5656
5747
  var pathParams = {
5657
5748
  $roomId: roomId,
5658
5749
  $eventType: event.getWireType(),
@@ -5662,36 +5753,36 @@ export class BriijClient extends TypedEventEmitter {
5662
5753
  if (stateKey !== undefined) {
5663
5754
  path = utils.encodeUri(path + "/$stateKey", pathParams);
5664
5755
  }
5665
- return _this60.http.authedRequest(Method.Put, path, undefined, event.getWireContent(), opts);
5756
+ return _this62.http.authedRequest(Method.Put, path, undefined, event.getWireContent(), opts);
5666
5757
  })();
5667
5758
  }
5668
5759
  encryptStateEventIfNeeded(event, room) {
5669
- var _this61 = this;
5760
+ var _this63 = this;
5670
5761
  return _asyncToGenerator(function* () {
5671
- if (!_this61.enableEncryptedStateEvents) {
5762
+ if (!_this63.enableEncryptedStateEvents) {
5672
5763
  return;
5673
5764
  }
5674
5765
 
5675
5766
  // If the room is unknown, we cannot encrypt for it
5676
5767
  if (!room) return;
5677
- if (!_this61.cryptoBackend && _this61.usingExternalCrypto) {
5768
+ if (!_this63.cryptoBackend && _this63.usingExternalCrypto) {
5678
5769
  // The client has opted to allow sending messages to encrypted
5679
5770
  // rooms even if the room is encrypted, and we haven't set up
5680
5771
  // crypto. This is useful for users of matrix-org/pantalaimon
5681
5772
  return;
5682
5773
  }
5683
- if (!_this61.cryptoBackend) {
5774
+ if (!_this63.cryptoBackend) {
5684
5775
  throw new Error("This room is configured to use encryption, but your client does not support encryption.");
5685
5776
  }
5686
5777
 
5687
5778
  // Check regular encryption conditions.
5688
- if (!(yield _this61.shouldEncryptEventForRoom(event, room))) {
5779
+ if (!(yield _this63.shouldEncryptEventForRoom(event, room))) {
5689
5780
  return;
5690
5781
  }
5691
5782
 
5692
5783
  // If the crypto impl thinks we shouldn't encrypt, then we shouldn't.
5693
5784
  // Safety: we checked the crypto impl exists above.
5694
- if (!(yield _this61.cryptoBackend.isStateEncryptionEnabledInRoom(room.roomId))) {
5785
+ if (!(yield _this63.cryptoBackend.isStateEncryptionEnabledInRoom(room.roomId))) {
5695
5786
  return;
5696
5787
  }
5697
5788
 
@@ -5699,7 +5790,7 @@ export class BriijClient extends TypedEventEmitter {
5699
5790
  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())) {
5700
5791
  return;
5701
5792
  }
5702
- yield _this61.cryptoBackend.encryptEvent(event, room);
5793
+ yield _this63.cryptoBackend.encryptEvent(event, room);
5703
5794
  })();
5704
5795
  }
5705
5796
 
@@ -5732,7 +5823,7 @@ export class BriijClient extends TypedEventEmitter {
5732
5823
  * @returns Promise which resolves: the empty object, `{}`.
5733
5824
  */
5734
5825
  setRoomReadMarkersHttpRequest(roomId, rmEventId, rrEventId, rpEventId) {
5735
- var _this62 = this;
5826
+ var _this64 = this;
5736
5827
  return _asyncToGenerator(function* () {
5737
5828
  var path = utils.encodeUri("/rooms/$roomId/read_markers", {
5738
5829
  $roomId: roomId
@@ -5741,10 +5832,10 @@ export class BriijClient extends TypedEventEmitter {
5741
5832
  [ReceiptType.FullyRead]: rmEventId,
5742
5833
  [ReceiptType.Read]: rrEventId
5743
5834
  };
5744
- if ((yield _this62.doesServerSupportUnstableFeature("org.matrix.msc2285.stable")) || (yield _this62.isVersionSupported("v1.4"))) {
5835
+ if ((yield _this64.doesServerSupportUnstableFeature("org.matrix.msc2285.stable")) || (yield _this64.isVersionSupported("v1.4"))) {
5745
5836
  content[ReceiptType.ReadPrivate] = rpEventId;
5746
5837
  }
5747
- return _this62.http.authedRequest(Method.Post, path, undefined, content);
5838
+ return _this64.http.authedRequest(Method.Post, path, undefined, content);
5748
5839
  })();
5749
5840
  }
5750
5841
 
@@ -5978,9 +6069,9 @@ export class BriijClient extends TypedEventEmitter {
5978
6069
  * @returns `true` if supported, otherwise `false`
5979
6070
  */
5980
6071
  doesServerSupportExtendedProfiles() {
5981
- var _this63 = this;
6072
+ var _this65 = this;
5982
6073
  return _asyncToGenerator(function* () {
5983
- return (yield _this63.isVersionSupported("v1.16")) || (yield _this63.doesServerSupportUnstableFeature(UNSTABLE_MSC4133_EXTENDED_PROFILES)) || (yield _this63.doesServerSupportUnstableFeature(STABLE_MSC4133_EXTENDED_PROFILES));
6074
+ return (yield _this65.isVersionSupported("v1.16")) || (yield _this65.doesServerSupportUnstableFeature(UNSTABLE_MSC4133_EXTENDED_PROFILES)) || (yield _this65.doesServerSupportUnstableFeature(STABLE_MSC4133_EXTENDED_PROFILES));
5984
6075
  })();
5985
6076
  }
5986
6077
 
@@ -5990,9 +6081,9 @@ export class BriijClient extends TypedEventEmitter {
5990
6081
  * @returns The prefix for use with `authedRequest`
5991
6082
  */
5992
6083
  getExtendedProfileRequestPrefix() {
5993
- var _this64 = this;
6084
+ var _this66 = this;
5994
6085
  return _asyncToGenerator(function* () {
5995
- if ((yield _this64.isVersionSupported("v1.16")) || (yield _this64.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable"))) {
6086
+ if ((yield _this66.isVersionSupported("v1.16")) || (yield _this66.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable"))) {
5996
6087
  return ClientPrefix.V3;
5997
6088
  }
5998
6089
  return "/_matrix/client/unstable/uk.tcpip.msc4133";
@@ -6010,15 +6101,15 @@ export class BriijClient extends TypedEventEmitter {
6010
6101
  * @throws A M_NOT_FOUND error if the profile could not be found.
6011
6102
  */
6012
6103
  getExtendedProfile(userId) {
6013
- var _this65 = this;
6104
+ var _this67 = this;
6014
6105
  return _asyncToGenerator(function* () {
6015
- if (!(yield _this65.doesServerSupportExtendedProfiles())) {
6106
+ if (!(yield _this67.doesServerSupportExtendedProfiles())) {
6016
6107
  throw new Error("Server does not support extended profiles");
6017
6108
  }
6018
- return _this65.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId", {
6109
+ return _this67.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId", {
6019
6110
  $userId: userId
6020
6111
  }), undefined, undefined, {
6021
- prefix: yield _this65.getExtendedProfileRequestPrefix()
6112
+ prefix: yield _this67.getExtendedProfileRequestPrefix()
6022
6113
  });
6023
6114
  })();
6024
6115
  }
@@ -6035,16 +6126,16 @@ export class BriijClient extends TypedEventEmitter {
6035
6126
  * @throws A M_NOT_FOUND error if the key was not set OR the profile could not be found.
6036
6127
  */
6037
6128
  getExtendedProfileProperty(userId, key) {
6038
- var _this66 = this;
6129
+ var _this68 = this;
6039
6130
  return _asyncToGenerator(function* () {
6040
- if (!(yield _this66.doesServerSupportExtendedProfiles())) {
6131
+ if (!(yield _this68.doesServerSupportExtendedProfiles())) {
6041
6132
  throw new Error("Server does not support extended profiles");
6042
6133
  }
6043
- var profile = yield _this66.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId/$key", {
6134
+ var profile = yield _this68.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId/$key", {
6044
6135
  $userId: userId,
6045
6136
  $key: key
6046
6137
  }), undefined, undefined, {
6047
- prefix: yield _this66.getExtendedProfileRequestPrefix()
6138
+ prefix: yield _this68.getExtendedProfileRequestPrefix()
6048
6139
  });
6049
6140
  return profile[key];
6050
6141
  })();
@@ -6060,19 +6151,19 @@ export class BriijClient extends TypedEventEmitter {
6060
6151
  * @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
6061
6152
  */
6062
6153
  setExtendedProfileProperty(key, value) {
6063
- var _this67 = this;
6154
+ var _this69 = this;
6064
6155
  return _asyncToGenerator(function* () {
6065
- if (!(yield _this67.doesServerSupportExtendedProfiles())) {
6156
+ if (!(yield _this69.doesServerSupportExtendedProfiles())) {
6066
6157
  throw new Error("Server does not support extended profiles");
6067
6158
  }
6068
- var userId = _this67.getUserId();
6069
- yield _this67.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId/$key", {
6159
+ var userId = _this69.getUserId();
6160
+ yield _this69.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId/$key", {
6070
6161
  $userId: userId,
6071
6162
  $key: key
6072
6163
  }), undefined, {
6073
6164
  [key]: value
6074
6165
  }, {
6075
- prefix: yield _this67.getExtendedProfileRequestPrefix()
6166
+ prefix: yield _this69.getExtendedProfileRequestPrefix()
6076
6167
  });
6077
6168
  })();
6078
6169
  }
@@ -6086,17 +6177,17 @@ export class BriijClient extends TypedEventEmitter {
6086
6177
  * @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
6087
6178
  */
6088
6179
  deleteExtendedProfileProperty(key) {
6089
- var _this68 = this;
6180
+ var _this70 = this;
6090
6181
  return _asyncToGenerator(function* () {
6091
- if (!(yield _this68.doesServerSupportExtendedProfiles())) {
6182
+ if (!(yield _this70.doesServerSupportExtendedProfiles())) {
6092
6183
  throw new Error("Server does not support extended profiles");
6093
6184
  }
6094
- var userId = _this68.getUserId();
6095
- yield _this68.http.authedRequest(Method.Delete, utils.encodeUri("/profile/$userId/$key", {
6185
+ var userId = _this70.getUserId();
6186
+ yield _this70.http.authedRequest(Method.Delete, utils.encodeUri("/profile/$userId/$key", {
6096
6187
  $userId: userId,
6097
6188
  $key: key
6098
6189
  }), undefined, undefined, {
6099
- prefix: yield _this68.getExtendedProfileRequestPrefix()
6190
+ prefix: yield _this70.getExtendedProfileRequestPrefix()
6100
6191
  });
6101
6192
  })();
6102
6193
  }
@@ -6112,16 +6203,16 @@ export class BriijClient extends TypedEventEmitter {
6112
6203
  * @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
6113
6204
  */
6114
6205
  patchExtendedProfile(profile) {
6115
- var _this69 = this;
6206
+ var _this71 = this;
6116
6207
  return _asyncToGenerator(function* () {
6117
- if (!(yield _this69.doesServerSupportExtendedProfiles())) {
6208
+ if (!(yield _this71.doesServerSupportExtendedProfiles())) {
6118
6209
  throw new Error("Server does not support extended profiles");
6119
6210
  }
6120
- var userId = _this69.getUserId();
6121
- return _this69.http.authedRequest(Method.Patch, utils.encodeUri("/profile/$userId", {
6211
+ var userId = _this71.getUserId();
6212
+ return _this71.http.authedRequest(Method.Patch, utils.encodeUri("/profile/$userId", {
6122
6213
  $userId: userId
6123
6214
  }), {}, profile, {
6124
- prefix: yield _this69.getExtendedProfileRequestPrefix()
6215
+ prefix: yield _this71.getExtendedProfileRequestPrefix()
6125
6216
  });
6126
6217
  })();
6127
6218
  }
@@ -6136,16 +6227,16 @@ export class BriijClient extends TypedEventEmitter {
6136
6227
  * @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
6137
6228
  */
6138
6229
  setExtendedProfile(profile) {
6139
- var _this70 = this;
6230
+ var _this72 = this;
6140
6231
  return _asyncToGenerator(function* () {
6141
- if (!(yield _this70.doesServerSupportExtendedProfiles())) {
6232
+ if (!(yield _this72.doesServerSupportExtendedProfiles())) {
6142
6233
  throw new Error("Server does not support extended profiles");
6143
6234
  }
6144
- var userId = _this70.getUserId();
6145
- yield _this70.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId", {
6235
+ var userId = _this72.getUserId();
6236
+ yield _this72.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId", {
6146
6237
  $userId: userId
6147
6238
  }), {}, profile, {
6148
- prefix: yield _this70.getExtendedProfileRequestPrefix()
6239
+ prefix: yield _this72.getExtendedProfileRequestPrefix()
6149
6240
  });
6150
6241
  })();
6151
6242
  }
@@ -6168,10 +6259,10 @@ export class BriijClient extends TypedEventEmitter {
6168
6259
  * @returns Rejects: with an error response.
6169
6260
  */
6170
6261
  addThreePidOnly(data) {
6171
- var _this71 = this;
6262
+ var _this73 = this;
6172
6263
  return _asyncToGenerator(function* () {
6173
6264
  var path = "/account/3pid/add";
6174
- return _this71.http.authedRequest(Method.Post, path, undefined, data);
6265
+ return _this73.http.authedRequest(Method.Post, path, undefined, data);
6175
6266
  })();
6176
6267
  }
6177
6268
 
@@ -6187,10 +6278,10 @@ export class BriijClient extends TypedEventEmitter {
6187
6278
  * @returns Rejects: with an error response.
6188
6279
  */
6189
6280
  bindThreePid(data) {
6190
- var _this72 = this;
6281
+ var _this74 = this;
6191
6282
  return _asyncToGenerator(function* () {
6192
6283
  var path = "/account/3pid/bind";
6193
- return _this72.http.authedRequest(Method.Post, path, undefined, data);
6284
+ return _this74.http.authedRequest(Method.Post, path, undefined, data);
6194
6285
  })();
6195
6286
  }
6196
6287
 
@@ -6208,15 +6299,15 @@ export class BriijClient extends TypedEventEmitter {
6208
6299
  unbindThreePid(medium, address
6209
6300
  // eslint-disable-next-line camelcase
6210
6301
  ) {
6211
- var _this73 = this;
6302
+ var _this75 = this;
6212
6303
  return _asyncToGenerator(function* () {
6213
6304
  var path = "/account/3pid/unbind";
6214
6305
  var data = {
6215
6306
  medium,
6216
6307
  address,
6217
- id_server: _this73.getIdentityServerUrl(true)
6308
+ id_server: _this75.getIdentityServerUrl(true)
6218
6309
  };
6219
- return _this73.http.authedRequest(Method.Post, path, undefined, data);
6310
+ return _this75.http.authedRequest(Method.Post, path, undefined, data);
6220
6311
  })();
6221
6312
  }
6222
6313
 
@@ -6338,13 +6429,13 @@ export class BriijClient extends TypedEventEmitter {
6338
6429
  * @returns Rejects: with an error response.
6339
6430
  */
6340
6431
  getPushers() {
6341
- var _this74 = this;
6432
+ var _this76 = this;
6342
6433
  return _asyncToGenerator(function* () {
6343
- var response = yield _this74.http.authedRequest(Method.Get, "/pushers");
6434
+ var response = yield _this76.http.authedRequest(Method.Get, "/pushers");
6344
6435
 
6345
6436
  // Migration path for clients that connect to a homeserver that does not support
6346
6437
  // MSC3881 yet, see https://github.com/matrix-org/matrix-spec-proposals/blob/kerry/remote-push-toggle/proposals/3881-remote-push-notification-toggling.md#migration
6347
- if (!(yield _this74.doesServerSupportUnstableFeature("org.matrix.msc3881"))) {
6438
+ if (!(yield _this76.doesServerSupportUnstableFeature("org.matrix.msc3881"))) {
6348
6439
  response.pushers = response.pushers.map(pusher => {
6349
6440
  if (!pusher.hasOwnProperty(PUSHER_ENABLED.name)) {
6350
6441
  pusher[PUSHER_ENABLED.name] = true;
@@ -6774,7 +6865,7 @@ export class BriijClient extends TypedEventEmitter {
6774
6865
  * found MXIDs. Results where no user could be found will not be listed.
6775
6866
  */
6776
6867
  identityHashedLookup(addressPairs, identityAccessToken) {
6777
- var _this75 = this;
6868
+ var _this77 = this;
6778
6869
  return _asyncToGenerator(function* () {
6779
6870
  var params = {
6780
6871
  // addresses: ["email@example.org", "10005550000"],
@@ -6783,7 +6874,7 @@ export class BriijClient extends TypedEventEmitter {
6783
6874
  };
6784
6875
 
6785
6876
  // Get hash information first before trying to do a lookup
6786
- var hashes = yield _this75.getIdentityHashDetails(identityAccessToken);
6877
+ var hashes = yield _this77.getIdentityHashDetails(identityAccessToken);
6787
6878
  if (!hashes || !hashes["lookup_pepper"] || !hashes["algorithms"]) {
6788
6879
  throw new Error("Unsupported identity server: bad response");
6789
6880
  }
@@ -6826,7 +6917,7 @@ export class BriijClient extends TypedEventEmitter {
6826
6917
  } else {
6827
6918
  throw new Error("Unsupported identity server: unknown hash algorithm");
6828
6919
  }
6829
- var response = yield _this75.http.idServerRequest(Method.Post, "/lookup", params, IdentityPrefix.V2, identityAccessToken);
6920
+ var response = yield _this77.http.idServerRequest(Method.Post, "/lookup", params, IdentityPrefix.V2, identityAccessToken);
6830
6921
  if (!(response !== null && response !== void 0 && response["mappings"])) return []; // no results
6831
6922
 
6832
6923
  var foundAddresses = [];
@@ -6860,12 +6951,12 @@ export class BriijClient extends TypedEventEmitter {
6860
6951
  * @returns Rejects: with an error response.
6861
6952
  */
6862
6953
  lookupThreePid(medium, address, identityAccessToken) {
6863
- var _this76 = this;
6954
+ var _this78 = this;
6864
6955
  return _asyncToGenerator(function* () {
6865
6956
  // Note: we're using the V2 API by calling this function, but our
6866
6957
  // function contract requires a V1 response. We therefore have to
6867
6958
  // convert it manually.
6868
- var response = yield _this76.identityHashedLookup([[address, medium]], identityAccessToken);
6959
+ var response = yield _this78.identityHashedLookup([[address, medium]], identityAccessToken);
6869
6960
  var result = response.find(p => p.address === address);
6870
6961
  if (!result) {
6871
6962
  return {};
@@ -6897,12 +6988,12 @@ export class BriijClient extends TypedEventEmitter {
6897
6988
  * @returns Rejects: with an error response.
6898
6989
  */
6899
6990
  bulkLookupThreePids(query, identityAccessToken) {
6900
- var _this77 = this;
6991
+ var _this79 = this;
6901
6992
  return _asyncToGenerator(function* () {
6902
6993
  // Note: we're using the V2 API by calling this function, but our
6903
6994
  // function contract requires a V1 response. We therefore have to
6904
6995
  // convert it manually.
6905
- var response = yield _this77.identityHashedLookup(
6996
+ var response = yield _this79.identityHashedLookup(
6906
6997
  // We have to reverse the query order to get [address, medium] pairs
6907
6998
  query.map(p => [p[1], p[0]]), identityAccessToken);
6908
6999
  var v1results = [];
@@ -6976,16 +7067,16 @@ export class BriijClient extends TypedEventEmitter {
6976
7067
  * @returns Promise which resolves once queued there is no error feedback when sending fails.
6977
7068
  */
6978
7069
  encryptAndSendToDevice(eventType, devices, payload) {
6979
- var _this78 = this;
7070
+ var _this80 = this;
6980
7071
  return _asyncToGenerator(function* () {
6981
- if (!_this78.cryptoBackend) {
7072
+ if (!_this80.cryptoBackend) {
6982
7073
  throw new Error("Cannot encrypt to device event, your client does not support encryption.");
6983
7074
  }
6984
- var batch = yield _this78.cryptoBackend.encryptToDeviceMessages(eventType, devices, payload);
7075
+ var batch = yield _this80.cryptoBackend.encryptToDeviceMessages(eventType, devices, payload);
6985
7076
 
6986
7077
  // TODO The batch mechanism removes all possibility to get error feedbacks..
6987
7078
  // We might want instead to do the API call directly and pass the errors back.
6988
- yield _this78.queueToDevice(batch);
7079
+ yield _this80.queueToDevice(batch);
6989
7080
  })();
6990
7081
  }
6991
7082
 
@@ -7142,16 +7233,16 @@ export class BriijClient extends TypedEventEmitter {
7142
7233
  * @returns Promise which resolves to the created space.
7143
7234
  */
7144
7235
  unstableCreateFileTree(name) {
7145
- var _this79 = this;
7236
+ var _this81 = this;
7146
7237
  return _asyncToGenerator(function* () {
7147
7238
  var {
7148
7239
  room_id: roomId
7149
- } = yield _this79.createRoom({
7240
+ } = yield _this81.createRoom({
7150
7241
  name: name,
7151
7242
  preset: Preset.PrivateChat,
7152
7243
  power_level_content_override: _objectSpread(_objectSpread({}, DEFAULT_TREE_POWER_LEVELS_TEMPLATE), {}, {
7153
7244
  users: {
7154
- [_this79.getUserId()]: 100
7245
+ [_this81.getUserId()]: 100
7155
7246
  }
7156
7247
  }),
7157
7248
  creation_content: {
@@ -7171,7 +7262,7 @@ export class BriijClient extends TypedEventEmitter {
7171
7262
  }
7172
7263
  }]
7173
7264
  });
7174
- return new MSC3089TreeSpace(_this79, roomId);
7265
+ return new MSC3089TreeSpace(_this81, roomId);
7175
7266
  })();
7176
7267
  }
7177
7268
 
@@ -7248,7 +7339,7 @@ export class BriijClient extends TypedEventEmitter {
7248
7339
  * @param via - The list of servers which know about the room if only an ID was provided.
7249
7340
  */
7250
7341
  getRoomSummary(roomIdOrAlias, via) {
7251
- var _this80 = this;
7342
+ var _this82 = this;
7252
7343
  return _asyncToGenerator(function* () {
7253
7344
  var paramOpts = {
7254
7345
  prefix: "/_matrix/client/unstable/im.nheko.summary"
@@ -7257,7 +7348,7 @@ export class BriijClient extends TypedEventEmitter {
7257
7348
  var path = utils.encodeUri("/summary/$roomid", {
7258
7349
  $roomid: roomIdOrAlias
7259
7350
  });
7260
- return yield _this80.http.authedRequest(Method.Get, path, {
7351
+ return yield _this82.http.authedRequest(Method.Get, path, {
7261
7352
  via
7262
7353
  }, undefined, paramOpts);
7263
7354
  } catch (e) {
@@ -7265,7 +7356,7 @@ export class BriijClient extends TypedEventEmitter {
7265
7356
  var _path = utils.encodeUri("/rooms/$roomid/summary", {
7266
7357
  $roomid: roomIdOrAlias
7267
7358
  });
7268
- return yield _this80.http.authedRequest(Method.Get, _path, {
7359
+ return yield _this82.http.authedRequest(Method.Get, _path, {
7269
7360
  via
7270
7361
  }, undefined, paramOpts);
7271
7362
  } else {
@@ -7317,9 +7408,9 @@ export class BriijClient extends TypedEventEmitter {
7317
7408
  * Fetches information about the user for the configured access token.
7318
7409
  */
7319
7410
  whoami() {
7320
- var _this81 = this;
7411
+ var _this83 = this;
7321
7412
  return _asyncToGenerator(function* () {
7322
- return _this81.http.authedRequest(Method.Get, "/account/whoami");
7413
+ return _this83.http.authedRequest(Method.Get, "/account/whoami");
7323
7414
  })();
7324
7415
  }
7325
7416
 
@@ -7330,7 +7421,7 @@ export class BriijClient extends TypedEventEmitter {
7330
7421
  * @returns Rejects: when the request fails (module:http-api.BriijError)
7331
7422
  */
7332
7423
  timestampToEvent(roomId, timestamp, dir) {
7333
- var _this82 = this;
7424
+ var _this84 = this;
7334
7425
  return _asyncToGenerator(function* () {
7335
7426
  var path = utils.encodeUri("/rooms/$roomId/timestamp_to_event", {
7336
7427
  $roomId: roomId
@@ -7340,7 +7431,7 @@ export class BriijClient extends TypedEventEmitter {
7340
7431
  dir: dir
7341
7432
  };
7342
7433
  try {
7343
- return yield _this82.http.authedRequest(Method.Get, path, queryParams, undefined, {
7434
+ return yield _this84.http.authedRequest(Method.Get, path, queryParams, undefined, {
7344
7435
  prefix: ClientPrefix.V1
7345
7436
  });
7346
7437
  } catch (err) {
@@ -7356,7 +7447,7 @@ export class BriijClient extends TypedEventEmitter {
7356
7447
  // both indicate that this endpoint+verb combination is
7357
7448
  // not supported.
7358
7449
  err.httpStatus === 404 || err.httpStatus === 405)) {
7359
- return yield _this82.http.authedRequest(Method.Get, path, queryParams, undefined, {
7450
+ return yield _this84.http.authedRequest(Method.Get, path, queryParams, undefined, {
7360
7451
  prefix: "/_matrix/client/unstable/org.matrix.msc3030"
7361
7452
  });
7362
7453
  }
@@ -7376,12 +7467,12 @@ export class BriijClient extends TypedEventEmitter {
7376
7467
  * @throws when delegated auth config is invalid or unreachable
7377
7468
  */
7378
7469
  getAuthMetadata() {
7379
- var _this83 = this;
7470
+ var _this85 = this;
7380
7471
  return _asyncToGenerator(function* () {
7381
7472
  var authMetadata;
7382
7473
  try {
7383
- var useStable = yield _this83.isVersionSupported("v1.15");
7384
- authMetadata = yield _this83.http.request(Method.Get, "/auth_metadata", undefined, undefined, {
7474
+ var useStable = yield _this85.isVersionSupported("v1.15");
7475
+ authMetadata = yield _this85.http.request(Method.Get, "/auth_metadata", undefined, undefined, {
7385
7476
  prefix: useStable ? ClientPrefix.V1 : ClientPrefix.Unstable + "/org.matrix.msc2965"
7386
7477
  });
7387
7478
  } catch (e) {
@@ -7389,7 +7480,7 @@ export class BriijClient extends TypedEventEmitter {
7389
7480
  // Fall back to older variant of MSC2965
7390
7481
  var {
7391
7482
  issuer
7392
- } = yield _this83.http.request(Method.Get, "/auth_issuer", undefined, undefined, {
7483
+ } = yield _this85.http.request(Method.Get, "/auth_issuer", undefined, undefined, {
7393
7484
  prefix: ClientPrefix.Unstable + "/org.matrix.msc2965"
7394
7485
  });
7395
7486
  return discoverAndValidateOIDCIssuerWellKnown(issuer);