@textrp/briij-js-sdk 43.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.
- package/CHANGELOG.md +7 -4
- package/lib/@types/auth.d.ts +7 -5
- package/lib/@types/auth.d.ts.map +1 -1
- package/lib/@types/auth.js.map +1 -1
- package/lib/@types/event.d.ts +3 -32
- package/lib/@types/event.d.ts.map +1 -1
- package/lib/@types/event.js.map +1 -1
- package/lib/@types/synapse.d.ts +64 -0
- package/lib/@types/synapse.d.ts.map +1 -1
- package/lib/@types/synapse.js.map +1 -1
- package/lib/briij.d.ts +1 -0
- package/lib/briij.d.ts.map +1 -1
- package/lib/briij.js +1 -0
- package/lib/briij.js.map +1 -1
- package/lib/client.d.ts +64 -1
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +360 -195
- package/lib/client.js.map +1 -1
- package/lib/wallet-recovery.d.ts +1 -1
- package/lib/wallet-recovery.d.ts.map +1 -1
- package/lib/wallet-recovery.js +32 -8
- package/lib/wallet-recovery.js.map +1 -1
- package/lib/xrpl/identity.d.ts +2 -1
- package/lib/xrpl/identity.d.ts.map +1 -1
- package/lib/xrpl/identity.js +70 -47
- package/lib/xrpl/identity.js.map +1 -1
- package/lib/xrpl/trust.d.ts +4 -2
- package/lib/xrpl/trust.d.ts.map +1 -1
- package/lib/xrpl/trust.js +31 -19
- package/lib/xrpl/trust.js.map +1 -1
- package/lib/xrpl/verification.js +17 -6
- package/lib/xrpl/verification.js.map +1 -1
- package/package.json +127 -129
- package/src/@types/auth.ts +6 -7
- package/src/@types/event.ts +3 -32
- package/src/@types/synapse.ts +77 -0
- package/src/briij.ts +1 -0
- package/src/client.ts +241 -36
- package/src/wallet-recovery.ts +101 -26
- package/src/xrpl/identity.ts +66 -39
- package/src/xrpl/trust.ts +35 -18
- package/src/xrpl/verification.ts +19 -6
package/lib/client.js
CHANGED
|
@@ -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 {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
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
|
-
} =
|
|
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
|
|
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 (
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
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
|
|
4732
|
+
var adminSubPath = utils.encodeUri("v1/whois/$userId", {
|
|
4682
4733
|
$userId: userId
|
|
4683
4734
|
});
|
|
4684
|
-
return this.
|
|
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
|
|
4745
|
+
var adminSubPath = utils.encodeUri("v1/deactivate/$userId", {
|
|
4697
4746
|
$userId: userId
|
|
4698
4747
|
});
|
|
4699
|
-
return this.
|
|
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
|
+
}, {
|
|
4700
4789
|
prefix: ""
|
|
4701
4790
|
});
|
|
4702
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, {
|
|
4805
|
+
prefix: ""
|
|
4806
|
+
});
|
|
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
|
|
4851
|
+
var _this49 = this;
|
|
4705
4852
|
return _asyncToGenerator(function* () {
|
|
4706
|
-
var
|
|
4853
|
+
var _this49$getDomain;
|
|
4707
4854
|
// `getRawClientConfig` does not throw or reject on network errors, instead
|
|
4708
4855
|
// it absorbs errors and returns `{}`.
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
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(
|
|
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
|
|
4904
|
+
var _this50 = this;
|
|
4758
4905
|
return _asyncToGenerator(function* () {
|
|
4759
4906
|
// Initial variant of the MSC
|
|
4760
|
-
var sharedRoomsSupport = yield
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
4977
|
+
var _this52 = this;
|
|
4831
4978
|
return _asyncToGenerator(function* () {
|
|
4832
|
-
if (
|
|
4833
|
-
return
|
|
4979
|
+
if (_this52.serverVersionsPromise) {
|
|
4980
|
+
return _this52.serverVersionsPromise;
|
|
4834
4981
|
}
|
|
4835
4982
|
|
|
4836
4983
|
// We send an authenticated request as of MSC4026
|
|
4837
|
-
|
|
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
|
-
|
|
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
|
|
4846
|
-
|
|
4847
|
-
return
|
|
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
|
|
5004
|
+
var _this53 = this;
|
|
4858
5005
|
return _asyncToGenerator(function* () {
|
|
4859
5006
|
var {
|
|
4860
5007
|
versions
|
|
4861
|
-
} = yield
|
|
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
|
|
5020
|
+
var _this54 = this;
|
|
4874
5021
|
return _asyncToGenerator(function* () {
|
|
4875
|
-
var response = yield
|
|
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
|
|
5037
|
+
var _this55 = this;
|
|
4891
5038
|
return _asyncToGenerator(function* () {
|
|
4892
|
-
var response = yield
|
|
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
|
|
5049
|
+
var _this56 = this;
|
|
4903
5050
|
return _asyncToGenerator(function* () {
|
|
4904
|
-
if (yield
|
|
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([
|
|
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
|
-
|
|
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 ?
|
|
4978
|
-
var [eventResult, result] = yield Promise.all([
|
|
4979
|
-
var mapper =
|
|
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 =>
|
|
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
|
|
5398
|
+
var _this58 = this;
|
|
5252
5399
|
return _asyncToGenerator(function* () {
|
|
5253
|
-
var response = yield
|
|
5400
|
+
var response = yield _this58.loginRequest(_objectSpread(_objectSpread({}, data), {}, {
|
|
5254
5401
|
type: loginType
|
|
5255
5402
|
}));
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
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"
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
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
|
|
|
@@ -5302,10 +5462,10 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
5302
5462
|
* response, so this helper normalizes that into a resolved promise.
|
|
5303
5463
|
*/
|
|
5304
5464
|
getXrplAuthChallenge(request) {
|
|
5305
|
-
var
|
|
5465
|
+
var _this60 = this;
|
|
5306
5466
|
return _asyncToGenerator(function* () {
|
|
5307
5467
|
try {
|
|
5308
|
-
var response = yield
|
|
5468
|
+
var response = yield _this60.loginRequest(_objectSpread(_objectSpread({}, request), {}, {
|
|
5309
5469
|
type: XRPL_WALLET_LOGIN_TYPE
|
|
5310
5470
|
}));
|
|
5311
5471
|
if (typeof response.session === "string" && typeof response.challenge === "string") {
|
|
@@ -5349,7 +5509,10 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
5349
5509
|
* @param envelope - Wallet recovery envelope payload.
|
|
5350
5510
|
*/
|
|
5351
5511
|
setWalletRecoveryEnvelope(envelope) {
|
|
5352
|
-
|
|
5512
|
+
var _this61 = this;
|
|
5513
|
+
return _asyncToGenerator(function* () {
|
|
5514
|
+
return yield _this61.setAccountData(WALLET_E2EE_RECOVERY_ACCOUNT_DATA_TYPE, envelope);
|
|
5515
|
+
})();
|
|
5353
5516
|
}
|
|
5354
5517
|
|
|
5355
5518
|
/**
|
|
@@ -5377,7 +5540,7 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
5377
5540
|
*/
|
|
5378
5541
|
loginWithXrplWallet(user, walletAddress, signature, challenge) {
|
|
5379
5542
|
var _arguments13 = arguments,
|
|
5380
|
-
|
|
5543
|
+
_this62 = this;
|
|
5381
5544
|
return _asyncToGenerator(function* () {
|
|
5382
5545
|
var _parsedChallenge, _parsedChallenge2;
|
|
5383
5546
|
var network = _arguments13.length > 4 && _arguments13[4] !== undefined ? _arguments13[4] : "xrpl";
|
|
@@ -5395,7 +5558,7 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
5395
5558
|
if (!session) {
|
|
5396
5559
|
throw new Error("XRPL challenge payload is missing session; call getXrplAuthChallenge first");
|
|
5397
5560
|
}
|
|
5398
|
-
|
|
5561
|
+
var response = yield _this62.completeXrplAuth({
|
|
5399
5562
|
user,
|
|
5400
5563
|
identifier: {
|
|
5401
5564
|
type: "m.id.user",
|
|
@@ -5407,6 +5570,8 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
5407
5570
|
public_key: (_parsedChallenge2 = parsedChallenge) === null || _parsedChallenge2 === void 0 ? void 0 : _parsedChallenge2.public_key,
|
|
5408
5571
|
network
|
|
5409
5572
|
});
|
|
5573
|
+
yield _this62.applyLoginResponse(response, XRPL_WALLET_LOGIN_TYPE);
|
|
5574
|
+
return response;
|
|
5410
5575
|
})();
|
|
5411
5576
|
}
|
|
5412
5577
|
|
|
@@ -5470,9 +5635,9 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
5470
5635
|
* @param data - Credentials and other details for the login request.
|
|
5471
5636
|
*/
|
|
5472
5637
|
loginRequest(data) {
|
|
5473
|
-
var
|
|
5638
|
+
var _this63 = this;
|
|
5474
5639
|
return _asyncToGenerator(function* () {
|
|
5475
|
-
return yield
|
|
5640
|
+
return yield _this63.http.authedRequest(Method.Post, "/login", undefined, data);
|
|
5476
5641
|
})();
|
|
5477
5642
|
}
|
|
5478
5643
|
|
|
@@ -5487,14 +5652,14 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
5487
5652
|
*/
|
|
5488
5653
|
logout() {
|
|
5489
5654
|
var _arguments14 = arguments,
|
|
5490
|
-
|
|
5655
|
+
_this64 = this;
|
|
5491
5656
|
return _asyncToGenerator(function* () {
|
|
5492
5657
|
var stopClient = _arguments14.length > 0 && _arguments14[0] !== undefined ? _arguments14[0] : false;
|
|
5493
5658
|
if (stopClient) {
|
|
5494
|
-
|
|
5495
|
-
|
|
5659
|
+
_this64.stopClient();
|
|
5660
|
+
_this64.http.abort();
|
|
5496
5661
|
}
|
|
5497
|
-
return
|
|
5662
|
+
return _this64.http.authedRequest(Method.Post, "/logout");
|
|
5498
5663
|
})();
|
|
5499
5664
|
}
|
|
5500
5665
|
|
|
@@ -5532,12 +5697,12 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
5532
5697
|
* or UIA auth data.
|
|
5533
5698
|
*/
|
|
5534
5699
|
requestLoginToken(auth) {
|
|
5535
|
-
var
|
|
5700
|
+
var _this65 = this;
|
|
5536
5701
|
return _asyncToGenerator(function* () {
|
|
5537
5702
|
var body = {
|
|
5538
5703
|
auth
|
|
5539
5704
|
};
|
|
5540
|
-
return
|
|
5705
|
+
return _this65.http.authedRequest(Method.Post, "/login/get_token", undefined,
|
|
5541
5706
|
// no query params
|
|
5542
5707
|
body, {
|
|
5543
5708
|
prefix: ClientPrefix.V1
|
|
@@ -5569,23 +5734,23 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
5569
5734
|
* @returns Rejects: with an error response.
|
|
5570
5735
|
*/
|
|
5571
5736
|
createRoom(options) {
|
|
5572
|
-
var
|
|
5737
|
+
var _this66 = this;
|
|
5573
5738
|
return _asyncToGenerator(function* () {
|
|
5574
|
-
var
|
|
5739
|
+
var _this66$identityServe;
|
|
5575
5740
|
// eslint-disable-line camelcase
|
|
5576
5741
|
// some valid options include: room_alias_name, visibility, invite
|
|
5577
5742
|
|
|
5578
5743
|
// inject the id_access_token if inviting 3rd party addresses
|
|
5579
5744
|
var invitesNeedingToken = (options.invite_3pid || []).filter(i => !i.id_access_token);
|
|
5580
|
-
if (invitesNeedingToken.length > 0 && (
|
|
5581
|
-
var identityAccessToken = yield
|
|
5745
|
+
if (invitesNeedingToken.length > 0 && (_this66$identityServe = _this66.identityServer) !== null && _this66$identityServe !== void 0 && _this66$identityServe.getAccessToken) {
|
|
5746
|
+
var identityAccessToken = yield _this66.identityServer.getAccessToken();
|
|
5582
5747
|
if (identityAccessToken) {
|
|
5583
5748
|
for (var invite of invitesNeedingToken) {
|
|
5584
5749
|
invite.id_access_token = identityAccessToken;
|
|
5585
5750
|
}
|
|
5586
5751
|
}
|
|
5587
5752
|
}
|
|
5588
|
-
return
|
|
5753
|
+
return _this66.http.authedRequest(Method.Post, "/createRoom", undefined, options);
|
|
5589
5754
|
})();
|
|
5590
5755
|
}
|
|
5591
5756
|
|
|
@@ -5731,11 +5896,11 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
5731
5896
|
*/
|
|
5732
5897
|
sendStateEvent(roomId, eventType, content) {
|
|
5733
5898
|
var _arguments15 = arguments,
|
|
5734
|
-
|
|
5899
|
+
_this67 = this;
|
|
5735
5900
|
return _asyncToGenerator(function* () {
|
|
5736
5901
|
var stateKey = _arguments15.length > 3 && _arguments15[3] !== undefined ? _arguments15[3] : "";
|
|
5737
5902
|
var opts = _arguments15.length > 4 && _arguments15[4] !== undefined ? _arguments15[4] : {};
|
|
5738
|
-
var room =
|
|
5903
|
+
var room = _this67.getRoom(roomId);
|
|
5739
5904
|
var event = new BriijEvent({
|
|
5740
5905
|
room_id: roomId,
|
|
5741
5906
|
type: eventType,
|
|
@@ -5743,7 +5908,7 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
5743
5908
|
// Cast safety: StateEvents[K] is a stronger bound than IContent, which has [key: string]: any
|
|
5744
5909
|
content: content
|
|
5745
5910
|
});
|
|
5746
|
-
yield
|
|
5911
|
+
yield _this67.encryptStateEventIfNeeded(event, room !== null && room !== void 0 ? room : undefined);
|
|
5747
5912
|
var pathParams = {
|
|
5748
5913
|
$roomId: roomId,
|
|
5749
5914
|
$eventType: event.getWireType(),
|
|
@@ -5753,36 +5918,36 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
5753
5918
|
if (stateKey !== undefined) {
|
|
5754
5919
|
path = utils.encodeUri(path + "/$stateKey", pathParams);
|
|
5755
5920
|
}
|
|
5756
|
-
return
|
|
5921
|
+
return _this67.http.authedRequest(Method.Put, path, undefined, event.getWireContent(), opts);
|
|
5757
5922
|
})();
|
|
5758
5923
|
}
|
|
5759
5924
|
encryptStateEventIfNeeded(event, room) {
|
|
5760
|
-
var
|
|
5925
|
+
var _this68 = this;
|
|
5761
5926
|
return _asyncToGenerator(function* () {
|
|
5762
|
-
if (!
|
|
5927
|
+
if (!_this68.enableEncryptedStateEvents) {
|
|
5763
5928
|
return;
|
|
5764
5929
|
}
|
|
5765
5930
|
|
|
5766
5931
|
// If the room is unknown, we cannot encrypt for it
|
|
5767
5932
|
if (!room) return;
|
|
5768
|
-
if (!
|
|
5933
|
+
if (!_this68.cryptoBackend && _this68.usingExternalCrypto) {
|
|
5769
5934
|
// The client has opted to allow sending messages to encrypted
|
|
5770
5935
|
// rooms even if the room is encrypted, and we haven't set up
|
|
5771
5936
|
// crypto. This is useful for users of matrix-org/pantalaimon
|
|
5772
5937
|
return;
|
|
5773
5938
|
}
|
|
5774
|
-
if (!
|
|
5939
|
+
if (!_this68.cryptoBackend) {
|
|
5775
5940
|
throw new Error("This room is configured to use encryption, but your client does not support encryption.");
|
|
5776
5941
|
}
|
|
5777
5942
|
|
|
5778
5943
|
// Check regular encryption conditions.
|
|
5779
|
-
if (!(yield
|
|
5944
|
+
if (!(yield _this68.shouldEncryptEventForRoom(event, room))) {
|
|
5780
5945
|
return;
|
|
5781
5946
|
}
|
|
5782
5947
|
|
|
5783
5948
|
// If the crypto impl thinks we shouldn't encrypt, then we shouldn't.
|
|
5784
5949
|
// Safety: we checked the crypto impl exists above.
|
|
5785
|
-
if (!(yield
|
|
5950
|
+
if (!(yield _this68.cryptoBackend.isStateEncryptionEnabledInRoom(room.roomId))) {
|
|
5786
5951
|
return;
|
|
5787
5952
|
}
|
|
5788
5953
|
|
|
@@ -5790,7 +5955,7 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
5790
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())) {
|
|
5791
5956
|
return;
|
|
5792
5957
|
}
|
|
5793
|
-
yield
|
|
5958
|
+
yield _this68.cryptoBackend.encryptEvent(event, room);
|
|
5794
5959
|
})();
|
|
5795
5960
|
}
|
|
5796
5961
|
|
|
@@ -5823,7 +5988,7 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
5823
5988
|
* @returns Promise which resolves: the empty object, `{}`.
|
|
5824
5989
|
*/
|
|
5825
5990
|
setRoomReadMarkersHttpRequest(roomId, rmEventId, rrEventId, rpEventId) {
|
|
5826
|
-
var
|
|
5991
|
+
var _this69 = this;
|
|
5827
5992
|
return _asyncToGenerator(function* () {
|
|
5828
5993
|
var path = utils.encodeUri("/rooms/$roomId/read_markers", {
|
|
5829
5994
|
$roomId: roomId
|
|
@@ -5832,10 +5997,10 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
5832
5997
|
[ReceiptType.FullyRead]: rmEventId,
|
|
5833
5998
|
[ReceiptType.Read]: rrEventId
|
|
5834
5999
|
};
|
|
5835
|
-
if ((yield
|
|
6000
|
+
if ((yield _this69.doesServerSupportUnstableFeature("org.matrix.msc2285.stable")) || (yield _this69.isVersionSupported("v1.4"))) {
|
|
5836
6001
|
content[ReceiptType.ReadPrivate] = rpEventId;
|
|
5837
6002
|
}
|
|
5838
|
-
return
|
|
6003
|
+
return _this69.http.authedRequest(Method.Post, path, undefined, content);
|
|
5839
6004
|
})();
|
|
5840
6005
|
}
|
|
5841
6006
|
|
|
@@ -5871,13 +6036,13 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
5871
6036
|
* @see BriijSafetyError
|
|
5872
6037
|
*/
|
|
5873
6038
|
publicRooms() {
|
|
5874
|
-
var
|
|
6039
|
+
var _ref0 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
5875
6040
|
var {
|
|
5876
6041
|
server,
|
|
5877
6042
|
limit,
|
|
5878
6043
|
since
|
|
5879
|
-
} =
|
|
5880
|
-
options = _objectWithoutProperties(
|
|
6044
|
+
} = _ref0,
|
|
6045
|
+
options = _objectWithoutProperties(_ref0, _excluded);
|
|
5881
6046
|
if (Object.keys(options).length === 0) {
|
|
5882
6047
|
var queryParams = {
|
|
5883
6048
|
server,
|
|
@@ -5995,11 +6160,11 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
5995
6160
|
* @param options.limit - the maximum number of results to return. The server will apply a limit if unspecified.
|
|
5996
6161
|
* @returns Promise which resolves: an array of results.
|
|
5997
6162
|
*/
|
|
5998
|
-
searchUserDirectory(
|
|
6163
|
+
searchUserDirectory(_ref1) {
|
|
5999
6164
|
var {
|
|
6000
6165
|
term,
|
|
6001
6166
|
limit
|
|
6002
|
-
} =
|
|
6167
|
+
} = _ref1;
|
|
6003
6168
|
var body = {
|
|
6004
6169
|
search_term: term
|
|
6005
6170
|
};
|
|
@@ -6069,9 +6234,9 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6069
6234
|
* @returns `true` if supported, otherwise `false`
|
|
6070
6235
|
*/
|
|
6071
6236
|
doesServerSupportExtendedProfiles() {
|
|
6072
|
-
var
|
|
6237
|
+
var _this70 = this;
|
|
6073
6238
|
return _asyncToGenerator(function* () {
|
|
6074
|
-
return (yield
|
|
6239
|
+
return (yield _this70.isVersionSupported("v1.16")) || (yield _this70.doesServerSupportUnstableFeature(UNSTABLE_MSC4133_EXTENDED_PROFILES)) || (yield _this70.doesServerSupportUnstableFeature(STABLE_MSC4133_EXTENDED_PROFILES));
|
|
6075
6240
|
})();
|
|
6076
6241
|
}
|
|
6077
6242
|
|
|
@@ -6081,9 +6246,9 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6081
6246
|
* @returns The prefix for use with `authedRequest`
|
|
6082
6247
|
*/
|
|
6083
6248
|
getExtendedProfileRequestPrefix() {
|
|
6084
|
-
var
|
|
6249
|
+
var _this71 = this;
|
|
6085
6250
|
return _asyncToGenerator(function* () {
|
|
6086
|
-
if ((yield
|
|
6251
|
+
if ((yield _this71.isVersionSupported("v1.16")) || (yield _this71.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable"))) {
|
|
6087
6252
|
return ClientPrefix.V3;
|
|
6088
6253
|
}
|
|
6089
6254
|
return "/_matrix/client/unstable/uk.tcpip.msc4133";
|
|
@@ -6101,15 +6266,15 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6101
6266
|
* @throws A M_NOT_FOUND error if the profile could not be found.
|
|
6102
6267
|
*/
|
|
6103
6268
|
getExtendedProfile(userId) {
|
|
6104
|
-
var
|
|
6269
|
+
var _this72 = this;
|
|
6105
6270
|
return _asyncToGenerator(function* () {
|
|
6106
|
-
if (!(yield
|
|
6271
|
+
if (!(yield _this72.doesServerSupportExtendedProfiles())) {
|
|
6107
6272
|
throw new Error("Server does not support extended profiles");
|
|
6108
6273
|
}
|
|
6109
|
-
return
|
|
6274
|
+
return _this72.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId", {
|
|
6110
6275
|
$userId: userId
|
|
6111
6276
|
}), undefined, undefined, {
|
|
6112
|
-
prefix: yield
|
|
6277
|
+
prefix: yield _this72.getExtendedProfileRequestPrefix()
|
|
6113
6278
|
});
|
|
6114
6279
|
})();
|
|
6115
6280
|
}
|
|
@@ -6126,16 +6291,16 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6126
6291
|
* @throws A M_NOT_FOUND error if the key was not set OR the profile could not be found.
|
|
6127
6292
|
*/
|
|
6128
6293
|
getExtendedProfileProperty(userId, key) {
|
|
6129
|
-
var
|
|
6294
|
+
var _this73 = this;
|
|
6130
6295
|
return _asyncToGenerator(function* () {
|
|
6131
|
-
if (!(yield
|
|
6296
|
+
if (!(yield _this73.doesServerSupportExtendedProfiles())) {
|
|
6132
6297
|
throw new Error("Server does not support extended profiles");
|
|
6133
6298
|
}
|
|
6134
|
-
var profile = yield
|
|
6299
|
+
var profile = yield _this73.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId/$key", {
|
|
6135
6300
|
$userId: userId,
|
|
6136
6301
|
$key: key
|
|
6137
6302
|
}), undefined, undefined, {
|
|
6138
|
-
prefix: yield
|
|
6303
|
+
prefix: yield _this73.getExtendedProfileRequestPrefix()
|
|
6139
6304
|
});
|
|
6140
6305
|
return profile[key];
|
|
6141
6306
|
})();
|
|
@@ -6151,19 +6316,19 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6151
6316
|
* @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
|
|
6152
6317
|
*/
|
|
6153
6318
|
setExtendedProfileProperty(key, value) {
|
|
6154
|
-
var
|
|
6319
|
+
var _this74 = this;
|
|
6155
6320
|
return _asyncToGenerator(function* () {
|
|
6156
|
-
if (!(yield
|
|
6321
|
+
if (!(yield _this74.doesServerSupportExtendedProfiles())) {
|
|
6157
6322
|
throw new Error("Server does not support extended profiles");
|
|
6158
6323
|
}
|
|
6159
|
-
var userId =
|
|
6160
|
-
yield
|
|
6324
|
+
var userId = _this74.getUserId();
|
|
6325
|
+
yield _this74.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId/$key", {
|
|
6161
6326
|
$userId: userId,
|
|
6162
6327
|
$key: key
|
|
6163
6328
|
}), undefined, {
|
|
6164
6329
|
[key]: value
|
|
6165
6330
|
}, {
|
|
6166
|
-
prefix: yield
|
|
6331
|
+
prefix: yield _this74.getExtendedProfileRequestPrefix()
|
|
6167
6332
|
});
|
|
6168
6333
|
})();
|
|
6169
6334
|
}
|
|
@@ -6177,17 +6342,17 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6177
6342
|
* @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
|
|
6178
6343
|
*/
|
|
6179
6344
|
deleteExtendedProfileProperty(key) {
|
|
6180
|
-
var
|
|
6345
|
+
var _this75 = this;
|
|
6181
6346
|
return _asyncToGenerator(function* () {
|
|
6182
|
-
if (!(yield
|
|
6347
|
+
if (!(yield _this75.doesServerSupportExtendedProfiles())) {
|
|
6183
6348
|
throw new Error("Server does not support extended profiles");
|
|
6184
6349
|
}
|
|
6185
|
-
var userId =
|
|
6186
|
-
yield
|
|
6350
|
+
var userId = _this75.getUserId();
|
|
6351
|
+
yield _this75.http.authedRequest(Method.Delete, utils.encodeUri("/profile/$userId/$key", {
|
|
6187
6352
|
$userId: userId,
|
|
6188
6353
|
$key: key
|
|
6189
6354
|
}), undefined, undefined, {
|
|
6190
|
-
prefix: yield
|
|
6355
|
+
prefix: yield _this75.getExtendedProfileRequestPrefix()
|
|
6191
6356
|
});
|
|
6192
6357
|
})();
|
|
6193
6358
|
}
|
|
@@ -6203,16 +6368,16 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6203
6368
|
* @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
|
|
6204
6369
|
*/
|
|
6205
6370
|
patchExtendedProfile(profile) {
|
|
6206
|
-
var
|
|
6371
|
+
var _this76 = this;
|
|
6207
6372
|
return _asyncToGenerator(function* () {
|
|
6208
|
-
if (!(yield
|
|
6373
|
+
if (!(yield _this76.doesServerSupportExtendedProfiles())) {
|
|
6209
6374
|
throw new Error("Server does not support extended profiles");
|
|
6210
6375
|
}
|
|
6211
|
-
var userId =
|
|
6212
|
-
return
|
|
6376
|
+
var userId = _this76.getUserId();
|
|
6377
|
+
return _this76.http.authedRequest(Method.Patch, utils.encodeUri("/profile/$userId", {
|
|
6213
6378
|
$userId: userId
|
|
6214
6379
|
}), {}, profile, {
|
|
6215
|
-
prefix: yield
|
|
6380
|
+
prefix: yield _this76.getExtendedProfileRequestPrefix()
|
|
6216
6381
|
});
|
|
6217
6382
|
})();
|
|
6218
6383
|
}
|
|
@@ -6227,16 +6392,16 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6227
6392
|
* @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
|
|
6228
6393
|
*/
|
|
6229
6394
|
setExtendedProfile(profile) {
|
|
6230
|
-
var
|
|
6395
|
+
var _this77 = this;
|
|
6231
6396
|
return _asyncToGenerator(function* () {
|
|
6232
|
-
if (!(yield
|
|
6397
|
+
if (!(yield _this77.doesServerSupportExtendedProfiles())) {
|
|
6233
6398
|
throw new Error("Server does not support extended profiles");
|
|
6234
6399
|
}
|
|
6235
|
-
var userId =
|
|
6236
|
-
yield
|
|
6400
|
+
var userId = _this77.getUserId();
|
|
6401
|
+
yield _this77.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId", {
|
|
6237
6402
|
$userId: userId
|
|
6238
6403
|
}), {}, profile, {
|
|
6239
|
-
prefix: yield
|
|
6404
|
+
prefix: yield _this77.getExtendedProfileRequestPrefix()
|
|
6240
6405
|
});
|
|
6241
6406
|
})();
|
|
6242
6407
|
}
|
|
@@ -6259,10 +6424,10 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6259
6424
|
* @returns Rejects: with an error response.
|
|
6260
6425
|
*/
|
|
6261
6426
|
addThreePidOnly(data) {
|
|
6262
|
-
var
|
|
6427
|
+
var _this78 = this;
|
|
6263
6428
|
return _asyncToGenerator(function* () {
|
|
6264
6429
|
var path = "/account/3pid/add";
|
|
6265
|
-
return
|
|
6430
|
+
return _this78.http.authedRequest(Method.Post, path, undefined, data);
|
|
6266
6431
|
})();
|
|
6267
6432
|
}
|
|
6268
6433
|
|
|
@@ -6278,10 +6443,10 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6278
6443
|
* @returns Rejects: with an error response.
|
|
6279
6444
|
*/
|
|
6280
6445
|
bindThreePid(data) {
|
|
6281
|
-
var
|
|
6446
|
+
var _this79 = this;
|
|
6282
6447
|
return _asyncToGenerator(function* () {
|
|
6283
6448
|
var path = "/account/3pid/bind";
|
|
6284
|
-
return
|
|
6449
|
+
return _this79.http.authedRequest(Method.Post, path, undefined, data);
|
|
6285
6450
|
})();
|
|
6286
6451
|
}
|
|
6287
6452
|
|
|
@@ -6299,15 +6464,15 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6299
6464
|
unbindThreePid(medium, address
|
|
6300
6465
|
// eslint-disable-next-line camelcase
|
|
6301
6466
|
) {
|
|
6302
|
-
var
|
|
6467
|
+
var _this80 = this;
|
|
6303
6468
|
return _asyncToGenerator(function* () {
|
|
6304
6469
|
var path = "/account/3pid/unbind";
|
|
6305
6470
|
var data = {
|
|
6306
6471
|
medium,
|
|
6307
6472
|
address,
|
|
6308
|
-
id_server:
|
|
6473
|
+
id_server: _this80.getIdentityServerUrl(true)
|
|
6309
6474
|
};
|
|
6310
|
-
return
|
|
6475
|
+
return _this80.http.authedRequest(Method.Post, path, undefined, data);
|
|
6311
6476
|
})();
|
|
6312
6477
|
}
|
|
6313
6478
|
|
|
@@ -6429,13 +6594,13 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6429
6594
|
* @returns Rejects: with an error response.
|
|
6430
6595
|
*/
|
|
6431
6596
|
getPushers() {
|
|
6432
|
-
var
|
|
6597
|
+
var _this81 = this;
|
|
6433
6598
|
return _asyncToGenerator(function* () {
|
|
6434
|
-
var response = yield
|
|
6599
|
+
var response = yield _this81.http.authedRequest(Method.Get, "/pushers");
|
|
6435
6600
|
|
|
6436
6601
|
// Migration path for clients that connect to a homeserver that does not support
|
|
6437
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
|
|
6438
|
-
if (!(yield
|
|
6603
|
+
if (!(yield _this81.doesServerSupportUnstableFeature("org.matrix.msc3881"))) {
|
|
6439
6604
|
response.pushers = response.pushers.map(pusher => {
|
|
6440
6605
|
if (!pusher.hasOwnProperty(PUSHER_ENABLED.name)) {
|
|
6441
6606
|
pusher[PUSHER_ENABLED.name] = true;
|
|
@@ -6574,11 +6739,11 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6574
6739
|
* @returns Promise which resolves to the search response object.
|
|
6575
6740
|
* @returns Rejects: with an error response.
|
|
6576
6741
|
*/
|
|
6577
|
-
search(
|
|
6742
|
+
search(_ref10, abortSignal) {
|
|
6578
6743
|
var {
|
|
6579
6744
|
body,
|
|
6580
6745
|
next_batch: nextBatch
|
|
6581
|
-
} =
|
|
6746
|
+
} = _ref10;
|
|
6582
6747
|
var queryParams = {};
|
|
6583
6748
|
if (nextBatch) {
|
|
6584
6749
|
queryParams.next_batch = nextBatch;
|
|
@@ -6865,7 +7030,7 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6865
7030
|
* found MXIDs. Results where no user could be found will not be listed.
|
|
6866
7031
|
*/
|
|
6867
7032
|
identityHashedLookup(addressPairs, identityAccessToken) {
|
|
6868
|
-
var
|
|
7033
|
+
var _this82 = this;
|
|
6869
7034
|
return _asyncToGenerator(function* () {
|
|
6870
7035
|
var params = {
|
|
6871
7036
|
// addresses: ["email@example.org", "10005550000"],
|
|
@@ -6874,7 +7039,7 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6874
7039
|
};
|
|
6875
7040
|
|
|
6876
7041
|
// Get hash information first before trying to do a lookup
|
|
6877
|
-
var hashes = yield
|
|
7042
|
+
var hashes = yield _this82.getIdentityHashDetails(identityAccessToken);
|
|
6878
7043
|
if (!hashes || !hashes["lookup_pepper"] || !hashes["algorithms"]) {
|
|
6879
7044
|
throw new Error("Unsupported identity server: bad response");
|
|
6880
7045
|
}
|
|
@@ -6887,7 +7052,7 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6887
7052
|
// When picking an algorithm, we pick the hashed over no hashes
|
|
6888
7053
|
if (hashes["algorithms"].includes("sha256")) {
|
|
6889
7054
|
params["addresses"] = yield Promise.all(addressPairs.map(/*#__PURE__*/function () {
|
|
6890
|
-
var
|
|
7055
|
+
var _ref11 = _asyncToGenerator(function* (p) {
|
|
6891
7056
|
var addr = p[0].toLowerCase(); // lowercase to get consistent hashes
|
|
6892
7057
|
var med = p[1].toLowerCase();
|
|
6893
7058
|
var hashBuffer = yield sha256("".concat(addr, " ").concat(med, " ").concat(params["pepper"]));
|
|
@@ -6899,7 +7064,7 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6899
7064
|
return hashed;
|
|
6900
7065
|
});
|
|
6901
7066
|
return function (_x4) {
|
|
6902
|
-
return
|
|
7067
|
+
return _ref11.apply(this, arguments);
|
|
6903
7068
|
};
|
|
6904
7069
|
}()));
|
|
6905
7070
|
params["algorithm"] = "sha256";
|
|
@@ -6917,7 +7082,7 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6917
7082
|
} else {
|
|
6918
7083
|
throw new Error("Unsupported identity server: unknown hash algorithm");
|
|
6919
7084
|
}
|
|
6920
|
-
var response = yield
|
|
7085
|
+
var response = yield _this82.http.idServerRequest(Method.Post, "/lookup", params, IdentityPrefix.V2, identityAccessToken);
|
|
6921
7086
|
if (!(response !== null && response !== void 0 && response["mappings"])) return []; // no results
|
|
6922
7087
|
|
|
6923
7088
|
var foundAddresses = [];
|
|
@@ -6951,12 +7116,12 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6951
7116
|
* @returns Rejects: with an error response.
|
|
6952
7117
|
*/
|
|
6953
7118
|
lookupThreePid(medium, address, identityAccessToken) {
|
|
6954
|
-
var
|
|
7119
|
+
var _this83 = this;
|
|
6955
7120
|
return _asyncToGenerator(function* () {
|
|
6956
7121
|
// Note: we're using the V2 API by calling this function, but our
|
|
6957
7122
|
// function contract requires a V1 response. We therefore have to
|
|
6958
7123
|
// convert it manually.
|
|
6959
|
-
var response = yield
|
|
7124
|
+
var response = yield _this83.identityHashedLookup([[address, medium]], identityAccessToken);
|
|
6960
7125
|
var result = response.find(p => p.address === address);
|
|
6961
7126
|
if (!result) {
|
|
6962
7127
|
return {};
|
|
@@ -6988,12 +7153,12 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
6988
7153
|
* @returns Rejects: with an error response.
|
|
6989
7154
|
*/
|
|
6990
7155
|
bulkLookupThreePids(query, identityAccessToken) {
|
|
6991
|
-
var
|
|
7156
|
+
var _this84 = this;
|
|
6992
7157
|
return _asyncToGenerator(function* () {
|
|
6993
7158
|
// Note: we're using the V2 API by calling this function, but our
|
|
6994
7159
|
// function contract requires a V1 response. We therefore have to
|
|
6995
7160
|
// convert it manually.
|
|
6996
|
-
var response = yield
|
|
7161
|
+
var response = yield _this84.identityHashedLookup(
|
|
6997
7162
|
// We have to reverse the query order to get [address, medium] pairs
|
|
6998
7163
|
query.map(p => [p[1], p[0]]), identityAccessToken);
|
|
6999
7164
|
var v1results = [];
|
|
@@ -7067,16 +7232,16 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
7067
7232
|
* @returns Promise which resolves once queued there is no error feedback when sending fails.
|
|
7068
7233
|
*/
|
|
7069
7234
|
encryptAndSendToDevice(eventType, devices, payload) {
|
|
7070
|
-
var
|
|
7235
|
+
var _this85 = this;
|
|
7071
7236
|
return _asyncToGenerator(function* () {
|
|
7072
|
-
if (!
|
|
7237
|
+
if (!_this85.cryptoBackend) {
|
|
7073
7238
|
throw new Error("Cannot encrypt to device event, your client does not support encryption.");
|
|
7074
7239
|
}
|
|
7075
|
-
var batch = yield
|
|
7240
|
+
var batch = yield _this85.cryptoBackend.encryptToDeviceMessages(eventType, devices, payload);
|
|
7076
7241
|
|
|
7077
7242
|
// TODO The batch mechanism removes all possibility to get error feedbacks..
|
|
7078
7243
|
// We might want instead to do the API call directly and pass the errors back.
|
|
7079
|
-
yield
|
|
7244
|
+
yield _this85.queueToDevice(batch);
|
|
7080
7245
|
})();
|
|
7081
7246
|
}
|
|
7082
7247
|
|
|
@@ -7233,16 +7398,16 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
7233
7398
|
* @returns Promise which resolves to the created space.
|
|
7234
7399
|
*/
|
|
7235
7400
|
unstableCreateFileTree(name) {
|
|
7236
|
-
var
|
|
7401
|
+
var _this86 = this;
|
|
7237
7402
|
return _asyncToGenerator(function* () {
|
|
7238
7403
|
var {
|
|
7239
7404
|
room_id: roomId
|
|
7240
|
-
} = yield
|
|
7405
|
+
} = yield _this86.createRoom({
|
|
7241
7406
|
name: name,
|
|
7242
7407
|
preset: Preset.PrivateChat,
|
|
7243
7408
|
power_level_content_override: _objectSpread(_objectSpread({}, DEFAULT_TREE_POWER_LEVELS_TEMPLATE), {}, {
|
|
7244
7409
|
users: {
|
|
7245
|
-
[
|
|
7410
|
+
[_this86.getUserId()]: 100
|
|
7246
7411
|
}
|
|
7247
7412
|
}),
|
|
7248
7413
|
creation_content: {
|
|
@@ -7262,7 +7427,7 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
7262
7427
|
}
|
|
7263
7428
|
}]
|
|
7264
7429
|
});
|
|
7265
|
-
return new MSC3089TreeSpace(
|
|
7430
|
+
return new MSC3089TreeSpace(_this86, roomId);
|
|
7266
7431
|
})();
|
|
7267
7432
|
}
|
|
7268
7433
|
|
|
@@ -7339,7 +7504,7 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
7339
7504
|
* @param via - The list of servers which know about the room if only an ID was provided.
|
|
7340
7505
|
*/
|
|
7341
7506
|
getRoomSummary(roomIdOrAlias, via) {
|
|
7342
|
-
var
|
|
7507
|
+
var _this87 = this;
|
|
7343
7508
|
return _asyncToGenerator(function* () {
|
|
7344
7509
|
var paramOpts = {
|
|
7345
7510
|
prefix: "/_matrix/client/unstable/im.nheko.summary"
|
|
@@ -7348,7 +7513,7 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
7348
7513
|
var path = utils.encodeUri("/summary/$roomid", {
|
|
7349
7514
|
$roomid: roomIdOrAlias
|
|
7350
7515
|
});
|
|
7351
|
-
return yield
|
|
7516
|
+
return yield _this87.http.authedRequest(Method.Get, path, {
|
|
7352
7517
|
via
|
|
7353
7518
|
}, undefined, paramOpts);
|
|
7354
7519
|
} catch (e) {
|
|
@@ -7356,7 +7521,7 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
7356
7521
|
var _path = utils.encodeUri("/rooms/$roomid/summary", {
|
|
7357
7522
|
$roomid: roomIdOrAlias
|
|
7358
7523
|
});
|
|
7359
|
-
return yield
|
|
7524
|
+
return yield _this87.http.authedRequest(Method.Get, _path, {
|
|
7360
7525
|
via
|
|
7361
7526
|
}, undefined, paramOpts);
|
|
7362
7527
|
} else {
|
|
@@ -7408,9 +7573,9 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
7408
7573
|
* Fetches information about the user for the configured access token.
|
|
7409
7574
|
*/
|
|
7410
7575
|
whoami() {
|
|
7411
|
-
var
|
|
7576
|
+
var _this88 = this;
|
|
7412
7577
|
return _asyncToGenerator(function* () {
|
|
7413
|
-
return
|
|
7578
|
+
return _this88.http.authedRequest(Method.Get, "/account/whoami");
|
|
7414
7579
|
})();
|
|
7415
7580
|
}
|
|
7416
7581
|
|
|
@@ -7421,7 +7586,7 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
7421
7586
|
* @returns Rejects: when the request fails (module:http-api.BriijError)
|
|
7422
7587
|
*/
|
|
7423
7588
|
timestampToEvent(roomId, timestamp, dir) {
|
|
7424
|
-
var
|
|
7589
|
+
var _this89 = this;
|
|
7425
7590
|
return _asyncToGenerator(function* () {
|
|
7426
7591
|
var path = utils.encodeUri("/rooms/$roomId/timestamp_to_event", {
|
|
7427
7592
|
$roomId: roomId
|
|
@@ -7431,7 +7596,7 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
7431
7596
|
dir: dir
|
|
7432
7597
|
};
|
|
7433
7598
|
try {
|
|
7434
|
-
return yield
|
|
7599
|
+
return yield _this89.http.authedRequest(Method.Get, path, queryParams, undefined, {
|
|
7435
7600
|
prefix: ClientPrefix.V1
|
|
7436
7601
|
});
|
|
7437
7602
|
} catch (err) {
|
|
@@ -7447,7 +7612,7 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
7447
7612
|
// both indicate that this endpoint+verb combination is
|
|
7448
7613
|
// not supported.
|
|
7449
7614
|
err.httpStatus === 404 || err.httpStatus === 405)) {
|
|
7450
|
-
return yield
|
|
7615
|
+
return yield _this89.http.authedRequest(Method.Get, path, queryParams, undefined, {
|
|
7451
7616
|
prefix: "/_matrix/client/unstable/org.matrix.msc3030"
|
|
7452
7617
|
});
|
|
7453
7618
|
}
|
|
@@ -7467,12 +7632,12 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
7467
7632
|
* @throws when delegated auth config is invalid or unreachable
|
|
7468
7633
|
*/
|
|
7469
7634
|
getAuthMetadata() {
|
|
7470
|
-
var
|
|
7635
|
+
var _this90 = this;
|
|
7471
7636
|
return _asyncToGenerator(function* () {
|
|
7472
7637
|
var authMetadata;
|
|
7473
7638
|
try {
|
|
7474
|
-
var useStable = yield
|
|
7475
|
-
authMetadata = yield
|
|
7639
|
+
var useStable = yield _this90.isVersionSupported("v1.15");
|
|
7640
|
+
authMetadata = yield _this90.http.request(Method.Get, "/auth_metadata", undefined, undefined, {
|
|
7476
7641
|
prefix: useStable ? ClientPrefix.V1 : ClientPrefix.Unstable + "/org.matrix.msc2965"
|
|
7477
7642
|
});
|
|
7478
7643
|
} catch (e) {
|
|
@@ -7480,7 +7645,7 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
7480
7645
|
// Fall back to older variant of MSC2965
|
|
7481
7646
|
var {
|
|
7482
7647
|
issuer
|
|
7483
|
-
} = yield
|
|
7648
|
+
} = yield _this90.http.request(Method.Get, "/auth_issuer", undefined, undefined, {
|
|
7484
7649
|
prefix: ClientPrefix.Unstable + "/org.matrix.msc2965"
|
|
7485
7650
|
});
|
|
7486
7651
|
return discoverAndValidateOIDCIssuerWellKnown(issuer);
|
|
@@ -7493,8 +7658,8 @@ export class BriijClient extends TypedEventEmitter {
|
|
|
7493
7658
|
}
|
|
7494
7659
|
_defineProperty(BriijClient, "RESTORE_BACKUP_ERROR_BAD_KEY", "RESTORE_BACKUP_ERROR_BAD_KEY");
|
|
7495
7660
|
function getUnstableDelayQueryOpts(delayOpts) {
|
|
7496
|
-
return Object.fromEntries(Object.entries(delayOpts).map(
|
|
7497
|
-
var [k, v] =
|
|
7661
|
+
return Object.fromEntries(Object.entries(delayOpts).map(_ref12 => {
|
|
7662
|
+
var [k, v] = _ref12;
|
|
7498
7663
|
return ["".concat(UNSTABLE_MSC4140_DELAYED_EVENTS, ".").concat(k), v];
|
|
7499
7664
|
}));
|
|
7500
7665
|
}
|