@textrp/briij-js-sdk 42.0.0 → 43.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +7 -4
  2. package/README.md +71 -0
  3. package/lib/@types/auth.d.ts +57 -2
  4. package/lib/@types/auth.d.ts.map +1 -1
  5. package/lib/@types/auth.js +2 -0
  6. package/lib/@types/auth.js.map +1 -1
  7. package/lib/@types/event.d.ts +3 -0
  8. package/lib/@types/event.d.ts.map +1 -1
  9. package/lib/@types/event.js.map +1 -1
  10. package/lib/@types/synapse.d.ts +64 -0
  11. package/lib/@types/synapse.d.ts.map +1 -1
  12. package/lib/@types/synapse.js.map +1 -1
  13. package/lib/briij.d.ts +2 -0
  14. package/lib/briij.d.ts.map +1 -1
  15. package/lib/briij.js +2 -0
  16. package/lib/briij.js.map +1 -1
  17. package/lib/client.d.ts +100 -7
  18. package/lib/client.d.ts.map +1 -1
  19. package/lib/client.js +469 -213
  20. package/lib/client.js.map +1 -1
  21. package/lib/wallet-recovery.d.ts +24 -0
  22. package/lib/wallet-recovery.d.ts.map +1 -0
  23. package/lib/wallet-recovery.js +256 -0
  24. package/lib/wallet-recovery.js.map +1 -0
  25. package/lib/xrpl/identity.d.ts +2 -1
  26. package/lib/xrpl/identity.d.ts.map +1 -1
  27. package/lib/xrpl/identity.js +70 -47
  28. package/lib/xrpl/identity.js.map +1 -1
  29. package/lib/xrpl/trust.d.ts +4 -2
  30. package/lib/xrpl/trust.d.ts.map +1 -1
  31. package/lib/xrpl/trust.js +31 -19
  32. package/lib/xrpl/trust.js.map +1 -1
  33. package/lib/xrpl/verification.js +17 -6
  34. package/lib/xrpl/verification.js.map +1 -1
  35. package/package.json +1 -1
  36. package/src/@types/auth.ts +61 -2
  37. package/src/@types/event.ts +3 -0
  38. package/src/@types/synapse.ts +77 -0
  39. package/src/briij.ts +2 -0
  40. package/src/client.ts +344 -46
  41. package/src/wallet-recovery.ts +327 -0
  42. package/src/xrpl/identity.ts +66 -39
  43. package/src/xrpl/trust.ts +35 -18
  44. package/src/xrpl/verification.ts +19 -6
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";
@@ -76,9 +76,8 @@ import { KnownMembership } from "./@types/membership.js";
76
76
  import { ServerCapabilities } from "./serverCapabilities.js";
77
77
  import { sha256 } from "./digest.js";
78
78
  import { discoverAndValidateOIDCIssuerWellKnown, validateAuthMetadataAndKeys } from "./oidc/index.js";
79
- import { configureXrplIdentityMinting, mintSoulboundIdentityNFT } from "./xrpl/identity.js";
79
+ import { getConfiguredXrplIdentityMintingConfig, mintSoulboundIdentityNFT } from "./xrpl/identity.js";
80
80
  import { XRPL_VERIFIED_EVENT, XRPL_VERIFY_ACCEPT_EVENT, XRPL_VERIFY_REQUEST_EVENT } from "./xrpl/verification.js";
81
- import { configureXrplTrust } from "./xrpl/trust.js";
82
81
  import { UnsupportedDelayedEventsEndpointError, UnsupportedStickyEventsEndpointError } from "./errors.js";
83
82
  var SCROLLBACK_DELAY_MS = 3000;
84
83
  var TURN_CHECK_INTERVAL = 10 * 60 * 1000; // poll for turn credentials every 10 minutes
@@ -327,7 +326,7 @@ var SSO_ACTION_PARAM = new UnstableValue("action", "org.matrix.msc3824.action");
327
326
  */
328
327
  export class BriijClient extends TypedEventEmitter {
329
328
  constructor(opts) {
330
- var _opts$logger, _opts$usingExternalCr, _this, _opts$disableVoip, _opts$enableEncrypted, _opts$cryptoCallbacks;
329
+ var _opts$logger, _opts$usingExternalCr, _opts$xrplIdentityMin, _this, _opts$disableVoip, _opts$enableEncrypted, _opts$cryptoCallbacks;
331
330
  // If a custom logger is provided, use it. Otherwise, default to the global
332
331
  // one in logger.ts.
333
332
  super();
@@ -412,6 +411,8 @@ export class BriijClient extends TypedEventEmitter {
412
411
  _defineProperty(this, "clientOpts", void 0);
413
412
  _defineProperty(this, "clientWellKnownIntervalID", void 0);
414
413
  _defineProperty(this, "canResetTimelineCallback", void 0);
414
+ _defineProperty(this, "xrplTrustConfig", void 0);
415
+ _defineProperty(this, "xrplIdentityMintingConfig", {});
415
416
  _defineProperty(this, "canSupport", new Map());
416
417
  // The pushprocessor caches useful things, so keep one and re-use it
417
418
  _defineProperty(this, "pushProcessor", new PushProcessor(this));
@@ -505,6 +506,17 @@ export class BriijClient extends TypedEventEmitter {
505
506
  this.credentials = {
506
507
  userId
507
508
  };
509
+ if (opts.xrplTrust) {
510
+ var _opts$xrplTrust$homes, _ref, _opts$xrplTrust$acces;
511
+ this.xrplTrustConfig = {
512
+ homeserverBaseUrl: (_opts$xrplTrust$homes = opts.xrplTrust.homeserverBaseUrl) !== null && _opts$xrplTrust$homes !== void 0 ? _opts$xrplTrust$homes : this.baseUrl,
513
+ accessToken: (_ref = (_opts$xrplTrust$acces = opts.xrplTrust.accessToken) !== null && _opts$xrplTrust$acces !== void 0 ? _opts$xrplTrust$acces : opts.accessToken) !== null && _ref !== void 0 ? _ref : "",
514
+ trustPath: opts.xrplTrust.trustPath
515
+ };
516
+ }
517
+ this.xrplIdentityMintingConfig = _objectSpread(_objectSpread({}, (_opts$xrplIdentityMin = opts.xrplIdentityMinting) !== null && _opts$xrplIdentityMin !== void 0 ? _opts$xrplIdentityMin : {}), opts.xamanWallet ? {
518
+ xamanWallet: opts.xamanWallet
519
+ } : {});
508
520
  this.http = new BriijHttpApi(this, {
509
521
  fetchFn: opts.fetchFn,
510
522
  baseUrl: opts.baseUrl,
@@ -526,7 +538,7 @@ export class BriijClient extends TypedEventEmitter {
526
538
  this.scheduler = opts.scheduler;
527
539
  if (this.scheduler) {
528
540
  this.scheduler.setProcessFunction(/*#__PURE__*/function () {
529
- var _ref = _asyncToGenerator(function* (eventToSend) {
541
+ var _ref2 = _asyncToGenerator(function* (eventToSend) {
530
542
  var room = _this.getRoom(eventToSend.getRoomId());
531
543
  if (eventToSend.status !== EventStatus.SENDING) {
532
544
  _this.updatePendingEventStatus(room, eventToSend, EventStatus.SENDING);
@@ -540,7 +552,7 @@ export class BriijClient extends TypedEventEmitter {
540
552
  return res;
541
553
  });
542
554
  return function (_x) {
543
- return _ref.apply(this, arguments);
555
+ return _ref2.apply(this, arguments);
544
556
  };
545
557
  }());
546
558
  }
@@ -733,7 +745,7 @@ export class BriijClient extends TypedEventEmitter {
733
745
 
734
746
  // delete the stores used by the rust matrix-sdk-crypto, in case they were used
735
747
  var deleteRustSdkStore = /*#__PURE__*/function () {
736
- var _ref2 = _asyncToGenerator(function* () {
748
+ var _ref3 = _asyncToGenerator(function* () {
737
749
  var indexedDB;
738
750
  try {
739
751
  indexedDB = globalThis.indexedDB;
@@ -771,7 +783,7 @@ export class BriijClient extends TypedEventEmitter {
771
783
  }
772
784
  });
773
785
  return function deleteRustSdkStore() {
774
- return _ref2.apply(this, arguments);
786
+ return _ref3.apply(this, arguments);
775
787
  };
776
788
  }();
777
789
  promises.push(deleteRustSdkStore());
@@ -1866,7 +1878,7 @@ export class BriijClient extends TypedEventEmitter {
1866
1878
  * @returns Rejects: with an error response.
1867
1879
  */
1868
1880
 
1869
- sendCompleteEvent(_ref3) {
1881
+ sendCompleteEvent(_ref4) {
1870
1882
  var {
1871
1883
  roomId,
1872
1884
  threadId,
@@ -1874,7 +1886,7 @@ export class BriijClient extends TypedEventEmitter {
1874
1886
  delayOpts,
1875
1887
  queryDict,
1876
1888
  txnId
1877
- } = _ref3;
1889
+ } = _ref4;
1878
1890
  if (!txnId) {
1879
1891
  txnId = this.makeTxnId();
1880
1892
  }
@@ -3440,7 +3452,7 @@ export class BriijClient extends TypedEventEmitter {
3440
3452
  getEventTimeline(timelineSet, eventId) {
3441
3453
  var _this39 = this;
3442
3454
  return _asyncToGenerator(function* () {
3443
- var _ref4, _timelineSet$getTimel, _timelineSet$room$fin;
3455
+ var _ref5, _timelineSet$getTimel, _timelineSet$room$fin;
3444
3456
  // don't allow any timeline support unless it's been enabled.
3445
3457
  if (!_this39.timelineSupport) {
3446
3458
  throw new Error("timeline support is disabled. Set the 'timelineSupport'" + " parameter to true when creating BriijClient to enable it.");
@@ -3493,7 +3505,7 @@ export class BriijClient extends TypedEventEmitter {
3493
3505
  // There is no guarantee that the event ended up in "timeline" (we might have switched to a neighbouring
3494
3506
  // timeline) - so check the room's index again. On the other hand, there's no guarantee the event ended up
3495
3507
  // anywhere, if it was later redacted, so we just return the timeline we first thought of.
3496
- return (_ref4 = (_timelineSet$getTimel = timelineSet.getTimelineForEvent(eventId)) !== null && _timelineSet$getTimel !== void 0 ? _timelineSet$getTimel : (_timelineSet$room$fin = timelineSet.room.findThreadForEvent(event)) === null || _timelineSet$room$fin === void 0 ? void 0 : _timelineSet$room$fin.liveTimeline) !== null && _ref4 !== void 0 ? _ref4 :
3508
+ return (_ref5 = (_timelineSet$getTimel = timelineSet.getTimelineForEvent(eventId)) !== null && _timelineSet$getTimel !== void 0 ? _timelineSet$getTimel : (_timelineSet$room$fin = timelineSet.room.findThreadForEvent(event)) === null || _timelineSet$room$fin === void 0 ? void 0 : _timelineSet$room$fin.liveTimeline) !== null && _ref5 !== void 0 ? _ref5 :
3497
3509
  // for Threads degraded support
3498
3510
  timeline;
3499
3511
  })();
@@ -3815,7 +3827,7 @@ export class BriijClient extends TypedEventEmitter {
3815
3827
  params.from = token;
3816
3828
  }
3817
3829
  promise = this.http.authedRequest(Method.Get, path, params).then(/*#__PURE__*/function () {
3818
- var _ref5 = _asyncToGenerator(function* (res) {
3830
+ var _ref6 = _asyncToGenerator(function* (res) {
3819
3831
  var token = res.next_token;
3820
3832
  var matrixEvents = [];
3821
3833
  res.notifications = res.notifications.filter(noUnsafeEventProps);
@@ -3845,7 +3857,7 @@ export class BriijClient extends TypedEventEmitter {
3845
3857
  return Boolean(res.next_token);
3846
3858
  });
3847
3859
  return function (_x2) {
3848
- return _ref5.apply(this, arguments);
3860
+ return _ref6.apply(this, arguments);
3849
3861
  };
3850
3862
  }()).finally(() => {
3851
3863
  eventTimeline.paginationRequests[dir] = null;
@@ -3895,7 +3907,7 @@ export class BriijClient extends TypedEventEmitter {
3895
3907
  from: token !== null && token !== void 0 ? token : undefined,
3896
3908
  recurse: recurse || undefined
3897
3909
  }).then(/*#__PURE__*/function () {
3898
- var _ref6 = _asyncToGenerator(function* (res) {
3910
+ var _ref7 = _asyncToGenerator(function* (res) {
3899
3911
  var mapper = _this42.getEventMapper();
3900
3912
  var matrixEvents = res.chunk.filter(noUnsafeEventProps).filter(getRelationsThreadFilter(thread.id)).map(mapper);
3901
3913
 
@@ -3926,7 +3938,7 @@ export class BriijClient extends TypedEventEmitter {
3926
3938
  return Boolean(newToken);
3927
3939
  });
3928
3940
  return function (_x3) {
3929
- return _ref6.apply(this, arguments);
3941
+ return _ref7.apply(this, arguments);
3930
3942
  };
3931
3943
  }()).finally(() => {
3932
3944
  eventTimeline.paginationRequests[dir] = null;
@@ -4654,6 +4666,33 @@ export class BriijClient extends TypedEventEmitter {
4654
4666
  return this.fallbackICEServerAllowed;
4655
4667
  }
4656
4668
 
4669
+ /**
4670
+ * Some briij deployments mount admin resources under `/_briij/admin` while
4671
+ * Synapse defaults to `/_synapse/admin`. Try both prefixes to stay compatible.
4672
+ */
4673
+ authedRequestWithAdminPrefixes(method, adminSubPath, queryParams, body) {
4674
+ var _this46 = this;
4675
+ return _asyncToGenerator(function* () {
4676
+ var normalizedSubPath = adminSubPath.replace(/^\/+/, "");
4677
+ var adminPrefixes = ["/_synapse/admin", "/_briij/admin"];
4678
+ var lastError;
4679
+ for (var adminPrefix of adminPrefixes) {
4680
+ try {
4681
+ return yield _this46.http.authedRequest(method, "".concat(adminPrefix, "/").concat(normalizedSubPath), queryParams, body, {
4682
+ prefix: ""
4683
+ });
4684
+ } catch (error) {
4685
+ if (error instanceof BriijError && error.httpStatus === 404) {
4686
+ lastError = error;
4687
+ continue;
4688
+ }
4689
+ throw error;
4690
+ }
4691
+ }
4692
+ throw lastError !== null && lastError !== void 0 ? lastError : new Error("Admin API endpoint not found");
4693
+ })();
4694
+ }
4695
+
4657
4696
  /**
4658
4697
  * Determines if the current user is an administrator of the Synapse homeserver.
4659
4698
  * Returns false if untrue or the homeserver does not appear to be a Synapse
@@ -4662,12 +4701,24 @@ export class BriijClient extends TypedEventEmitter {
4662
4701
  * @returns true if the user appears to be a Synapse administrator.
4663
4702
  */
4664
4703
  isSynapseAdministrator() {
4665
- var path = utils.encodeUri("/_synapse/admin/v1/users/$userId/admin", {
4666
- $userId: this.getUserId()
4667
- });
4668
- return this.http.authedRequest(Method.Get, path, undefined, undefined, {
4669
- prefix: ""
4670
- }).then(r => r.admin); // pull out the specific boolean we want
4704
+ var _this47 = this;
4705
+ return _asyncToGenerator(function* () {
4706
+ var adminSubPath = utils.encodeUri("v1/users/$userId/admin", {
4707
+ $userId: _this47.getUserId()
4708
+ });
4709
+ try {
4710
+ var response = yield _this47.authedRequestWithAdminPrefixes(Method.Get, adminSubPath);
4711
+ return response.admin;
4712
+ } catch (error) {
4713
+ if (error instanceof BriijError && error.httpStatus === 404) {
4714
+ return false;
4715
+ }
4716
+ if (error instanceof Error && /Admin API endpoint not found/i.test(error.message)) {
4717
+ return false;
4718
+ }
4719
+ throw error;
4720
+ }
4721
+ })();
4671
4722
  }
4672
4723
 
4673
4724
  /**
@@ -4678,12 +4729,10 @@ export class BriijClient extends TypedEventEmitter {
4678
4729
  * @returns the whois response - see Synapse docs for information.
4679
4730
  */
4680
4731
  whoisSynapseUser(userId) {
4681
- var path = utils.encodeUri("/_synapse/admin/v1/whois/$userId", {
4732
+ var adminSubPath = utils.encodeUri("v1/whois/$userId", {
4682
4733
  $userId: userId
4683
4734
  });
4684
- return this.http.authedRequest(Method.Get, path, undefined, undefined, {
4685
- prefix: ""
4686
- });
4735
+ return this.authedRequestWithAdminPrefixes(Method.Get, adminSubPath);
4687
4736
  }
4688
4737
 
4689
4738
  /**
@@ -4693,22 +4742,120 @@ export class BriijClient extends TypedEventEmitter {
4693
4742
  * @returns the deactivate response - see Synapse docs for information.
4694
4743
  */
4695
4744
  deactivateSynapseUser(userId) {
4696
- var path = utils.encodeUri("/_synapse/admin/v1/deactivate/$userId", {
4745
+ var adminSubPath = utils.encodeUri("v1/deactivate/$userId", {
4697
4746
  $userId: userId
4698
4747
  });
4699
- return this.http.authedRequest(Method.Post, path, undefined, undefined, {
4748
+ return this.authedRequestWithAdminPrefixes(Method.Post, adminSubPath);
4749
+ }
4750
+
4751
+ /**
4752
+ * Lists active mCredits features for the authenticated user.
4753
+ */
4754
+ getBriijMcreditsFeatures() {
4755
+ return this.http.authedRequest(Method.Get, "/mcredits/features", undefined, undefined, {
4756
+ prefix: ClientPrefix.V3
4757
+ });
4758
+ }
4759
+
4760
+ /**
4761
+ * Retrieves the authenticated user's mCredits balance.
4762
+ */
4763
+ getBriijMcreditsBalance() {
4764
+ return this.http.authedRequest(Method.Get, "/mcredits/balance", undefined, undefined, {
4765
+ prefix: ClientPrefix.V3
4766
+ });
4767
+ }
4768
+
4769
+ /**
4770
+ * Spends mCredits for a premium feature.
4771
+ * @param featureKey - The premium feature identifier to spend against.
4772
+ */
4773
+ spendBriijMcredits(featureKey) {
4774
+ return this.http.authedRequest(Method.Post, "/mcredits/spend", undefined, {
4775
+ feature_key: featureKey
4776
+ }, {
4777
+ prefix: ClientPrefix.V3
4778
+ });
4779
+ }
4780
+
4781
+ /**
4782
+ * Calls Briij's legacy-compatible endpoint to resolve a Matrix user to wallet/mcredit payload.
4783
+ * @param matrixUserId - Matrix user ID used by legacy clients.
4784
+ */
4785
+ getBriijLegacyMyAddress(matrixUserId) {
4786
+ return this.http.authedRequest(Method.Post, "/my-address", undefined, {
4787
+ address: matrixUserId
4788
+ }, {
4789
+ prefix: ""
4790
+ });
4791
+ }
4792
+
4793
+ /**
4794
+ * Calls Briij's legacy-compatible enabled-features endpoint.
4795
+ * @param walletAddress - XRPL wallet address.
4796
+ * @param network - Legacy network segment; defaults to `main`.
4797
+ */
4798
+ getBriijLegacyEnabledFeatures(walletAddress) {
4799
+ var network = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "main";
4800
+ var path = utils.encodeUri("/my-features/$walletAddress/$network/enabled", {
4801
+ $walletAddress: walletAddress,
4802
+ $network: network
4803
+ });
4804
+ return this.http.authedRequest(Method.Get, path, undefined, undefined, {
4700
4805
  prefix: ""
4701
4806
  });
4702
4807
  }
4808
+
4809
+ /**
4810
+ * Lists mCredits premium features from Synapse admin APIs.
4811
+ */
4812
+ getBriijAdminPremiumFeatures() {
4813
+ var _this48 = this;
4814
+ return _asyncToGenerator(function* () {
4815
+ var response = yield _this48.authedRequestWithAdminPrefixes(Method.Get, "v2/briij/premium_features");
4816
+ return response.premium_features;
4817
+ })();
4818
+ }
4819
+
4820
+ /**
4821
+ * Creates an mCredits premium feature via Synapse admin APIs.
4822
+ * @param body - Feature fields to create.
4823
+ */
4824
+ createBriijAdminPremiumFeature(body) {
4825
+ return this.authedRequestWithAdminPrefixes(Method.Post, "v2/briij/premium_features", undefined, body);
4826
+ }
4827
+
4828
+ /**
4829
+ * Updates an mCredits premium feature via Synapse admin APIs.
4830
+ * @param featureKey - The premium feature key to update.
4831
+ * @param body - Updatable feature fields.
4832
+ */
4833
+ updateBriijAdminPremiumFeature(featureKey, body) {
4834
+ var adminSubPath = utils.encodeUri("v2/briij/premium_features/$featureKey", {
4835
+ $featureKey: featureKey
4836
+ });
4837
+ return this.authedRequestWithAdminPrefixes(Method.Put, adminSubPath, undefined, body);
4838
+ }
4839
+
4840
+ /**
4841
+ * Soft-deactivates an mCredits premium feature via Synapse admin APIs.
4842
+ * @param featureKey - The premium feature key to deactivate.
4843
+ */
4844
+ deactivateBriijAdminPremiumFeature(featureKey) {
4845
+ var adminSubPath = utils.encodeUri("v2/briij/premium_features/$featureKey", {
4846
+ $featureKey: featureKey
4847
+ });
4848
+ return this.authedRequestWithAdminPrefixes(Method.Delete, adminSubPath);
4849
+ }
4703
4850
  fetchClientWellKnown() {
4704
- var _this46 = this;
4851
+ var _this49 = this;
4705
4852
  return _asyncToGenerator(function* () {
4706
- var _this46$getDomain;
4853
+ var _this49$getDomain;
4707
4854
  // `getRawClientConfig` does not throw or reject on network errors, instead
4708
4855
  // it absorbs errors and returns `{}`.
4709
- _this46.clientWellKnownPromise = AutoDiscovery.getRawClientConfig((_this46$getDomain = _this46.getDomain()) !== null && _this46$getDomain !== void 0 ? _this46$getDomain : undefined);
4710
- _this46.clientWellKnown = yield _this46.clientWellKnownPromise;
4711
- _this46.emit(ClientEvent.ClientWellKnown, _this46.clientWellKnown);
4856
+ _this49.clientWellKnownPromise = AutoDiscovery.getRawClientConfig((_this49$getDomain = _this49.getDomain()) !== null && _this49$getDomain !== void 0 ? _this49$getDomain : undefined);
4857
+ _this49.clientWellKnown = yield _this49.clientWellKnownPromise;
4858
+ _this49.emit(ClientEvent.ClientWellKnown, _this49.clientWellKnown);
4712
4859
  })();
4713
4860
  }
4714
4861
  getClientWellKnown() {
@@ -4730,11 +4877,11 @@ export class BriijClient extends TypedEventEmitter {
4730
4877
  storeClientOptions() {
4731
4878
  // XXX: Intended private, used in code
4732
4879
  var primTypes = ["boolean", "string", "number"];
4733
- var serializableOpts = Object.entries(this.clientOpts).filter(_ref7 => {
4734
- var [key, value] = _ref7;
4735
- return primTypes.includes(typeof value);
4736
- }).reduce((obj, _ref8) => {
4880
+ var serializableOpts = Object.entries(this.clientOpts).filter(_ref8 => {
4737
4881
  var [key, value] = _ref8;
4882
+ return primTypes.includes(typeof value);
4883
+ }).reduce((obj, _ref9) => {
4884
+ var [key, value] = _ref9;
4738
4885
  obj[key] = value;
4739
4886
  return obj;
4740
4887
  }, {});
@@ -4754,16 +4901,16 @@ export class BriijClient extends TypedEventEmitter {
4754
4901
  // TODO: on spec release, rename this to getMutualRooms
4755
4902
  // eslint-disable-next-line
4756
4903
  _unstable_getSharedRooms(userId) {
4757
- var _this47 = this;
4904
+ var _this50 = this;
4758
4905
  return _asyncToGenerator(function* () {
4759
4906
  // Initial variant of the MSC
4760
- var sharedRoomsSupport = yield _this47.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_SHARED_ROOMS);
4907
+ var sharedRoomsSupport = yield _this50.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_SHARED_ROOMS);
4761
4908
 
4762
4909
  // Newer variant that renamed shared rooms to mutual rooms
4763
- var mutualRoomsSupport = yield _this47.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_MUTUAL_ROOMS);
4910
+ var mutualRoomsSupport = yield _this50.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_MUTUAL_ROOMS);
4764
4911
 
4765
4912
  // Latest variant that changed from path elements to query elements
4766
- var queryMutualRoomsSupport = yield _this47.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_QUERY_MUTUAL_ROOMS);
4913
+ var queryMutualRoomsSupport = yield _this50.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_QUERY_MUTUAL_ROOMS);
4767
4914
  if (!sharedRoomsSupport && !mutualRoomsSupport && !queryMutualRoomsSupport) {
4768
4915
  throw Error("Server does not support the Mutual Rooms API");
4769
4916
  }
@@ -4791,7 +4938,7 @@ export class BriijClient extends TypedEventEmitter {
4791
4938
  if (token != null && queryMutualRoomsSupport) {
4792
4939
  tokenQuery["batch_token"] = token;
4793
4940
  }
4794
- var res = yield _this47.http.authedRequest(Method.Get, path, _objectSpread(_objectSpread({}, query), tokenQuery), undefined, {
4941
+ var res = yield _this50.http.authedRequest(Method.Get, path, _objectSpread(_objectSpread({}, query), tokenQuery), undefined, {
4795
4942
  prefix: ClientPrefix.Unstable
4796
4943
  });
4797
4944
  rooms.push(...res.joined);
@@ -4812,10 +4959,10 @@ export class BriijClient extends TypedEventEmitter {
4812
4959
  */
4813
4960
  // eslint-disable-next-line @typescript-eslint/naming-convention
4814
4961
  _unstable_getRTCTransports() {
4815
- var _this48 = this;
4962
+ var _this51 = this;
4816
4963
  return _asyncToGenerator(function* () {
4817
4964
  // There is no /versions endpoint to check for support, so we just have to attempt a request.
4818
- return (yield _this48.http.authedRequest(Method.Get, "/rtc/transports", undefined, undefined, {
4965
+ return (yield _this51.http.authedRequest(Method.Get, "/rtc/transports", undefined, undefined, {
4819
4966
  prefix: "".concat(ClientPrefix.Unstable, "/org.matrix.msc4143")
4820
4967
  })).rtc_transports;
4821
4968
  })();
@@ -4827,24 +4974,24 @@ export class BriijClient extends TypedEventEmitter {
4827
4974
  * @returns The server /versions response
4828
4975
  */
4829
4976
  getVersions() {
4830
- var _this49 = this;
4977
+ var _this52 = this;
4831
4978
  return _asyncToGenerator(function* () {
4832
- if (_this49.serverVersionsPromise) {
4833
- return _this49.serverVersionsPromise;
4979
+ if (_this52.serverVersionsPromise) {
4980
+ return _this52.serverVersionsPromise;
4834
4981
  }
4835
4982
 
4836
4983
  // We send an authenticated request as of MSC4026
4837
- _this49.serverVersionsPromise = _this49.http.authedRequest(Method.Get, "/_matrix/client/versions", undefined, undefined, {
4984
+ _this52.serverVersionsPromise = _this52.http.authedRequest(Method.Get, "/_matrix/client/versions", undefined, undefined, {
4838
4985
  prefix: ""
4839
4986
  }).catch(e => {
4840
4987
  // Need to unset this if it fails, otherwise we'll never retry
4841
- _this49.serverVersionsPromise = undefined;
4988
+ _this52.serverVersionsPromise = undefined;
4842
4989
  // but rethrow the exception to anything that was waiting
4843
4990
  throw e;
4844
4991
  });
4845
- var serverVersions = yield _this49.serverVersionsPromise;
4846
- _this49.canSupport = yield buildFeatureSupportMap(serverVersions);
4847
- return _this49.serverVersionsPromise;
4992
+ var serverVersions = yield _this52.serverVersionsPromise;
4993
+ _this52.canSupport = yield buildFeatureSupportMap(serverVersions);
4994
+ return _this52.serverVersionsPromise;
4848
4995
  })();
4849
4996
  }
4850
4997
 
@@ -4854,11 +5001,11 @@ export class BriijClient extends TypedEventEmitter {
4854
5001
  * @returns Whether it is supported
4855
5002
  */
4856
5003
  isVersionSupported(version) {
4857
- var _this50 = this;
5004
+ var _this53 = this;
4858
5005
  return _asyncToGenerator(function* () {
4859
5006
  var {
4860
5007
  versions
4861
- } = yield _this50.getVersions();
5008
+ } = yield _this53.getVersions();
4862
5009
  return versions && versions.includes(version);
4863
5010
  })();
4864
5011
  }
@@ -4870,9 +5017,9 @@ export class BriijClient extends TypedEventEmitter {
4870
5017
  * @returns true if the feature is supported
4871
5018
  */
4872
5019
  doesServerSupportUnstableFeature(feature) {
4873
- var _this51 = this;
5020
+ var _this54 = this;
4874
5021
  return _asyncToGenerator(function* () {
4875
- var response = yield _this51.getVersions();
5022
+ var response = yield _this54.getVersions();
4876
5023
  if (!response) return false;
4877
5024
  var unstableFeatures = response["unstable_features"];
4878
5025
  return unstableFeatures && !!unstableFeatures[feature];
@@ -4887,9 +5034,9 @@ export class BriijClient extends TypedEventEmitter {
4887
5034
  * for the preset.
4888
5035
  */
4889
5036
  doesServerForceEncryptionForPreset(presetName) {
4890
- var _this52 = this;
5037
+ var _this55 = this;
4891
5038
  return _asyncToGenerator(function* () {
4892
- var response = yield _this52.getVersions();
5039
+ var response = yield _this55.getVersions();
4893
5040
  if (!response) return false;
4894
5041
  var unstableFeatures = response["unstable_features"];
4895
5042
 
@@ -4899,9 +5046,9 @@ export class BriijClient extends TypedEventEmitter {
4899
5046
  })();
4900
5047
  }
4901
5048
  doesServerSupportThread() {
4902
- var _this53 = this;
5049
+ var _this56 = this;
4903
5050
  return _asyncToGenerator(function* () {
4904
- if (yield _this53.isVersionSupported("v1.4")) {
5051
+ if (yield _this56.isVersionSupported("v1.4")) {
4905
5052
  return {
4906
5053
  threads: FeatureSupport.Stable,
4907
5054
  list: FeatureSupport.Stable,
@@ -4909,7 +5056,7 @@ export class BriijClient extends TypedEventEmitter {
4909
5056
  };
4910
5057
  }
4911
5058
  try {
4912
- var [threadUnstable, threadStable, listUnstable, listStable, fwdPaginationUnstable, fwdPaginationStable] = yield Promise.all([_this53.doesServerSupportUnstableFeature("org.matrix.msc3440"), _this53.doesServerSupportUnstableFeature("org.matrix.msc3440.stable"), _this53.doesServerSupportUnstableFeature("org.matrix.msc3856"), _this53.doesServerSupportUnstableFeature("org.matrix.msc3856.stable"), _this53.doesServerSupportUnstableFeature("org.matrix.msc3715"), _this53.doesServerSupportUnstableFeature("org.matrix.msc3715.stable")]);
5059
+ var [threadUnstable, threadStable, listUnstable, listStable, fwdPaginationUnstable, fwdPaginationStable] = yield Promise.all([_this56.doesServerSupportUnstableFeature("org.matrix.msc3440"), _this56.doesServerSupportUnstableFeature("org.matrix.msc3440.stable"), _this56.doesServerSupportUnstableFeature("org.matrix.msc3856"), _this56.doesServerSupportUnstableFeature("org.matrix.msc3856.stable"), _this56.doesServerSupportUnstableFeature("org.matrix.msc3715"), _this56.doesServerSupportUnstableFeature("org.matrix.msc3715.stable")]);
4913
5060
  return {
4914
5061
  threads: determineFeatureSupport(threadStable, threadUnstable),
4915
5062
  list: determineFeatureSupport(listStable, listUnstable),
@@ -4968,20 +5115,20 @@ export class BriijClient extends TypedEventEmitter {
4968
5115
  */
4969
5116
  relations(roomId, eventId, relationType, eventType) {
4970
5117
  var _arguments12 = arguments,
4971
- _this54 = this;
5118
+ _this57 = this;
4972
5119
  return _asyncToGenerator(function* () {
4973
5120
  var _result$next_batch, _result$prev_batch;
4974
5121
  var opts = _arguments12.length > 4 && _arguments12[4] !== undefined ? _arguments12[4] : {
4975
5122
  dir: Direction.Backward
4976
5123
  };
4977
- var fetchedEventType = eventType ? _this54.getEncryptedIfNeededEventType(roomId, eventType) : null;
4978
- var [eventResult, result] = yield Promise.all([_this54.fetchRoomEvent(roomId, eventId), _this54.fetchRelations(roomId, eventId, relationType, fetchedEventType, opts)]);
4979
- var mapper = _this54.getEventMapper();
5124
+ var fetchedEventType = eventType ? _this57.getEncryptedIfNeededEventType(roomId, eventType) : null;
5125
+ var [eventResult, result] = yield Promise.all([_this57.fetchRoomEvent(roomId, eventId), _this57.fetchRelations(roomId, eventId, relationType, fetchedEventType, opts)]);
5126
+ var mapper = _this57.getEventMapper();
4980
5127
  var originalEvent = eventResult ? mapper(eventResult) : undefined;
4981
5128
  var events = result.chunk.map(mapper);
4982
5129
  if (fetchedEventType === EventType.RoomMessageEncrypted) {
4983
5130
  var allEvents = originalEvent ? events.concat(originalEvent) : events;
4984
- yield Promise.all(allEvents.map(e => _this54.decryptEventIfNeeded(e)));
5131
+ yield Promise.all(allEvents.map(e => _this57.decryptEventIfNeeded(e)));
4985
5132
  if (eventType !== null) {
4986
5133
  events = events.filter(e => e.getType() === eventType);
4987
5134
  }
@@ -5248,35 +5395,48 @@ export class BriijClient extends TypedEventEmitter {
5248
5395
  * results. See https://github.com/matrix-org/briij-js-sdk/issues/4502.
5249
5396
  */
5250
5397
  login(loginType, data) {
5251
- var _this55 = this;
5398
+ var _this58 = this;
5252
5399
  return _asyncToGenerator(function* () {
5253
- var response = yield _this55.loginRequest(_objectSpread(_objectSpread({}, data), {}, {
5400
+ var response = yield _this58.loginRequest(_objectSpread(_objectSpread({}, data), {}, {
5254
5401
  type: loginType
5255
5402
  }));
5256
- if (response.access_token && response.user_id) {
5257
- _this55.http.opts.accessToken = response.access_token;
5258
- _this55.credentials = {
5259
- userId: response.user_id
5260
- };
5261
- configureXrplTrust({
5262
- homeserverBaseUrl: _this55.baseUrl,
5263
- accessToken: response.access_token
5264
- });
5403
+ yield _this58.applyLoginResponse(response, loginType);
5404
+ return response;
5405
+ })();
5406
+ }
5407
+ applyLoginResponse(response, loginType) {
5408
+ var _this59 = this;
5409
+ return _asyncToGenerator(function* () {
5410
+ var _response$device_id, _this59$xrplTrustConf;
5411
+ if (!response.access_token || !response.user_id) {
5412
+ return;
5265
5413
  }
5414
+ _this59.http.opts.accessToken = response.access_token;
5415
+ _this59.credentials = {
5416
+ userId: response.user_id
5417
+ };
5418
+ _this59.deviceId = (_response$device_id = response.device_id) !== null && _response$device_id !== void 0 ? _response$device_id : _this59.deviceId;
5419
+ _this59.xrplTrustConfig = {
5420
+ homeserverBaseUrl: _this59.baseUrl,
5421
+ accessToken: response.access_token,
5422
+ trustPath: (_this59$xrplTrustConf = _this59.xrplTrustConfig) === null || _this59$xrplTrustConf === void 0 ? void 0 : _this59$xrplTrustConf.trustPath
5423
+ };
5266
5424
 
5267
5425
  // After Xaman-backed SSO login, mint once and persist identity metadata in account_data.
5268
- if (loginType === "m.login.token" && response.access_token && response.user_id) {
5269
- configureXrplIdentityMinting({
5270
- homeserverBaseUrl: _this55.baseUrl,
5271
- accessToken: response.access_token
5272
- });
5426
+ if (loginType === "m.login.token") {
5427
+ var _this59$xrplIdentityM;
5428
+ var fallbackMintingConfig = getConfiguredXrplIdentityMintingConfig();
5429
+ var xamanWallet = (_this59$xrplIdentityM = _this59.xrplIdentityMintingConfig.xamanWallet) !== null && _this59$xrplIdentityM !== void 0 ? _this59$xrplIdentityM : fallbackMintingConfig.xamanWallet;
5273
5430
  try {
5274
- yield mintSoulboundIdentityNFT(response.user_id);
5431
+ yield mintSoulboundIdentityNFT(response.user_id, _objectSpread(_objectSpread(_objectSpread({}, fallbackMintingConfig), _this59.xrplIdentityMintingConfig), {}, {
5432
+ homeserverBaseUrl: _this59.baseUrl,
5433
+ accessToken: response.access_token,
5434
+ xamanWallet
5435
+ }));
5275
5436
  } catch (error) {
5276
5437
  logger.warn("XRPL identity NFT minting skipped/failed", error);
5277
5438
  }
5278
5439
  }
5279
- return response;
5280
5440
  })();
5281
5441
  }
5282
5442
 
@@ -5296,27 +5456,123 @@ export class BriijClient extends TypedEventEmitter {
5296
5456
  }
5297
5457
 
5298
5458
  /**
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`.
5459
+ * Request an XRPL login challenge from the homeserver.
5460
+ *
5461
+ * The briij homeserver responds with HTTP 401 as the successful challenge
5462
+ * response, so this helper normalizes that into a resolved promise.
5463
+ */
5464
+ getXrplAuthChallenge(request) {
5465
+ var _this60 = this;
5466
+ return _asyncToGenerator(function* () {
5467
+ try {
5468
+ var response = yield _this60.loginRequest(_objectSpread(_objectSpread({}, request), {}, {
5469
+ type: XRPL_WALLET_LOGIN_TYPE
5470
+ }));
5471
+ if (typeof response.session === "string" && typeof response.challenge === "string") {
5472
+ return response;
5473
+ }
5474
+ } catch (error) {
5475
+ if (error instanceof BriijError && error.httpStatus === 401) {
5476
+ var _error$data, _error$data2;
5477
+ var session = (_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.session;
5478
+ var challenge = (_error$data2 = error.data) === null || _error$data2 === void 0 ? void 0 : _error$data2.challenge;
5479
+ if (typeof session === "string" && typeof challenge === "string") {
5480
+ return {
5481
+ session,
5482
+ challenge
5483
+ };
5484
+ }
5485
+ }
5486
+ throw error;
5487
+ }
5488
+ throw new Error("XRPL challenge response was not returned by homeserver");
5489
+ })();
5490
+ }
5491
+
5492
+ /**
5493
+ * Complete XRPL login using the previously issued challenge session.
5494
+ *
5304
5495
  * @returns Promise which resolves to a LoginResponse object.
5305
5496
  * @returns Rejects: with an error response.
5306
5497
  */
5498
+ completeXrplAuth(request) {
5499
+ return this.loginRequest(_objectSpread(_objectSpread({}, request), {}, {
5500
+ type: XRPL_WALLET_LOGIN_TYPE
5501
+ }));
5502
+ }
5503
+
5504
+ /**
5505
+ * Store a chain-agnostic wallet recovery envelope in account data.
5506
+ *
5507
+ * This uses a stable account-data type and does not affect core E2EE state.
5508
+ *
5509
+ * @param envelope - Wallet recovery envelope payload.
5510
+ */
5511
+ setWalletRecoveryEnvelope(envelope) {
5512
+ var _this61 = this;
5513
+ return _asyncToGenerator(function* () {
5514
+ return yield _this61.setAccountData(WALLET_E2EE_RECOVERY_ACCOUNT_DATA_TYPE, envelope);
5515
+ })();
5516
+ }
5517
+
5518
+ /**
5519
+ * Fetch wallet recovery envelope directly from the homeserver.
5520
+ *
5521
+ * @returns The stored envelope, or null if not found.
5522
+ */
5523
+ getWalletRecoveryEnvelopeFromServer() {
5524
+ return this.getAccountDataFromServer(WALLET_E2EE_RECOVERY_ACCOUNT_DATA_TYPE);
5525
+ }
5526
+
5527
+ /**
5528
+ * Fetch canonical wallet identity metadata from the homeserver.
5529
+ *
5530
+ * @returns Wallet identity metadata, or null if not found.
5531
+ */
5532
+ getWalletIdentityFromServer() {
5533
+ return this.getAccountDataFromServer(WALLET_IDENTITY_ACCOUNT_DATA_TYPE);
5534
+ }
5535
+
5536
+ /**
5537
+ * @deprecated Use `getXrplAuthChallenge` + `completeXrplAuth` for explicit
5538
+ * two-step XRPL login flow. This wrapper now expects `challenge` to include
5539
+ * the `session` and optional `public_key`.
5540
+ */
5307
5541
  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
- });
5542
+ var _arguments13 = arguments,
5543
+ _this62 = this;
5544
+ return _asyncToGenerator(function* () {
5545
+ var _parsedChallenge, _parsedChallenge2;
5546
+ var network = _arguments13.length > 4 && _arguments13[4] !== undefined ? _arguments13[4] : "xrpl";
5547
+ var parsedChallenge = null;
5548
+ if (typeof challenge === "string") {
5549
+ try {
5550
+ parsedChallenge = JSON.parse(challenge);
5551
+ } catch (_unused3) {
5552
+ throw new Error("XRPL challenge must be JSON with a session field");
5553
+ }
5554
+ } else {
5555
+ parsedChallenge = challenge;
5556
+ }
5557
+ var session = (_parsedChallenge = parsedChallenge) === null || _parsedChallenge === void 0 ? void 0 : _parsedChallenge.session;
5558
+ if (!session) {
5559
+ throw new Error("XRPL challenge payload is missing session; call getXrplAuthChallenge first");
5560
+ }
5561
+ var response = yield _this62.completeXrplAuth({
5562
+ user,
5563
+ identifier: {
5564
+ type: "m.id.user",
5565
+ user
5566
+ },
5567
+ session,
5568
+ address: walletAddress,
5569
+ signature,
5570
+ public_key: (_parsedChallenge2 = parsedChallenge) === null || _parsedChallenge2 === void 0 ? void 0 : _parsedChallenge2.public_key,
5571
+ network
5572
+ });
5573
+ yield _this62.applyLoginResponse(response, XRPL_WALLET_LOGIN_TYPE);
5574
+ return response;
5575
+ })();
5320
5576
  }
5321
5577
 
5322
5578
  /**
@@ -5379,9 +5635,9 @@ export class BriijClient extends TypedEventEmitter {
5379
5635
  * @param data - Credentials and other details for the login request.
5380
5636
  */
5381
5637
  loginRequest(data) {
5382
- var _this56 = this;
5638
+ var _this63 = this;
5383
5639
  return _asyncToGenerator(function* () {
5384
- return yield _this56.http.authedRequest(Method.Post, "/login", undefined, data);
5640
+ return yield _this63.http.authedRequest(Method.Post, "/login", undefined, data);
5385
5641
  })();
5386
5642
  }
5387
5643
 
@@ -5395,15 +5651,15 @@ export class BriijClient extends TypedEventEmitter {
5395
5651
  * @returns Promise which resolves: On success, the empty object `{}`
5396
5652
  */
5397
5653
  logout() {
5398
- var _arguments13 = arguments,
5399
- _this57 = this;
5654
+ var _arguments14 = arguments,
5655
+ _this64 = this;
5400
5656
  return _asyncToGenerator(function* () {
5401
- var stopClient = _arguments13.length > 0 && _arguments13[0] !== undefined ? _arguments13[0] : false;
5657
+ var stopClient = _arguments14.length > 0 && _arguments14[0] !== undefined ? _arguments14[0] : false;
5402
5658
  if (stopClient) {
5403
- _this57.stopClient();
5404
- _this57.http.abort();
5659
+ _this64.stopClient();
5660
+ _this64.http.abort();
5405
5661
  }
5406
- return _this57.http.authedRequest(Method.Post, "/logout");
5662
+ return _this64.http.authedRequest(Method.Post, "/logout");
5407
5663
  })();
5408
5664
  }
5409
5665
 
@@ -5441,12 +5697,12 @@ export class BriijClient extends TypedEventEmitter {
5441
5697
  * or UIA auth data.
5442
5698
  */
5443
5699
  requestLoginToken(auth) {
5444
- var _this58 = this;
5700
+ var _this65 = this;
5445
5701
  return _asyncToGenerator(function* () {
5446
5702
  var body = {
5447
5703
  auth
5448
5704
  };
5449
- return _this58.http.authedRequest(Method.Post, "/login/get_token", undefined,
5705
+ return _this65.http.authedRequest(Method.Post, "/login/get_token", undefined,
5450
5706
  // no query params
5451
5707
  body, {
5452
5708
  prefix: ClientPrefix.V1
@@ -5478,23 +5734,23 @@ export class BriijClient extends TypedEventEmitter {
5478
5734
  * @returns Rejects: with an error response.
5479
5735
  */
5480
5736
  createRoom(options) {
5481
- var _this59 = this;
5737
+ var _this66 = this;
5482
5738
  return _asyncToGenerator(function* () {
5483
- var _this59$identityServe;
5739
+ var _this66$identityServe;
5484
5740
  // eslint-disable-line camelcase
5485
5741
  // some valid options include: room_alias_name, visibility, invite
5486
5742
 
5487
5743
  // inject the id_access_token if inviting 3rd party addresses
5488
5744
  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();
5745
+ if (invitesNeedingToken.length > 0 && (_this66$identityServe = _this66.identityServer) !== null && _this66$identityServe !== void 0 && _this66$identityServe.getAccessToken) {
5746
+ var identityAccessToken = yield _this66.identityServer.getAccessToken();
5491
5747
  if (identityAccessToken) {
5492
5748
  for (var invite of invitesNeedingToken) {
5493
5749
  invite.id_access_token = identityAccessToken;
5494
5750
  }
5495
5751
  }
5496
5752
  }
5497
- return _this59.http.authedRequest(Method.Post, "/createRoom", undefined, options);
5753
+ return _this66.http.authedRequest(Method.Post, "/createRoom", undefined, options);
5498
5754
  })();
5499
5755
  }
5500
5756
 
@@ -5639,12 +5895,12 @@ export class BriijClient extends TypedEventEmitter {
5639
5895
  * @returns Rejects: with an error response.
5640
5896
  */
5641
5897
  sendStateEvent(roomId, eventType, content) {
5642
- var _arguments14 = arguments,
5643
- _this60 = this;
5898
+ var _arguments15 = arguments,
5899
+ _this67 = this;
5644
5900
  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);
5901
+ var stateKey = _arguments15.length > 3 && _arguments15[3] !== undefined ? _arguments15[3] : "";
5902
+ var opts = _arguments15.length > 4 && _arguments15[4] !== undefined ? _arguments15[4] : {};
5903
+ var room = _this67.getRoom(roomId);
5648
5904
  var event = new BriijEvent({
5649
5905
  room_id: roomId,
5650
5906
  type: eventType,
@@ -5652,7 +5908,7 @@ export class BriijClient extends TypedEventEmitter {
5652
5908
  // Cast safety: StateEvents[K] is a stronger bound than IContent, which has [key: string]: any
5653
5909
  content: content
5654
5910
  });
5655
- yield _this60.encryptStateEventIfNeeded(event, room !== null && room !== void 0 ? room : undefined);
5911
+ yield _this67.encryptStateEventIfNeeded(event, room !== null && room !== void 0 ? room : undefined);
5656
5912
  var pathParams = {
5657
5913
  $roomId: roomId,
5658
5914
  $eventType: event.getWireType(),
@@ -5662,36 +5918,36 @@ export class BriijClient extends TypedEventEmitter {
5662
5918
  if (stateKey !== undefined) {
5663
5919
  path = utils.encodeUri(path + "/$stateKey", pathParams);
5664
5920
  }
5665
- return _this60.http.authedRequest(Method.Put, path, undefined, event.getWireContent(), opts);
5921
+ return _this67.http.authedRequest(Method.Put, path, undefined, event.getWireContent(), opts);
5666
5922
  })();
5667
5923
  }
5668
5924
  encryptStateEventIfNeeded(event, room) {
5669
- var _this61 = this;
5925
+ var _this68 = this;
5670
5926
  return _asyncToGenerator(function* () {
5671
- if (!_this61.enableEncryptedStateEvents) {
5927
+ if (!_this68.enableEncryptedStateEvents) {
5672
5928
  return;
5673
5929
  }
5674
5930
 
5675
5931
  // If the room is unknown, we cannot encrypt for it
5676
5932
  if (!room) return;
5677
- if (!_this61.cryptoBackend && _this61.usingExternalCrypto) {
5933
+ if (!_this68.cryptoBackend && _this68.usingExternalCrypto) {
5678
5934
  // The client has opted to allow sending messages to encrypted
5679
5935
  // rooms even if the room is encrypted, and we haven't set up
5680
5936
  // crypto. This is useful for users of matrix-org/pantalaimon
5681
5937
  return;
5682
5938
  }
5683
- if (!_this61.cryptoBackend) {
5939
+ if (!_this68.cryptoBackend) {
5684
5940
  throw new Error("This room is configured to use encryption, but your client does not support encryption.");
5685
5941
  }
5686
5942
 
5687
5943
  // Check regular encryption conditions.
5688
- if (!(yield _this61.shouldEncryptEventForRoom(event, room))) {
5944
+ if (!(yield _this68.shouldEncryptEventForRoom(event, room))) {
5689
5945
  return;
5690
5946
  }
5691
5947
 
5692
5948
  // If the crypto impl thinks we shouldn't encrypt, then we shouldn't.
5693
5949
  // Safety: we checked the crypto impl exists above.
5694
- if (!(yield _this61.cryptoBackend.isStateEncryptionEnabledInRoom(room.roomId))) {
5950
+ if (!(yield _this68.cryptoBackend.isStateEncryptionEnabledInRoom(room.roomId))) {
5695
5951
  return;
5696
5952
  }
5697
5953
 
@@ -5699,7 +5955,7 @@ export class BriijClient extends TypedEventEmitter {
5699
5955
  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
5956
  return;
5701
5957
  }
5702
- yield _this61.cryptoBackend.encryptEvent(event, room);
5958
+ yield _this68.cryptoBackend.encryptEvent(event, room);
5703
5959
  })();
5704
5960
  }
5705
5961
 
@@ -5732,7 +5988,7 @@ export class BriijClient extends TypedEventEmitter {
5732
5988
  * @returns Promise which resolves: the empty object, `{}`.
5733
5989
  */
5734
5990
  setRoomReadMarkersHttpRequest(roomId, rmEventId, rrEventId, rpEventId) {
5735
- var _this62 = this;
5991
+ var _this69 = this;
5736
5992
  return _asyncToGenerator(function* () {
5737
5993
  var path = utils.encodeUri("/rooms/$roomId/read_markers", {
5738
5994
  $roomId: roomId
@@ -5741,10 +5997,10 @@ export class BriijClient extends TypedEventEmitter {
5741
5997
  [ReceiptType.FullyRead]: rmEventId,
5742
5998
  [ReceiptType.Read]: rrEventId
5743
5999
  };
5744
- if ((yield _this62.doesServerSupportUnstableFeature("org.matrix.msc2285.stable")) || (yield _this62.isVersionSupported("v1.4"))) {
6000
+ if ((yield _this69.doesServerSupportUnstableFeature("org.matrix.msc2285.stable")) || (yield _this69.isVersionSupported("v1.4"))) {
5745
6001
  content[ReceiptType.ReadPrivate] = rpEventId;
5746
6002
  }
5747
- return _this62.http.authedRequest(Method.Post, path, undefined, content);
6003
+ return _this69.http.authedRequest(Method.Post, path, undefined, content);
5748
6004
  })();
5749
6005
  }
5750
6006
 
@@ -5780,13 +6036,13 @@ export class BriijClient extends TypedEventEmitter {
5780
6036
  * @see BriijSafetyError
5781
6037
  */
5782
6038
  publicRooms() {
5783
- var _ref9 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6039
+ var _ref0 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5784
6040
  var {
5785
6041
  server,
5786
6042
  limit,
5787
6043
  since
5788
- } = _ref9,
5789
- options = _objectWithoutProperties(_ref9, _excluded);
6044
+ } = _ref0,
6045
+ options = _objectWithoutProperties(_ref0, _excluded);
5790
6046
  if (Object.keys(options).length === 0) {
5791
6047
  var queryParams = {
5792
6048
  server,
@@ -5904,11 +6160,11 @@ export class BriijClient extends TypedEventEmitter {
5904
6160
  * @param options.limit - the maximum number of results to return. The server will apply a limit if unspecified.
5905
6161
  * @returns Promise which resolves: an array of results.
5906
6162
  */
5907
- searchUserDirectory(_ref0) {
6163
+ searchUserDirectory(_ref1) {
5908
6164
  var {
5909
6165
  term,
5910
6166
  limit
5911
- } = _ref0;
6167
+ } = _ref1;
5912
6168
  var body = {
5913
6169
  search_term: term
5914
6170
  };
@@ -5978,9 +6234,9 @@ export class BriijClient extends TypedEventEmitter {
5978
6234
  * @returns `true` if supported, otherwise `false`
5979
6235
  */
5980
6236
  doesServerSupportExtendedProfiles() {
5981
- var _this63 = this;
6237
+ var _this70 = this;
5982
6238
  return _asyncToGenerator(function* () {
5983
- return (yield _this63.isVersionSupported("v1.16")) || (yield _this63.doesServerSupportUnstableFeature(UNSTABLE_MSC4133_EXTENDED_PROFILES)) || (yield _this63.doesServerSupportUnstableFeature(STABLE_MSC4133_EXTENDED_PROFILES));
6239
+ return (yield _this70.isVersionSupported("v1.16")) || (yield _this70.doesServerSupportUnstableFeature(UNSTABLE_MSC4133_EXTENDED_PROFILES)) || (yield _this70.doesServerSupportUnstableFeature(STABLE_MSC4133_EXTENDED_PROFILES));
5984
6240
  })();
5985
6241
  }
5986
6242
 
@@ -5990,9 +6246,9 @@ export class BriijClient extends TypedEventEmitter {
5990
6246
  * @returns The prefix for use with `authedRequest`
5991
6247
  */
5992
6248
  getExtendedProfileRequestPrefix() {
5993
- var _this64 = this;
6249
+ var _this71 = this;
5994
6250
  return _asyncToGenerator(function* () {
5995
- if ((yield _this64.isVersionSupported("v1.16")) || (yield _this64.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable"))) {
6251
+ if ((yield _this71.isVersionSupported("v1.16")) || (yield _this71.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable"))) {
5996
6252
  return ClientPrefix.V3;
5997
6253
  }
5998
6254
  return "/_matrix/client/unstable/uk.tcpip.msc4133";
@@ -6010,15 +6266,15 @@ export class BriijClient extends TypedEventEmitter {
6010
6266
  * @throws A M_NOT_FOUND error if the profile could not be found.
6011
6267
  */
6012
6268
  getExtendedProfile(userId) {
6013
- var _this65 = this;
6269
+ var _this72 = this;
6014
6270
  return _asyncToGenerator(function* () {
6015
- if (!(yield _this65.doesServerSupportExtendedProfiles())) {
6271
+ if (!(yield _this72.doesServerSupportExtendedProfiles())) {
6016
6272
  throw new Error("Server does not support extended profiles");
6017
6273
  }
6018
- return _this65.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId", {
6274
+ return _this72.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId", {
6019
6275
  $userId: userId
6020
6276
  }), undefined, undefined, {
6021
- prefix: yield _this65.getExtendedProfileRequestPrefix()
6277
+ prefix: yield _this72.getExtendedProfileRequestPrefix()
6022
6278
  });
6023
6279
  })();
6024
6280
  }
@@ -6035,16 +6291,16 @@ export class BriijClient extends TypedEventEmitter {
6035
6291
  * @throws A M_NOT_FOUND error if the key was not set OR the profile could not be found.
6036
6292
  */
6037
6293
  getExtendedProfileProperty(userId, key) {
6038
- var _this66 = this;
6294
+ var _this73 = this;
6039
6295
  return _asyncToGenerator(function* () {
6040
- if (!(yield _this66.doesServerSupportExtendedProfiles())) {
6296
+ if (!(yield _this73.doesServerSupportExtendedProfiles())) {
6041
6297
  throw new Error("Server does not support extended profiles");
6042
6298
  }
6043
- var profile = yield _this66.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId/$key", {
6299
+ var profile = yield _this73.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId/$key", {
6044
6300
  $userId: userId,
6045
6301
  $key: key
6046
6302
  }), undefined, undefined, {
6047
- prefix: yield _this66.getExtendedProfileRequestPrefix()
6303
+ prefix: yield _this73.getExtendedProfileRequestPrefix()
6048
6304
  });
6049
6305
  return profile[key];
6050
6306
  })();
@@ -6060,19 +6316,19 @@ export class BriijClient extends TypedEventEmitter {
6060
6316
  * @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
6061
6317
  */
6062
6318
  setExtendedProfileProperty(key, value) {
6063
- var _this67 = this;
6319
+ var _this74 = this;
6064
6320
  return _asyncToGenerator(function* () {
6065
- if (!(yield _this67.doesServerSupportExtendedProfiles())) {
6321
+ if (!(yield _this74.doesServerSupportExtendedProfiles())) {
6066
6322
  throw new Error("Server does not support extended profiles");
6067
6323
  }
6068
- var userId = _this67.getUserId();
6069
- yield _this67.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId/$key", {
6324
+ var userId = _this74.getUserId();
6325
+ yield _this74.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId/$key", {
6070
6326
  $userId: userId,
6071
6327
  $key: key
6072
6328
  }), undefined, {
6073
6329
  [key]: value
6074
6330
  }, {
6075
- prefix: yield _this67.getExtendedProfileRequestPrefix()
6331
+ prefix: yield _this74.getExtendedProfileRequestPrefix()
6076
6332
  });
6077
6333
  })();
6078
6334
  }
@@ -6086,17 +6342,17 @@ export class BriijClient extends TypedEventEmitter {
6086
6342
  * @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
6087
6343
  */
6088
6344
  deleteExtendedProfileProperty(key) {
6089
- var _this68 = this;
6345
+ var _this75 = this;
6090
6346
  return _asyncToGenerator(function* () {
6091
- if (!(yield _this68.doesServerSupportExtendedProfiles())) {
6347
+ if (!(yield _this75.doesServerSupportExtendedProfiles())) {
6092
6348
  throw new Error("Server does not support extended profiles");
6093
6349
  }
6094
- var userId = _this68.getUserId();
6095
- yield _this68.http.authedRequest(Method.Delete, utils.encodeUri("/profile/$userId/$key", {
6350
+ var userId = _this75.getUserId();
6351
+ yield _this75.http.authedRequest(Method.Delete, utils.encodeUri("/profile/$userId/$key", {
6096
6352
  $userId: userId,
6097
6353
  $key: key
6098
6354
  }), undefined, undefined, {
6099
- prefix: yield _this68.getExtendedProfileRequestPrefix()
6355
+ prefix: yield _this75.getExtendedProfileRequestPrefix()
6100
6356
  });
6101
6357
  })();
6102
6358
  }
@@ -6112,16 +6368,16 @@ export class BriijClient extends TypedEventEmitter {
6112
6368
  * @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
6113
6369
  */
6114
6370
  patchExtendedProfile(profile) {
6115
- var _this69 = this;
6371
+ var _this76 = this;
6116
6372
  return _asyncToGenerator(function* () {
6117
- if (!(yield _this69.doesServerSupportExtendedProfiles())) {
6373
+ if (!(yield _this76.doesServerSupportExtendedProfiles())) {
6118
6374
  throw new Error("Server does not support extended profiles");
6119
6375
  }
6120
- var userId = _this69.getUserId();
6121
- return _this69.http.authedRequest(Method.Patch, utils.encodeUri("/profile/$userId", {
6376
+ var userId = _this76.getUserId();
6377
+ return _this76.http.authedRequest(Method.Patch, utils.encodeUri("/profile/$userId", {
6122
6378
  $userId: userId
6123
6379
  }), {}, profile, {
6124
- prefix: yield _this69.getExtendedProfileRequestPrefix()
6380
+ prefix: yield _this76.getExtendedProfileRequestPrefix()
6125
6381
  });
6126
6382
  })();
6127
6383
  }
@@ -6136,16 +6392,16 @@ export class BriijClient extends TypedEventEmitter {
6136
6392
  * @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
6137
6393
  */
6138
6394
  setExtendedProfile(profile) {
6139
- var _this70 = this;
6395
+ var _this77 = this;
6140
6396
  return _asyncToGenerator(function* () {
6141
- if (!(yield _this70.doesServerSupportExtendedProfiles())) {
6397
+ if (!(yield _this77.doesServerSupportExtendedProfiles())) {
6142
6398
  throw new Error("Server does not support extended profiles");
6143
6399
  }
6144
- var userId = _this70.getUserId();
6145
- yield _this70.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId", {
6400
+ var userId = _this77.getUserId();
6401
+ yield _this77.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId", {
6146
6402
  $userId: userId
6147
6403
  }), {}, profile, {
6148
- prefix: yield _this70.getExtendedProfileRequestPrefix()
6404
+ prefix: yield _this77.getExtendedProfileRequestPrefix()
6149
6405
  });
6150
6406
  })();
6151
6407
  }
@@ -6168,10 +6424,10 @@ export class BriijClient extends TypedEventEmitter {
6168
6424
  * @returns Rejects: with an error response.
6169
6425
  */
6170
6426
  addThreePidOnly(data) {
6171
- var _this71 = this;
6427
+ var _this78 = this;
6172
6428
  return _asyncToGenerator(function* () {
6173
6429
  var path = "/account/3pid/add";
6174
- return _this71.http.authedRequest(Method.Post, path, undefined, data);
6430
+ return _this78.http.authedRequest(Method.Post, path, undefined, data);
6175
6431
  })();
6176
6432
  }
6177
6433
 
@@ -6187,10 +6443,10 @@ export class BriijClient extends TypedEventEmitter {
6187
6443
  * @returns Rejects: with an error response.
6188
6444
  */
6189
6445
  bindThreePid(data) {
6190
- var _this72 = this;
6446
+ var _this79 = this;
6191
6447
  return _asyncToGenerator(function* () {
6192
6448
  var path = "/account/3pid/bind";
6193
- return _this72.http.authedRequest(Method.Post, path, undefined, data);
6449
+ return _this79.http.authedRequest(Method.Post, path, undefined, data);
6194
6450
  })();
6195
6451
  }
6196
6452
 
@@ -6208,15 +6464,15 @@ export class BriijClient extends TypedEventEmitter {
6208
6464
  unbindThreePid(medium, address
6209
6465
  // eslint-disable-next-line camelcase
6210
6466
  ) {
6211
- var _this73 = this;
6467
+ var _this80 = this;
6212
6468
  return _asyncToGenerator(function* () {
6213
6469
  var path = "/account/3pid/unbind";
6214
6470
  var data = {
6215
6471
  medium,
6216
6472
  address,
6217
- id_server: _this73.getIdentityServerUrl(true)
6473
+ id_server: _this80.getIdentityServerUrl(true)
6218
6474
  };
6219
- return _this73.http.authedRequest(Method.Post, path, undefined, data);
6475
+ return _this80.http.authedRequest(Method.Post, path, undefined, data);
6220
6476
  })();
6221
6477
  }
6222
6478
 
@@ -6338,13 +6594,13 @@ export class BriijClient extends TypedEventEmitter {
6338
6594
  * @returns Rejects: with an error response.
6339
6595
  */
6340
6596
  getPushers() {
6341
- var _this74 = this;
6597
+ var _this81 = this;
6342
6598
  return _asyncToGenerator(function* () {
6343
- var response = yield _this74.http.authedRequest(Method.Get, "/pushers");
6599
+ var response = yield _this81.http.authedRequest(Method.Get, "/pushers");
6344
6600
 
6345
6601
  // Migration path for clients that connect to a homeserver that does not support
6346
6602
  // 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"))) {
6603
+ if (!(yield _this81.doesServerSupportUnstableFeature("org.matrix.msc3881"))) {
6348
6604
  response.pushers = response.pushers.map(pusher => {
6349
6605
  if (!pusher.hasOwnProperty(PUSHER_ENABLED.name)) {
6350
6606
  pusher[PUSHER_ENABLED.name] = true;
@@ -6483,11 +6739,11 @@ export class BriijClient extends TypedEventEmitter {
6483
6739
  * @returns Promise which resolves to the search response object.
6484
6740
  * @returns Rejects: with an error response.
6485
6741
  */
6486
- search(_ref1, abortSignal) {
6742
+ search(_ref10, abortSignal) {
6487
6743
  var {
6488
6744
  body,
6489
6745
  next_batch: nextBatch
6490
- } = _ref1;
6746
+ } = _ref10;
6491
6747
  var queryParams = {};
6492
6748
  if (nextBatch) {
6493
6749
  queryParams.next_batch = nextBatch;
@@ -6774,7 +7030,7 @@ export class BriijClient extends TypedEventEmitter {
6774
7030
  * found MXIDs. Results where no user could be found will not be listed.
6775
7031
  */
6776
7032
  identityHashedLookup(addressPairs, identityAccessToken) {
6777
- var _this75 = this;
7033
+ var _this82 = this;
6778
7034
  return _asyncToGenerator(function* () {
6779
7035
  var params = {
6780
7036
  // addresses: ["email@example.org", "10005550000"],
@@ -6783,7 +7039,7 @@ export class BriijClient extends TypedEventEmitter {
6783
7039
  };
6784
7040
 
6785
7041
  // Get hash information first before trying to do a lookup
6786
- var hashes = yield _this75.getIdentityHashDetails(identityAccessToken);
7042
+ var hashes = yield _this82.getIdentityHashDetails(identityAccessToken);
6787
7043
  if (!hashes || !hashes["lookup_pepper"] || !hashes["algorithms"]) {
6788
7044
  throw new Error("Unsupported identity server: bad response");
6789
7045
  }
@@ -6796,7 +7052,7 @@ export class BriijClient extends TypedEventEmitter {
6796
7052
  // When picking an algorithm, we pick the hashed over no hashes
6797
7053
  if (hashes["algorithms"].includes("sha256")) {
6798
7054
  params["addresses"] = yield Promise.all(addressPairs.map(/*#__PURE__*/function () {
6799
- var _ref10 = _asyncToGenerator(function* (p) {
7055
+ var _ref11 = _asyncToGenerator(function* (p) {
6800
7056
  var addr = p[0].toLowerCase(); // lowercase to get consistent hashes
6801
7057
  var med = p[1].toLowerCase();
6802
7058
  var hashBuffer = yield sha256("".concat(addr, " ").concat(med, " ").concat(params["pepper"]));
@@ -6808,7 +7064,7 @@ export class BriijClient extends TypedEventEmitter {
6808
7064
  return hashed;
6809
7065
  });
6810
7066
  return function (_x4) {
6811
- return _ref10.apply(this, arguments);
7067
+ return _ref11.apply(this, arguments);
6812
7068
  };
6813
7069
  }()));
6814
7070
  params["algorithm"] = "sha256";
@@ -6826,7 +7082,7 @@ export class BriijClient extends TypedEventEmitter {
6826
7082
  } else {
6827
7083
  throw new Error("Unsupported identity server: unknown hash algorithm");
6828
7084
  }
6829
- var response = yield _this75.http.idServerRequest(Method.Post, "/lookup", params, IdentityPrefix.V2, identityAccessToken);
7085
+ var response = yield _this82.http.idServerRequest(Method.Post, "/lookup", params, IdentityPrefix.V2, identityAccessToken);
6830
7086
  if (!(response !== null && response !== void 0 && response["mappings"])) return []; // no results
6831
7087
 
6832
7088
  var foundAddresses = [];
@@ -6860,12 +7116,12 @@ export class BriijClient extends TypedEventEmitter {
6860
7116
  * @returns Rejects: with an error response.
6861
7117
  */
6862
7118
  lookupThreePid(medium, address, identityAccessToken) {
6863
- var _this76 = this;
7119
+ var _this83 = this;
6864
7120
  return _asyncToGenerator(function* () {
6865
7121
  // Note: we're using the V2 API by calling this function, but our
6866
7122
  // function contract requires a V1 response. We therefore have to
6867
7123
  // convert it manually.
6868
- var response = yield _this76.identityHashedLookup([[address, medium]], identityAccessToken);
7124
+ var response = yield _this83.identityHashedLookup([[address, medium]], identityAccessToken);
6869
7125
  var result = response.find(p => p.address === address);
6870
7126
  if (!result) {
6871
7127
  return {};
@@ -6897,12 +7153,12 @@ export class BriijClient extends TypedEventEmitter {
6897
7153
  * @returns Rejects: with an error response.
6898
7154
  */
6899
7155
  bulkLookupThreePids(query, identityAccessToken) {
6900
- var _this77 = this;
7156
+ var _this84 = this;
6901
7157
  return _asyncToGenerator(function* () {
6902
7158
  // Note: we're using the V2 API by calling this function, but our
6903
7159
  // function contract requires a V1 response. We therefore have to
6904
7160
  // convert it manually.
6905
- var response = yield _this77.identityHashedLookup(
7161
+ var response = yield _this84.identityHashedLookup(
6906
7162
  // We have to reverse the query order to get [address, medium] pairs
6907
7163
  query.map(p => [p[1], p[0]]), identityAccessToken);
6908
7164
  var v1results = [];
@@ -6976,16 +7232,16 @@ export class BriijClient extends TypedEventEmitter {
6976
7232
  * @returns Promise which resolves once queued there is no error feedback when sending fails.
6977
7233
  */
6978
7234
  encryptAndSendToDevice(eventType, devices, payload) {
6979
- var _this78 = this;
7235
+ var _this85 = this;
6980
7236
  return _asyncToGenerator(function* () {
6981
- if (!_this78.cryptoBackend) {
7237
+ if (!_this85.cryptoBackend) {
6982
7238
  throw new Error("Cannot encrypt to device event, your client does not support encryption.");
6983
7239
  }
6984
- var batch = yield _this78.cryptoBackend.encryptToDeviceMessages(eventType, devices, payload);
7240
+ var batch = yield _this85.cryptoBackend.encryptToDeviceMessages(eventType, devices, payload);
6985
7241
 
6986
7242
  // TODO The batch mechanism removes all possibility to get error feedbacks..
6987
7243
  // We might want instead to do the API call directly and pass the errors back.
6988
- yield _this78.queueToDevice(batch);
7244
+ yield _this85.queueToDevice(batch);
6989
7245
  })();
6990
7246
  }
6991
7247
 
@@ -7142,16 +7398,16 @@ export class BriijClient extends TypedEventEmitter {
7142
7398
  * @returns Promise which resolves to the created space.
7143
7399
  */
7144
7400
  unstableCreateFileTree(name) {
7145
- var _this79 = this;
7401
+ var _this86 = this;
7146
7402
  return _asyncToGenerator(function* () {
7147
7403
  var {
7148
7404
  room_id: roomId
7149
- } = yield _this79.createRoom({
7405
+ } = yield _this86.createRoom({
7150
7406
  name: name,
7151
7407
  preset: Preset.PrivateChat,
7152
7408
  power_level_content_override: _objectSpread(_objectSpread({}, DEFAULT_TREE_POWER_LEVELS_TEMPLATE), {}, {
7153
7409
  users: {
7154
- [_this79.getUserId()]: 100
7410
+ [_this86.getUserId()]: 100
7155
7411
  }
7156
7412
  }),
7157
7413
  creation_content: {
@@ -7171,7 +7427,7 @@ export class BriijClient extends TypedEventEmitter {
7171
7427
  }
7172
7428
  }]
7173
7429
  });
7174
- return new MSC3089TreeSpace(_this79, roomId);
7430
+ return new MSC3089TreeSpace(_this86, roomId);
7175
7431
  })();
7176
7432
  }
7177
7433
 
@@ -7248,7 +7504,7 @@ export class BriijClient extends TypedEventEmitter {
7248
7504
  * @param via - The list of servers which know about the room if only an ID was provided.
7249
7505
  */
7250
7506
  getRoomSummary(roomIdOrAlias, via) {
7251
- var _this80 = this;
7507
+ var _this87 = this;
7252
7508
  return _asyncToGenerator(function* () {
7253
7509
  var paramOpts = {
7254
7510
  prefix: "/_matrix/client/unstable/im.nheko.summary"
@@ -7257,7 +7513,7 @@ export class BriijClient extends TypedEventEmitter {
7257
7513
  var path = utils.encodeUri("/summary/$roomid", {
7258
7514
  $roomid: roomIdOrAlias
7259
7515
  });
7260
- return yield _this80.http.authedRequest(Method.Get, path, {
7516
+ return yield _this87.http.authedRequest(Method.Get, path, {
7261
7517
  via
7262
7518
  }, undefined, paramOpts);
7263
7519
  } catch (e) {
@@ -7265,7 +7521,7 @@ export class BriijClient extends TypedEventEmitter {
7265
7521
  var _path = utils.encodeUri("/rooms/$roomid/summary", {
7266
7522
  $roomid: roomIdOrAlias
7267
7523
  });
7268
- return yield _this80.http.authedRequest(Method.Get, _path, {
7524
+ return yield _this87.http.authedRequest(Method.Get, _path, {
7269
7525
  via
7270
7526
  }, undefined, paramOpts);
7271
7527
  } else {
@@ -7317,9 +7573,9 @@ export class BriijClient extends TypedEventEmitter {
7317
7573
  * Fetches information about the user for the configured access token.
7318
7574
  */
7319
7575
  whoami() {
7320
- var _this81 = this;
7576
+ var _this88 = this;
7321
7577
  return _asyncToGenerator(function* () {
7322
- return _this81.http.authedRequest(Method.Get, "/account/whoami");
7578
+ return _this88.http.authedRequest(Method.Get, "/account/whoami");
7323
7579
  })();
7324
7580
  }
7325
7581
 
@@ -7330,7 +7586,7 @@ export class BriijClient extends TypedEventEmitter {
7330
7586
  * @returns Rejects: when the request fails (module:http-api.BriijError)
7331
7587
  */
7332
7588
  timestampToEvent(roomId, timestamp, dir) {
7333
- var _this82 = this;
7589
+ var _this89 = this;
7334
7590
  return _asyncToGenerator(function* () {
7335
7591
  var path = utils.encodeUri("/rooms/$roomId/timestamp_to_event", {
7336
7592
  $roomId: roomId
@@ -7340,7 +7596,7 @@ export class BriijClient extends TypedEventEmitter {
7340
7596
  dir: dir
7341
7597
  };
7342
7598
  try {
7343
- return yield _this82.http.authedRequest(Method.Get, path, queryParams, undefined, {
7599
+ return yield _this89.http.authedRequest(Method.Get, path, queryParams, undefined, {
7344
7600
  prefix: ClientPrefix.V1
7345
7601
  });
7346
7602
  } catch (err) {
@@ -7356,7 +7612,7 @@ export class BriijClient extends TypedEventEmitter {
7356
7612
  // both indicate that this endpoint+verb combination is
7357
7613
  // not supported.
7358
7614
  err.httpStatus === 404 || err.httpStatus === 405)) {
7359
- return yield _this82.http.authedRequest(Method.Get, path, queryParams, undefined, {
7615
+ return yield _this89.http.authedRequest(Method.Get, path, queryParams, undefined, {
7360
7616
  prefix: "/_matrix/client/unstable/org.matrix.msc3030"
7361
7617
  });
7362
7618
  }
@@ -7376,12 +7632,12 @@ export class BriijClient extends TypedEventEmitter {
7376
7632
  * @throws when delegated auth config is invalid or unreachable
7377
7633
  */
7378
7634
  getAuthMetadata() {
7379
- var _this83 = this;
7635
+ var _this90 = this;
7380
7636
  return _asyncToGenerator(function* () {
7381
7637
  var authMetadata;
7382
7638
  try {
7383
- var useStable = yield _this83.isVersionSupported("v1.15");
7384
- authMetadata = yield _this83.http.request(Method.Get, "/auth_metadata", undefined, undefined, {
7639
+ var useStable = yield _this90.isVersionSupported("v1.15");
7640
+ authMetadata = yield _this90.http.request(Method.Get, "/auth_metadata", undefined, undefined, {
7385
7641
  prefix: useStable ? ClientPrefix.V1 : ClientPrefix.Unstable + "/org.matrix.msc2965"
7386
7642
  });
7387
7643
  } catch (e) {
@@ -7389,7 +7645,7 @@ export class BriijClient extends TypedEventEmitter {
7389
7645
  // Fall back to older variant of MSC2965
7390
7646
  var {
7391
7647
  issuer
7392
- } = yield _this83.http.request(Method.Get, "/auth_issuer", undefined, undefined, {
7648
+ } = yield _this90.http.request(Method.Get, "/auth_issuer", undefined, undefined, {
7393
7649
  prefix: ClientPrefix.Unstable + "/org.matrix.msc2965"
7394
7650
  });
7395
7651
  return discoverAndValidateOIDCIssuerWellKnown(issuer);
@@ -7402,8 +7658,8 @@ export class BriijClient extends TypedEventEmitter {
7402
7658
  }
7403
7659
  _defineProperty(BriijClient, "RESTORE_BACKUP_ERROR_BAD_KEY", "RESTORE_BACKUP_ERROR_BAD_KEY");
7404
7660
  function getUnstableDelayQueryOpts(delayOpts) {
7405
- return Object.fromEntries(Object.entries(delayOpts).map(_ref11 => {
7406
- var [k, v] = _ref11;
7661
+ return Object.fromEntries(Object.entries(delayOpts).map(_ref12 => {
7662
+ var [k, v] = _ref12;
7407
7663
  return ["".concat(UNSTABLE_MSC4140_DELAYED_EVENTS, ".").concat(k), v];
7408
7664
  }));
7409
7665
  }