matrix-js-sdk 42.4.0 → 43.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/lib/@types/PushRules.d.ts +3 -1
- package/lib/@types/PushRules.d.ts.map +1 -1
- package/lib/@types/PushRules.js +2 -0
- package/lib/@types/PushRules.js.map +1 -1
- package/lib/@types/event.d.ts +1 -0
- package/lib/@types/event.d.ts.map +1 -1
- package/lib/@types/event.js.map +1 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +1 -1
- package/lib/client.d.ts +88 -37
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +72 -47
- package/lib/client.js.map +1 -1
- package/lib/crypto-api/index.d.ts +3 -3
- package/lib/crypto-api/index.d.ts.map +1 -1
- package/lib/crypto-api/index.js.map +1 -1
- package/lib/embedded.d.ts +17 -1
- package/lib/embedded.d.ts.map +1 -1
- package/lib/embedded.js +46 -1
- package/lib/embedded.js.map +1 -1
- package/lib/errors.d.ts +1 -1
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +2 -2
- package/lib/errors.js.map +1 -1
- package/lib/http-api/fetch.d.ts +7 -1
- package/lib/http-api/fetch.d.ts.map +1 -1
- package/lib/http-api/fetch.js +14 -5
- package/lib/http-api/fetch.js.map +1 -1
- package/lib/http-api/interface.d.ts +34 -8
- package/lib/http-api/interface.d.ts.map +1 -1
- package/lib/http-api/interface.js +10 -3
- package/lib/http-api/interface.js.map +1 -1
- package/lib/http-api/refresh.d.ts +30 -11
- package/lib/http-api/refresh.d.ts.map +1 -1
- package/lib/http-api/refresh.js +72 -5
- package/lib/http-api/refresh.js.map +1 -1
- package/lib/matrix.d.ts +1 -1
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js.map +1 -1
- package/lib/matrixrtc/CallMembership.d.ts.map +1 -1
- package/lib/matrixrtc/CallMembership.js +20 -6
- package/lib/matrixrtc/CallMembership.js.map +1 -1
- package/lib/matrixrtc/IMembershipManager.d.ts +5 -0
- package/lib/matrixrtc/IMembershipManager.d.ts.map +1 -1
- package/lib/matrixrtc/IMembershipManager.js.map +1 -1
- package/lib/matrixrtc/MatrixRTCSession.d.ts +27 -1
- package/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -1
- package/lib/matrixrtc/MatrixRTCSession.js +58 -36
- package/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.js +1 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -1
- package/lib/matrixrtc/MembershipManager.d.ts +76 -0
- package/lib/matrixrtc/MembershipManager.d.ts.map +1 -1
- package/lib/matrixrtc/MembershipManager.js +264 -47
- package/lib/matrixrtc/MembershipManager.js.map +1 -1
- package/lib/matrixrtc/index.d.ts +1 -1
- package/lib/matrixrtc/index.d.ts.map +1 -1
- package/lib/matrixrtc/index.js +1 -1
- package/lib/matrixrtc/index.js.map +1 -1
- package/lib/matrixrtc/membershipData/common.d.ts +8 -0
- package/lib/matrixrtc/membershipData/common.d.ts.map +1 -1
- package/lib/matrixrtc/membershipData/common.js +10 -0
- package/lib/matrixrtc/membershipData/common.js.map +1 -1
- package/lib/matrixrtc/membershipData/index.d.ts +1 -1
- package/lib/matrixrtc/membershipData/index.d.ts.map +1 -1
- package/lib/matrixrtc/membershipData/index.js +1 -1
- package/lib/matrixrtc/membershipData/index.js.map +1 -1
- package/lib/matrixrtc/types.d.ts +104 -11
- package/lib/matrixrtc/types.d.ts.map +1 -1
- package/lib/matrixrtc/types.js +263 -19
- package/lib/matrixrtc/types.js.map +1 -1
- package/lib/matrixrtc/utils.d.ts +22 -1
- package/lib/matrixrtc/utils.d.ts.map +1 -1
- package/lib/matrixrtc/utils.js +38 -0
- package/lib/matrixrtc/utils.js.map +1 -1
- package/lib/models/room-sticky-events.d.ts +7 -0
- package/lib/models/room-sticky-events.d.ts.map +1 -1
- package/lib/models/room-sticky-events.js +27 -0
- package/lib/models/room-sticky-events.js.map +1 -1
- package/lib/models/thread.d.ts.map +1 -1
- package/lib/models/thread.js +8 -0
- package/lib/models/thread.js.map +1 -1
- package/lib/oauth/authorize.js +1 -1
- package/lib/oauth/authorize.js.map +1 -1
- package/lib/oauth/index.d.ts +3 -5
- package/lib/oauth/index.d.ts.map +1 -1
- package/lib/oauth/index.js +7 -7
- package/lib/oauth/index.js.map +1 -1
- package/lib/oauth/tokenRefresher.d.ts +10 -4
- package/lib/oauth/tokenRefresher.d.ts.map +1 -1
- package/lib/oauth/tokenRefresher.js +34 -24
- package/lib/oauth/tokenRefresher.js.map +1 -1
- package/lib/receipt-accumulator.d.ts +10 -11
- package/lib/receipt-accumulator.d.ts.map +1 -1
- package/lib/receipt-accumulator.js +26 -25
- package/lib/receipt-accumulator.js.map +1 -1
- package/lib/room-summary-api.d.ts +71 -0
- package/lib/room-summary-api.d.ts.map +1 -0
- package/lib/room-summary-api.js +82 -0
- package/lib/room-summary-api.js.map +1 -0
- package/lib/rust-crypto/backup.d.ts +7 -0
- package/lib/rust-crypto/backup.d.ts.map +1 -1
- package/lib/rust-crypto/backup.js +41 -25
- package/lib/rust-crypto/backup.js.map +1 -1
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +6 -1
- package/lib/sync.js.map +1 -1
- package/package.json +6 -6
- package/src/@types/PushRules.ts +2 -0
- package/src/@types/event.ts +1 -1
- package/src/@types/matrix-sdk-crypto-wasm.d.ts +15 -12
- package/src/client.ts +105 -62
- package/src/crypto-api/index.ts +3 -3
- package/src/embedded.ts +61 -2
- package/src/errors.ts +2 -1
- package/src/http-api/fetch.ts +14 -5
- package/src/http-api/interface.ts +36 -8
- package/src/http-api/refresh.ts +101 -17
- package/src/matrix.ts +1 -1
- package/src/matrixrtc/CallMembership.ts +22 -4
- package/src/matrixrtc/IMembershipManager.ts +6 -0
- package/src/matrixrtc/MatrixRTCSession.ts +72 -49
- package/src/matrixrtc/MatrixRTCSessionManager.ts +1 -1
- package/src/matrixrtc/MembershipManager.ts +284 -61
- package/src/matrixrtc/index.ts +7 -1
- package/src/matrixrtc/membershipData/common.ts +12 -0
- package/src/matrixrtc/membershipData/index.ts +1 -1
- package/src/matrixrtc/types.ts +351 -23
- package/src/matrixrtc/utils.ts +54 -1
- package/src/models/room-sticky-events.ts +26 -1
- package/src/models/thread.ts +9 -0
- package/src/oauth/authorize.ts +1 -1
- package/src/oauth/index.ts +7 -8
- package/src/oauth/tokenRefresher.ts +15 -5
- package/src/receipt-accumulator.ts +30 -26
- package/src/room-summary-api.ts +114 -0
- package/src/rust-crypto/backup.ts +46 -33
- package/src/sync.ts +9 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type MatrixError } from "./errors.ts";
|
|
2
2
|
import { type Logger } from "../logger.ts";
|
|
3
3
|
import { type QueryDict } from "../utils.ts";
|
|
4
|
+
import { type ValidatedAuthMetadata } from "../oauth/discover.ts";
|
|
4
5
|
export type Body = Record<string, any> | BodyInit;
|
|
5
6
|
/**
|
|
6
7
|
* Unencrypted access and (optional) refresh token
|
|
@@ -20,12 +21,24 @@ export type AccessTokens = {
|
|
|
20
21
|
expiry?: Date;
|
|
21
22
|
};
|
|
22
23
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
24
|
+
* A callback function called when tokens are refreshed such that stored tokens can be updated with
|
|
25
|
+
* the refreshed ones.
|
|
26
|
+
*/
|
|
27
|
+
export type TokenRefreshCallback = (newTokens: AccessTokens) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Configuration required for {@link IHttpOpts} to allow the SDK to manage the full lifecycle of tokens for an
|
|
30
|
+
* OAuth2-native session (as per MSC2965/MSC3861): discovering the delegated auth server's metadata, refreshing
|
|
31
|
+
* access/refresh tokens, and revoking them (e.g. on logout).
|
|
25
32
|
*
|
|
26
|
-
*
|
|
33
|
+
* The SDK constructs the underlying OAuth2 client itself, lazily, the first time it is actually needed (so that,
|
|
34
|
+
* for example, a client started with no network connection does not fail to ever set up token refresh).
|
|
27
35
|
*/
|
|
28
|
-
export
|
|
36
|
+
export interface OAuth2ClientConfig {
|
|
37
|
+
/** The OAuth2 client ID this application is registered with the delegated auth server under. */
|
|
38
|
+
clientId: string;
|
|
39
|
+
/** The device ID of the current session, used to scope refreshed/revoked tokens to this session. */
|
|
40
|
+
deviceId?: string;
|
|
41
|
+
}
|
|
29
42
|
/** Options object for `FetchHttpApi` and {@link MatrixHttpApi}. */
|
|
30
43
|
export interface IHttpOpts {
|
|
31
44
|
fetchFn?: typeof globalThis.fetch;
|
|
@@ -35,14 +48,27 @@ export interface IHttpOpts {
|
|
|
35
48
|
extraParams?: QueryDict;
|
|
36
49
|
accessToken?: string;
|
|
37
50
|
/**
|
|
38
|
-
* Used in conjunction with
|
|
51
|
+
* Used in conjunction with oauth2ClientConfig to attempt token refresh
|
|
39
52
|
*/
|
|
40
53
|
refreshToken?: string;
|
|
41
54
|
/**
|
|
42
|
-
*
|
|
43
|
-
|
|
55
|
+
* Callback called when tokens are refreshed. Must be supplied if refreshToken is supplied.
|
|
56
|
+
*/
|
|
57
|
+
onTokenRefresh?: TokenRefreshCallback;
|
|
58
|
+
/**
|
|
59
|
+
* Configuration needed to refresh (given refreshToken) and revoke (e.g. on logout) tokens for an
|
|
60
|
+
* OAuth2-native session. Optional; if omitted, tokens will not be refreshed or revoked by the SDK.
|
|
61
|
+
* authMetadataCallback must also be supplied to refresh tokens.
|
|
62
|
+
*/
|
|
63
|
+
oauth2ClientConfig?: OAuth2ClientConfig;
|
|
64
|
+
/**
|
|
65
|
+
* Discovers and validates the delegated auth server's metadata for the current homeserver.
|
|
66
|
+
* Must be supplied along with oauth2ClientConfig in order to refresh tokens.
|
|
67
|
+
*
|
|
68
|
+
* @returns validated authentication metadata
|
|
69
|
+
* @throws when delegated auth config is invalid or unreachable
|
|
44
70
|
*/
|
|
45
|
-
|
|
71
|
+
authMetadataCallback?: () => Promise<ValidatedAuthMetadata>;
|
|
46
72
|
/**
|
|
47
73
|
* Whether to use the HTTP Authorization header over the `access_token` query parameter
|
|
48
74
|
* @deprecated as of v1.11 in https://spec.matrix.org/v1.17/client-server-api/#using-access-tokens
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/http-api/interface.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/http-api/interface.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAElE,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,QAAQ,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACvB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,SAAS,EAAE,YAAY,KAAK,IAAI,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IAC/B,gGAAgG;IAChG,QAAQ,EAAE,MAAM,CAAC;IACjB,oGAAoG;IACpG,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,mEAAmE;AACnE,MAAM,WAAW,SAAS;IACtB,OAAO,CAAC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ED,oBAAY,YAAY;IACpB,gBAAgB,uBAAuB;IACvC,SAAS,eAAe;CAC3B;AAED,MAAM,MAAM,sBAAsB,GAAG;IACjC;;;;;;;;;;;OAWG;IACH,CAAC,YAAY,CAAC,gBAAgB,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,IAAI,CAAC;IAC5D;;;;;;;;;OASG;IACH,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3E,CAAC;AAEF,MAAM,WAAW,cAAc;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACvB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,eAAe,CAAC,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,CAAC;IACjD,eAAe,CAAC,EAAE,eAAe,CAAC;CACrC;AAED,MAAM,WAAW,MAAM;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACjC,eAAe,EAAE,eAAe,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IAC3B,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,QAAQ,GAAG,sBAAsB,CAAC"}
|
|
@@ -19,10 +19,17 @@ limitations under the License.
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* A callback function called when tokens are refreshed such that stored tokens can be updated with
|
|
23
|
+
* the refreshed ones.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Configuration required for {@link IHttpOpts} to allow the SDK to manage the full lifecycle of tokens for an
|
|
28
|
+
* OAuth2-native session (as per MSC2965/MSC3861): discovering the delegated auth server's metadata, refreshing
|
|
29
|
+
* access/refresh tokens, and revoking them (e.g. on logout).
|
|
24
30
|
*
|
|
25
|
-
*
|
|
31
|
+
* The SDK constructs the underlying OAuth2 client itself, lazily, the first time it is actually needed (so that,
|
|
32
|
+
* for example, a client started with no network connection does not fail to ever set up token refresh).
|
|
26
33
|
*/
|
|
27
34
|
|
|
28
35
|
/** Options object for `FetchHttpApi` and {@link MatrixHttpApi}. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.js","names":[],"sources":["../../src/http-api/interface.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type MatrixError } from \"./errors.ts\";\nimport { type Logger } from \"../logger.ts\";\nimport { type QueryDict } from \"../utils.ts\";\n\nexport type Body = Record<string, any> | BodyInit;\n\n/**\n * Unencrypted access and (optional) refresh token\n */\nexport type AccessTokens = {\n /**\n * The new access token to use for authenticated requests\n */\n accessToken: string;\n /**\n * The new refresh token to use for refreshing tokens, optional\n */\n refreshToken?: string;\n /**\n * Approximate date when the access token will expire, optional\n */\n expiry?: Date;\n};\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"interface.js","names":[],"sources":["../../src/http-api/interface.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type MatrixError } from \"./errors.ts\";\nimport { type Logger } from \"../logger.ts\";\nimport { type QueryDict } from \"../utils.ts\";\nimport { type ValidatedAuthMetadata } from \"../oauth/discover.ts\";\n\nexport type Body = Record<string, any> | BodyInit;\n\n/**\n * Unencrypted access and (optional) refresh token\n */\nexport type AccessTokens = {\n /**\n * The new access token to use for authenticated requests\n */\n accessToken: string;\n /**\n * The new refresh token to use for refreshing tokens, optional\n */\n refreshToken?: string;\n /**\n * Approximate date when the access token will expire, optional\n */\n expiry?: Date;\n};\n\n/**\n * A callback function called when tokens are refreshed such that stored tokens can be updated with\n * the refreshed ones.\n */\nexport type TokenRefreshCallback = (newTokens: AccessTokens) => void;\n\n/**\n * Configuration required for {@link IHttpOpts} to allow the SDK to manage the full lifecycle of tokens for an\n * OAuth2-native session (as per MSC2965/MSC3861): discovering the delegated auth server's metadata, refreshing\n * access/refresh tokens, and revoking them (e.g. on logout).\n *\n * The SDK constructs the underlying OAuth2 client itself, lazily, the first time it is actually needed (so that,\n * for example, a client started with no network connection does not fail to ever set up token refresh).\n */\nexport interface OAuth2ClientConfig {\n /** The OAuth2 client ID this application is registered with the delegated auth server under. */\n clientId: string;\n /** The device ID of the current session, used to scope refreshed/revoked tokens to this session. */\n deviceId?: string;\n}\n\n/** Options object for `FetchHttpApi` and {@link MatrixHttpApi}. */\nexport interface IHttpOpts {\n fetchFn?: typeof globalThis.fetch;\n\n baseUrl: string;\n idBaseUrl?: string;\n prefix: string;\n extraParams?: QueryDict;\n\n accessToken?: string;\n /**\n * Used in conjunction with oauth2ClientConfig to attempt token refresh\n */\n refreshToken?: string;\n /**\n * Callback called when tokens are refreshed. Must be supplied if refreshToken is supplied.\n */\n onTokenRefresh?: TokenRefreshCallback;\n /**\n * Configuration needed to refresh (given refreshToken) and revoke (e.g. on logout) tokens for an\n * OAuth2-native session. Optional; if omitted, tokens will not be refreshed or revoked by the SDK.\n * authMetadataCallback must also be supplied to refresh tokens.\n */\n oauth2ClientConfig?: OAuth2ClientConfig;\n\n /**\n * Discovers and validates the delegated auth server's metadata for the current homeserver.\n * Must be supplied along with oauth2ClientConfig in order to refresh tokens.\n *\n * @returns validated authentication metadata\n * @throws when delegated auth config is invalid or unreachable\n */\n authMetadataCallback?: () => Promise<ValidatedAuthMetadata>;\n\n /**\n * Whether to use the HTTP Authorization header over the `access_token` query parameter\n * @deprecated as of v1.11 in https://spec.matrix.org/v1.17/client-server-api/#using-access-tokens\n */\n useAuthorizationHeader?: boolean; // defaults to true\n\n /** For historical reasons, must be set to `true`. Will eventually be removed. */\n onlyData?: boolean;\n\n localTimeoutMs?: number;\n\n /** Optional logger instance. If provided, requests and responses will be logged. */\n logger?: Logger;\n}\n\n/** Options object for `FetchHttpApi.requestOtherUrl`. */\nexport interface BaseRequestOpts extends Pick<RequestInit, \"priority\"> {\n /**\n * map of additional request headers\n */\n headers?: Record<string, string>;\n abortSignal?: AbortSignal;\n /**\n * The maximum amount of time to wait before\n * timing out the request. If not specified, there is no timeout.\n */\n localTimeoutMs?: number;\n keepAlive?: boolean; // defaults to false\n\n /**\n * By default, we will:\n *\n * * If the `body` is an object, JSON-encode it and set `Content-Type: application/json` in the\n * request headers (unless overridden by {@link headers}).\n *\n * * Set `Accept: application/json` in the request headers (again, unless overridden by {@link headers}).\n *\n * * Parse the response as JSON and return the parsed response.\n *\n * Setting this to `false` inhibits all three behaviors, and the response is instead parsed as a UTF-8 string. It\n * defaults to `true`, unless {@link rawResponseBody} is set.\n *\n * @deprecated Instead of setting this to `false`, set {@link rawResponseBody} to `true`.\n */\n json?: boolean;\n\n /**\n * Setting this to `true` does two things:\n *\n * * Inhibits the automatic addition of `Accept: application/json` in the request headers.\n *\n * * Causes the raw response to be returned as a {@link https://developer.mozilla.org/en-US/docs/Web/API/Blob|Blob}\n * instead of parsing it as JSON.\n */\n rawResponseBody?: boolean;\n}\n\nexport interface IRequestOpts extends BaseRequestOpts {\n /**\n * The alternative base url to use.\n * If not specified, uses this.opts.baseUrl\n */\n baseUrl?: string;\n /**\n * The full prefix to use e.g.\n * \"/_matrix/client/v2_alpha\". If not specified, uses this.opts.prefix.\n */\n prefix?: string;\n\n // Set to true to prevent the request function from emitting a Session.logged_out event.\n // This is intended for use on endpoints where M_UNKNOWN_TOKEN is a valid/notable error response,\n // such as with token refreshes.\n inhibitLogoutEmit?: boolean;\n}\n\nexport enum HttpApiEvent {\n SessionLoggedOut = \"Session.logged_out\",\n NoConsent = \"no_consent\",\n}\n\nexport type HttpApiEventHandlerMap = {\n /**\n * Fires whenever the login session the JS SDK is using is no\n * longer valid and the user must log in again.\n * NB. This only fires when action is required from the user, not\n * when then login session can be renewed by using a refresh token.\n * @example\n * ```\n * matrixClient.on(\"Session.logged_out\", function(errorObj){\n * // show the login screen\n * });\n * ```\n */\n [HttpApiEvent.SessionLoggedOut]: (err: MatrixError) => void;\n /**\n * Fires when the JS SDK receives a M_CONSENT_NOT_GIVEN error in response\n * to a HTTP request.\n * @example\n * ```\n * matrixClient.on(\"no_consent\", function(message, contentUri) {\n * console.info(message + ' Go to ' + contentUri);\n * });\n * ```\n */\n [HttpApiEvent.NoConsent]: (message: string, consentUri: string) => void;\n};\n\nexport interface UploadProgress {\n loaded: number;\n total: number;\n}\n\nexport interface UploadOpts {\n /**\n * Name to give the file on the server. Defaults to <tt>file.name</tt>.\n */\n name?: string;\n /**\n * Content-type for the upload. Defaults to\n * <tt>file.type</tt>, or <tt>applicaton/octet-stream</tt>.\n */\n type?: string;\n /**\n * if false will not send the filename,\n * e.g for encrypted file uploads where filename leaks are undesirable.\n * Defaults to true.\n */\n includeFilename?: boolean;\n /**\n * Optional. Called when a chunk of\n * data has been uploaded, with an object containing the fields `loaded`\n * (number of bytes transferred) and `total` (total size, if known).\n */\n progressHandler?(progress: UploadProgress): void;\n abortController?: AbortController;\n}\n\nexport interface Upload {\n loaded: number;\n total: number;\n promise: Promise<UploadResponse>;\n abortController: AbortController;\n}\n\nexport interface UploadResponse {\n content_uri: string;\n}\n\nexport type FileType = XMLHttpRequestBodyInit;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;;AAgBA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;;AAiDA;;AA4DA,WAAY,YAAY,0BAAZ,YAAY;EAAZ,YAAY;EAAZ,YAAY;EAAA,OAAZ,YAAY;AAAA","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type IHttpOpts } from "./interface.ts";
|
|
1
|
+
import { type AccessTokens, type IHttpOpts } from "./interface.ts";
|
|
2
2
|
/**
|
|
3
3
|
* This is an internal module. See {@link MatrixHttpApi} for the public class.
|
|
4
4
|
*/
|
|
@@ -7,17 +7,15 @@ export declare const enum TokenRefreshOutcome {
|
|
|
7
7
|
Failure = "failure",
|
|
8
8
|
Logout = "logout"
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
accessToken: string;
|
|
12
|
-
refreshToken?: string;
|
|
13
|
-
expiry?: Date;
|
|
14
|
-
}
|
|
15
|
-
type Opts = Pick<IHttpOpts, "tokenRefreshFunction" | "logger" | "refreshToken" | "accessToken">;
|
|
10
|
+
type Opts = Pick<IHttpOpts, "onTokenRefresh" | "logger" | "refreshToken" | "accessToken" | "oauth2ClientConfig" | "authMetadataCallback">;
|
|
16
11
|
/**
|
|
17
12
|
* This class is responsible for managing the access token and refresh token for authenticated requests.
|
|
18
|
-
* It will automatically refresh the access token
|
|
13
|
+
* It will automatically refresh the tokens when the access token is about to expire and can handle
|
|
14
|
+
* Unknown Token errors (via {@link TokenManager.handleUnknownToken})
|
|
15
|
+
*
|
|
16
|
+
* It will update the {@link Opts} object with new tokens as they are refreshed, and also call the {@link IHttpOpts.onTokenRefresh} callback if provided.
|
|
19
17
|
*/
|
|
20
|
-
export declare class
|
|
18
|
+
export declare class TokenManager {
|
|
21
19
|
private readonly opts;
|
|
22
20
|
constructor(opts: Opts);
|
|
23
21
|
/**
|
|
@@ -26,12 +24,14 @@ export declare class TokenRefresher {
|
|
|
26
24
|
*/
|
|
27
25
|
private tokenRefreshPromise?;
|
|
28
26
|
private latestTokenRefreshExpiry?;
|
|
27
|
+
private tokenRefresher?;
|
|
28
|
+
private tokenRefresherPromise?;
|
|
29
29
|
/**
|
|
30
30
|
* This function is called before every request to ensure that the access token is valid.
|
|
31
31
|
* @returns a snapshot containing the access token and other properties which must be passed to the handleUnknownToken
|
|
32
32
|
* handler if an M_UNKNOWN_TOKEN error is encountered.
|
|
33
33
|
*/
|
|
34
|
-
prepareForRequest(): Promise<
|
|
34
|
+
prepareForRequest(): Promise<AccessTokens>;
|
|
35
35
|
private refreshIfNeeded;
|
|
36
36
|
/**
|
|
37
37
|
* This function is called when an M_UNKNOWN_TOKEN error is encountered.
|
|
@@ -40,7 +40,7 @@ export declare class TokenRefresher {
|
|
|
40
40
|
* @param attempt - the number of attempts made for this request so far
|
|
41
41
|
* @returns a TokenRefreshOutcome indicating the result of the refresh attempt
|
|
42
42
|
*/
|
|
43
|
-
handleUnknownToken(snapshot:
|
|
43
|
+
handleUnknownToken(snapshot: AccessTokens, attempt: number): Promise<TokenRefreshOutcome>;
|
|
44
44
|
private _handleUnknownToken;
|
|
45
45
|
/**
|
|
46
46
|
* Attempt to refresh access tokens.
|
|
@@ -48,6 +48,25 @@ export declare class TokenRefresher {
|
|
|
48
48
|
* @returns Promise that resolves to a boolean - true when token was refreshed successfully
|
|
49
49
|
*/
|
|
50
50
|
private doTokenRefresh;
|
|
51
|
+
/**
|
|
52
|
+
* Attempt to revoke the current access and refresh tokens with the OAuth2 authorization server, e.g. as
|
|
53
|
+
* part of logging out. Does nothing if this is not an OAuth2-native session (ie. no `oauth2ClientConfig`
|
|
54
|
+
* was supplied).
|
|
55
|
+
* @throws when discovery of the auth server metadata, or revocation of either token, fails
|
|
56
|
+
*/
|
|
57
|
+
revokeTokens(): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Lazily constructs (and caches) the {@link TokenRefresher} used to talk to the OAuth2 authorization
|
|
60
|
+
* server, discovering its metadata first if this is the first time it's needed.
|
|
61
|
+
* @returns the token refresher, or undefined if no `oauth2ClientConfig` was supplied
|
|
62
|
+
* @throws when discovery of the auth server metadata fails in a way that isn't worth retrying
|
|
63
|
+
*/
|
|
64
|
+
private ensureTokenRefresher;
|
|
65
|
+
/**
|
|
66
|
+
* Discovers the OAuth2 auth server metadata and constructs the OAuth2 client and token refresher from it.
|
|
67
|
+
* Throws if the request fails.
|
|
68
|
+
*/
|
|
69
|
+
private discoverTokenRefresher;
|
|
51
70
|
}
|
|
52
71
|
export {};
|
|
53
72
|
//# sourceMappingURL=refresh.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../src/http-api/refresh.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../src/http-api/refresh.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAA2B,MAAM,gBAAgB,CAAC;AAK5F;;GAEG;AAEH,0BAAkB,mBAAmB;IACjC,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,MAAM,WAAW;CACpB;AAQD,KAAK,IAAI,GAAG,IAAI,CACZ,SAAS,EACT,gBAAgB,GAAG,QAAQ,GAAG,cAAc,GAAG,aAAa,GAAG,oBAAoB,GAAG,sBAAsB,CAC/G,CAAC;AAEF;;;;;;GAMG;AACH,qBAAa,YAAY;IACF,OAAO,CAAC,QAAQ,CAAC,IAAI;IAAxC,YAAoC,IAAI,EAAE,IAAI,EAAI;IAElD;;;OAGG;IACH,OAAO,CAAC,mBAAmB,CAAC,CAA+B;IAE3D,OAAO,CAAC,wBAAwB,CAAC,CAAO;IAKxC,OAAO,CAAC,cAAc,CAAC,CAAiB;IAKxC,OAAO,CAAC,qBAAqB,CAAC,CAA0B;IAExD;;;;OAIG;IACU,iBAAiB,IAAI,OAAO,CAAC,YAAY,CAAC,CAStD;YAEa,eAAe;IAa7B;;;;;;OAMG;IACU,kBAAkB,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAErG;YAEa,mBAAmB;IA6BjC;;;;OAIG;YACW,cAAc;IAuC5B;;;;;OAKG;IACU,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAYzC;IAED;;;;;OAKG;YACW,oBAAoB;IAsBlC;;;OAGG;YACW,sBAAsB;CAavC"}
|
package/lib/http-api/refresh.js
CHANGED
|
@@ -17,6 +17,8 @@ limitations under the License.
|
|
|
17
17
|
|
|
18
18
|
import { MatrixError, TokenRefreshLogoutError } from "./errors.js";
|
|
19
19
|
import { sleep } from "../utils.js";
|
|
20
|
+
import { TokenRefresher } from "../oauth/tokenRefresher.js";
|
|
21
|
+
import { OAuth2 } from "../oauth/index.js";
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* This is an internal module. See {@link MatrixHttpApi} for the public class.
|
|
@@ -28,6 +30,7 @@ export let TokenRefreshOutcome = /*#__PURE__*/function (TokenRefreshOutcome) {
|
|
|
28
30
|
TokenRefreshOutcome["Logout"] = "logout";
|
|
29
31
|
return TokenRefreshOutcome;
|
|
30
32
|
}({});
|
|
33
|
+
|
|
31
34
|
// If the token expires in less than this time amount of time, we will eagerly refresh it before making the intended request.
|
|
32
35
|
const REFRESH_IF_TOKEN_EXPIRES_WITHIN_MS = 500;
|
|
33
36
|
// If we get an unknown token error and the token expires in less than this time amount of time, we will refresh it before making the intended request.
|
|
@@ -35,9 +38,12 @@ const REFRESH_IF_TOKEN_EXPIRES_WITHIN_MS = 500;
|
|
|
35
38
|
const REFRESH_ON_ERROR_IF_TOKEN_EXPIRES_WITHIN_MS = 60 * 1000;
|
|
36
39
|
/**
|
|
37
40
|
* This class is responsible for managing the access token and refresh token for authenticated requests.
|
|
38
|
-
* It will automatically refresh the access token
|
|
41
|
+
* It will automatically refresh the tokens when the access token is about to expire and can handle
|
|
42
|
+
* Unknown Token errors (via {@link TokenManager.handleUnknownToken})
|
|
43
|
+
*
|
|
44
|
+
* It will update the {@link Opts} object with new tokens as they are refreshed, and also call the {@link IHttpOpts.onTokenRefresh} callback if provided.
|
|
39
45
|
*/
|
|
40
|
-
export class
|
|
46
|
+
export class TokenManager {
|
|
41
47
|
constructor(opts) {
|
|
42
48
|
/**
|
|
43
49
|
* Promise used to block authenticated requests during a token refresh to avoid repeated expected errors.
|
|
@@ -45,6 +51,14 @@ export class TokenRefresher {
|
|
|
45
51
|
*/
|
|
46
52
|
_defineProperty(this, "tokenRefreshPromise", void 0);
|
|
47
53
|
_defineProperty(this, "latestTokenRefreshExpiry", void 0);
|
|
54
|
+
// The object at the OAuth API layer that actually does the refreshing
|
|
55
|
+
// This needs OAuth params to be fetched before it can be constructed so it starts
|
|
56
|
+
// off as undefined and is constructed once we are able to do so.
|
|
57
|
+
_defineProperty(this, "tokenRefresher", void 0);
|
|
58
|
+
// Tracks an in-progress attempt to discover the OAuth2 auth server metadata and construct
|
|
59
|
+
// `tokenRefresher`, so that concurrent callers wait for (and share the result of) the same attempt
|
|
60
|
+
// rather than racing to discover it independently.
|
|
61
|
+
_defineProperty(this, "tokenRefresherPromise", void 0);
|
|
48
62
|
this.opts = opts;
|
|
49
63
|
}
|
|
50
64
|
/**
|
|
@@ -114,8 +128,8 @@ export class TokenRefresher {
|
|
|
114
128
|
* @returns Promise that resolves to a boolean - true when token was refreshed successfully
|
|
115
129
|
*/
|
|
116
130
|
async doTokenRefresh(attempt) {
|
|
117
|
-
if (!this.opts.refreshToken || !this.opts.
|
|
118
|
-
this.opts.logger?.error("Unable to refresh token - no refresh token or
|
|
131
|
+
if (!this.opts.refreshToken || !this.opts.oauth2ClientConfig) {
|
|
132
|
+
this.opts.logger?.error("Unable to refresh token - no refresh token or OAuth2 client config");
|
|
119
133
|
return TokenRefreshOutcome.Logout;
|
|
120
134
|
}
|
|
121
135
|
if (attempt && attempt > 1) {
|
|
@@ -124,11 +138,16 @@ export class TokenRefresher {
|
|
|
124
138
|
}
|
|
125
139
|
try {
|
|
126
140
|
this.opts.logger?.debug("Attempting to refresh token");
|
|
141
|
+
const tokenRefresher = await this.ensureTokenRefresher();
|
|
142
|
+
if (!tokenRefresher) {
|
|
143
|
+
// We already checked `oauth2ClientConfig` is set above, so this should be unreachable.
|
|
144
|
+
return TokenRefreshOutcome.Logout;
|
|
145
|
+
}
|
|
127
146
|
const {
|
|
128
147
|
accessToken,
|
|
129
148
|
refreshToken,
|
|
130
149
|
expiry
|
|
131
|
-
} = await
|
|
150
|
+
} = await tokenRefresher.refreshTokens(this.opts.refreshToken);
|
|
132
151
|
this.opts.accessToken = accessToken;
|
|
133
152
|
this.opts.refreshToken = refreshToken;
|
|
134
153
|
this.latestTokenRefreshExpiry = expiry;
|
|
@@ -146,5 +165,53 @@ export class TokenRefresher {
|
|
|
146
165
|
return TokenRefreshOutcome.Failure;
|
|
147
166
|
}
|
|
148
167
|
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Attempt to revoke the current access and refresh tokens with the OAuth2 authorization server, e.g. as
|
|
171
|
+
* part of logging out. Does nothing if this is not an OAuth2-native session (ie. no `oauth2ClientConfig`
|
|
172
|
+
* was supplied).
|
|
173
|
+
* @throws when discovery of the auth server metadata, or revocation of either token, fails
|
|
174
|
+
*/
|
|
175
|
+
async revokeTokens() {
|
|
176
|
+
const tokenRefresher = await this.ensureTokenRefresher();
|
|
177
|
+
if (!tokenRefresher) return;
|
|
178
|
+
await Promise.all([this.opts.accessToken ? tokenRefresher.revokeToken(this.opts.accessToken, "access_token") : undefined, this.opts.refreshToken ? tokenRefresher.revokeToken(this.opts.refreshToken, "refresh_token") : undefined].filter(p => p !== undefined));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Lazily constructs (and caches) the {@link TokenRefresher} used to talk to the OAuth2 authorization
|
|
183
|
+
* server, discovering its metadata first if this is the first time it's needed.
|
|
184
|
+
* @returns the token refresher, or undefined if no `oauth2ClientConfig` was supplied
|
|
185
|
+
* @throws when discovery of the auth server metadata fails in a way that isn't worth retrying
|
|
186
|
+
*/
|
|
187
|
+
async ensureTokenRefresher() {
|
|
188
|
+
if (this.tokenRefresher) return this.tokenRefresher;
|
|
189
|
+
if (!this.opts.oauth2ClientConfig) return undefined;
|
|
190
|
+
if (!this.opts.authMetadataCallback) return undefined;
|
|
191
|
+
if (!this.tokenRefresherPromise) {
|
|
192
|
+
this.tokenRefresherPromise = this.discoverTokenRefresher(this.opts.oauth2ClientConfig, this.opts.authMetadataCallback);
|
|
193
|
+
}
|
|
194
|
+
try {
|
|
195
|
+
this.tokenRefresher = await this.tokenRefresherPromise;
|
|
196
|
+
return this.tokenRefresher;
|
|
197
|
+
} finally {
|
|
198
|
+
// Either we now have `tokenRefresher` cached and won't need this again, or discovery
|
|
199
|
+
// failed and a future call should be free to retry from scratch.
|
|
200
|
+
this.tokenRefresherPromise = undefined;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Discovers the OAuth2 auth server metadata and constructs the OAuth2 client and token refresher from it.
|
|
206
|
+
* Throws if the request fails.
|
|
207
|
+
*/
|
|
208
|
+
async discoverTokenRefresher(config, authMetaDataCallback) {
|
|
209
|
+
const metadata = await authMetaDataCallback();
|
|
210
|
+
const oauth2 = new OAuth2(metadata, {
|
|
211
|
+
clientId: config.clientId,
|
|
212
|
+
deviceId: config.deviceId
|
|
213
|
+
});
|
|
214
|
+
return new TokenRefresher(oauth2, tokens => this.opts.onTokenRefresh?.(tokens));
|
|
215
|
+
}
|
|
149
216
|
}
|
|
150
217
|
//# sourceMappingURL=refresh.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.js","names":[],"sources":["../../src/http-api/refresh.ts"],"sourcesContent":["/*\nCopyright 2025 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { MatrixError, TokenRefreshLogoutError } from \"./errors.ts\";\nimport { type IHttpOpts } from \"./interface.ts\";\nimport { sleep } from \"../utils.ts\";\n\n/**\n * This is an internal module. See {@link MatrixHttpApi} for the public class.\n */\n\nexport const enum TokenRefreshOutcome {\n Success = \"success\",\n Failure = \"failure\",\n Logout = \"logout\",\n}\n\ninterface Snapshot {\n accessToken: string;\n refreshToken?: string;\n expiry?: Date;\n}\n\n// If the token expires in less than this time amount of time, we will eagerly refresh it before making the intended request.\nconst REFRESH_IF_TOKEN_EXPIRES_WITHIN_MS = 500;\n// If we get an unknown token error and the token expires in less than this time amount of time, we will refresh it before making the intended request.\n// Otherwise, we will error as the token should not have expired yet and we need to avoid retrying indefinitely.\nconst REFRESH_ON_ERROR_IF_TOKEN_EXPIRES_WITHIN_MS = 60 * 1000;\n\ntype Opts = Pick<IHttpOpts, \"tokenRefreshFunction\" | \"logger\" | \"refreshToken\" | \"accessToken\">;\n\n/**\n * This class is responsible for managing the access token and refresh token for authenticated requests.\n * It will automatically refresh the access token when it is about to expire, and will handle unknown token errors.\n */\nexport class TokenRefresher {\n public constructor(private readonly opts: Opts) {}\n\n /**\n * Promise used to block authenticated requests during a token refresh to avoid repeated expected errors.\n * @private\n */\n private tokenRefreshPromise?: Promise<TokenRefreshOutcome>;\n\n private latestTokenRefreshExpiry?: Date;\n\n /**\n * This function is called before every request to ensure that the access token is valid.\n * @returns a snapshot containing the access token and other properties which must be passed to the handleUnknownToken\n * handler if an M_UNKNOWN_TOKEN error is encountered.\n */\n public async prepareForRequest(): Promise<Snapshot> {\n // Ensure our token is refreshed before we build the headers/params\n await this.refreshIfNeeded();\n\n return {\n accessToken: this.opts.accessToken!,\n refreshToken: this.opts.refreshToken,\n expiry: this.latestTokenRefreshExpiry,\n };\n }\n\n private async refreshIfNeeded(): Promise<unknown> {\n if (this.tokenRefreshPromise) {\n return this.tokenRefreshPromise;\n }\n // If we don't know the token expiry, we can't eagerly refresh\n if (!this.latestTokenRefreshExpiry) return;\n\n const expiresIn = this.latestTokenRefreshExpiry.getTime() - Date.now();\n if (expiresIn <= REFRESH_IF_TOKEN_EXPIRES_WITHIN_MS) {\n await this._handleUnknownToken();\n }\n }\n\n /**\n * This function is called when an M_UNKNOWN_TOKEN error is encountered.\n * It will attempt to refresh the access token if it is unknown, and will return a TokenRefreshOutcome.\n * @param snapshot - the snapshot returned by prepareForRequest\n * @param attempt - the number of attempts made for this request so far\n * @returns a TokenRefreshOutcome indicating the result of the refresh attempt\n */\n public async handleUnknownToken(snapshot: Snapshot, attempt: number): Promise<TokenRefreshOutcome> {\n return this._handleUnknownToken(snapshot, attempt);\n }\n\n private async _handleUnknownToken(): Promise<TokenRefreshOutcome>;\n private async _handleUnknownToken(snapshot: Snapshot, attempt: number): Promise<TokenRefreshOutcome>;\n private async _handleUnknownToken(snapshot?: Snapshot, attempt?: number): Promise<TokenRefreshOutcome> {\n if (snapshot?.expiry) {\n // If our token is unknown, but it should not have expired yet, then we should not refresh\n const expiresIn = snapshot.expiry.getTime() - Date.now();\n // If it still has plenty of time left on the clock, we assume something else must be wrong and\n // do not refresh. Otherwise if it's expired, or will soon, we try refreshing.\n if (expiresIn >= REFRESH_ON_ERROR_IF_TOKEN_EXPIRES_WITHIN_MS) {\n return TokenRefreshOutcome.Logout;\n }\n }\n\n if (!snapshot || snapshot?.accessToken === this.opts.accessToken) {\n // If we have a snapshot, but the access token is the same as the current one then a refresh\n // did not happen behind us but one may be ongoing anyway\n this.tokenRefreshPromise ??= this.doTokenRefresh(attempt);\n\n try {\n return await this.tokenRefreshPromise;\n } finally {\n this.tokenRefreshPromise = undefined;\n }\n }\n\n // We may end up here if the token was refreshed in the background due to another request\n return TokenRefreshOutcome.Success;\n }\n\n /**\n * Attempt to refresh access tokens.\n * On success, sets new access and refresh tokens in opts.\n * @returns Promise that resolves to a boolean - true when token was refreshed successfully\n */\n private async doTokenRefresh(attempt?: number): Promise<TokenRefreshOutcome> {\n if (!this.opts.refreshToken || !this.opts.tokenRefreshFunction) {\n this.opts.logger?.error(\"Unable to refresh token - no refresh token or refresh function\");\n return TokenRefreshOutcome.Logout;\n }\n\n if (attempt && attempt > 1) {\n // Exponential backoff to ensure we don't trash the server, up to 2^5 seconds\n await sleep(1000 * Math.min(32, 2 ** attempt));\n }\n\n try {\n this.opts.logger?.debug(\"Attempting to refresh token\");\n const { accessToken, refreshToken, expiry } = await this.opts.tokenRefreshFunction(this.opts.refreshToken);\n this.opts.accessToken = accessToken;\n this.opts.refreshToken = refreshToken;\n this.latestTokenRefreshExpiry = expiry;\n this.opts.logger?.debug(\"... token refresh complete, new token expiry:\", expiry);\n\n // successfully got new tokens\n return TokenRefreshOutcome.Success;\n } catch (error) {\n // If we get a TokenError or MatrixError, we should log out, otherwise assume transient\n if (error instanceof TokenRefreshLogoutError || error instanceof MatrixError) {\n this.opts.logger?.error(\"Failed to refresh token\", error);\n return TokenRefreshOutcome.Logout;\n }\n\n this.opts.logger?.warn(\"Failed to refresh token\", error);\n return TokenRefreshOutcome.Failure;\n }\n }\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAS,WAA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AAC,IAAI,CAAC,YAAY,CAAC;MAC1G,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,WAAW;MACnC,IAAI,CAAC,IAAI,CAAC,YAAY,GAAG,YAAY;MACrC,IAAI,CAAC,wBAAwB,GAAG,MAAM;MACtC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,+CAA+C,EAAE,MAAM,CAAC;;MAEhF;MACA,OAAO,mBAAmB,CAAC,OAAO;IACtC,CAAC,CAAC,OAAO,KAAK,EAAE;MACZ;MACA,IAAI,KAAK,YAAY,uBAAuB,IAAI,KAAK,YAAY,WAAW,EAAE;QAC1E,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC;QACzD,OAAO,mBAAmB,CAAC,MAAM;MACrC;MAEA,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,yBAAyB,EAAE,KAAK,CAAC;MACxD,OAAO,mBAAmB,CAAC,OAAO;IACtC;EACJ;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"refresh.js","names":[],"sources":["../../src/http-api/refresh.ts"],"sourcesContent":["/*\nCopyright 2025 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { MatrixError, TokenRefreshLogoutError } from \"./errors.ts\";\nimport { type AccessTokens, type IHttpOpts, type OAuth2ClientConfig } from \"./interface.ts\";\nimport { sleep } from \"../utils.ts\";\nimport { TokenRefresher } from \"../oauth/tokenRefresher.ts\";\nimport { OAuth2, type ValidatedAuthMetadata } from \"../oauth/index.ts\";\n\n/**\n * This is an internal module. See {@link MatrixHttpApi} for the public class.\n */\n\nexport const enum TokenRefreshOutcome {\n Success = \"success\",\n Failure = \"failure\",\n Logout = \"logout\",\n}\n\n// If the token expires in less than this time amount of time, we will eagerly refresh it before making the intended request.\nconst REFRESH_IF_TOKEN_EXPIRES_WITHIN_MS = 500;\n// If we get an unknown token error and the token expires in less than this time amount of time, we will refresh it before making the intended request.\n// Otherwise, we will error as the token should not have expired yet and we need to avoid retrying indefinitely.\nconst REFRESH_ON_ERROR_IF_TOKEN_EXPIRES_WITHIN_MS = 60 * 1000;\n\ntype Opts = Pick<\n IHttpOpts,\n \"onTokenRefresh\" | \"logger\" | \"refreshToken\" | \"accessToken\" | \"oauth2ClientConfig\" | \"authMetadataCallback\"\n>;\n\n/**\n * This class is responsible for managing the access token and refresh token for authenticated requests.\n * It will automatically refresh the tokens when the access token is about to expire and can handle\n * Unknown Token errors (via {@link TokenManager.handleUnknownToken})\n *\n * It will update the {@link Opts} object with new tokens as they are refreshed, and also call the {@link IHttpOpts.onTokenRefresh} callback if provided.\n */\nexport class TokenManager {\n public constructor(private readonly opts: Opts) {}\n\n /**\n * Promise used to block authenticated requests during a token refresh to avoid repeated expected errors.\n * @private\n */\n private tokenRefreshPromise?: Promise<TokenRefreshOutcome>;\n\n private latestTokenRefreshExpiry?: Date;\n\n // The object at the OAuth API layer that actually does the refreshing\n // This needs OAuth params to be fetched before it can be constructed so it starts\n // off as undefined and is constructed once we are able to do so.\n private tokenRefresher?: TokenRefresher;\n\n // Tracks an in-progress attempt to discover the OAuth2 auth server metadata and construct\n // `tokenRefresher`, so that concurrent callers wait for (and share the result of) the same attempt\n // rather than racing to discover it independently.\n private tokenRefresherPromise?: Promise<TokenRefresher>;\n\n /**\n * This function is called before every request to ensure that the access token is valid.\n * @returns a snapshot containing the access token and other properties which must be passed to the handleUnknownToken\n * handler if an M_UNKNOWN_TOKEN error is encountered.\n */\n public async prepareForRequest(): Promise<AccessTokens> {\n // Ensure our token is refreshed before we build the headers/params\n await this.refreshIfNeeded();\n\n return {\n accessToken: this.opts.accessToken!,\n refreshToken: this.opts.refreshToken,\n expiry: this.latestTokenRefreshExpiry,\n };\n }\n\n private async refreshIfNeeded(): Promise<unknown> {\n if (this.tokenRefreshPromise) {\n return this.tokenRefreshPromise;\n }\n // If we don't know the token expiry, we can't eagerly refresh\n if (!this.latestTokenRefreshExpiry) return;\n\n const expiresIn = this.latestTokenRefreshExpiry.getTime() - Date.now();\n if (expiresIn <= REFRESH_IF_TOKEN_EXPIRES_WITHIN_MS) {\n await this._handleUnknownToken();\n }\n }\n\n /**\n * This function is called when an M_UNKNOWN_TOKEN error is encountered.\n * It will attempt to refresh the access token if it is unknown, and will return a TokenRefreshOutcome.\n * @param snapshot - the snapshot returned by prepareForRequest\n * @param attempt - the number of attempts made for this request so far\n * @returns a TokenRefreshOutcome indicating the result of the refresh attempt\n */\n public async handleUnknownToken(snapshot: AccessTokens, attempt: number): Promise<TokenRefreshOutcome> {\n return this._handleUnknownToken(snapshot, attempt);\n }\n\n private async _handleUnknownToken(): Promise<TokenRefreshOutcome>;\n private async _handleUnknownToken(snapshot: AccessTokens, attempt: number): Promise<TokenRefreshOutcome>;\n private async _handleUnknownToken(snapshot?: AccessTokens, attempt?: number): Promise<TokenRefreshOutcome> {\n if (snapshot?.expiry) {\n // If our token is unknown, but it should not have expired yet, then we should not refresh\n const expiresIn = snapshot.expiry.getTime() - Date.now();\n // If it still has plenty of time left on the clock, we assume something else must be wrong and\n // do not refresh. Otherwise if it's expired, or will soon, we try refreshing.\n if (expiresIn >= REFRESH_ON_ERROR_IF_TOKEN_EXPIRES_WITHIN_MS) {\n return TokenRefreshOutcome.Logout;\n }\n }\n\n if (!snapshot || snapshot?.accessToken === this.opts.accessToken) {\n // If we have a snapshot, but the access token is the same as the current one then a refresh\n // did not happen behind us but one may be ongoing anyway\n this.tokenRefreshPromise ??= this.doTokenRefresh(attempt);\n\n try {\n return await this.tokenRefreshPromise;\n } finally {\n this.tokenRefreshPromise = undefined;\n }\n }\n\n // We may end up here if the token was refreshed in the background due to another request\n return TokenRefreshOutcome.Success;\n }\n\n /**\n * Attempt to refresh access tokens.\n * On success, sets new access and refresh tokens in opts.\n * @returns Promise that resolves to a boolean - true when token was refreshed successfully\n */\n private async doTokenRefresh(attempt?: number): Promise<TokenRefreshOutcome> {\n if (!this.opts.refreshToken || !this.opts.oauth2ClientConfig) {\n this.opts.logger?.error(\"Unable to refresh token - no refresh token or OAuth2 client config\");\n return TokenRefreshOutcome.Logout;\n }\n\n if (attempt && attempt > 1) {\n // Exponential backoff to ensure we don't trash the server, up to 2^5 seconds\n await sleep(1000 * Math.min(32, 2 ** attempt));\n }\n\n try {\n this.opts.logger?.debug(\"Attempting to refresh token\");\n const tokenRefresher = await this.ensureTokenRefresher();\n if (!tokenRefresher) {\n // We already checked `oauth2ClientConfig` is set above, so this should be unreachable.\n return TokenRefreshOutcome.Logout;\n }\n\n const { accessToken, refreshToken, expiry } = await tokenRefresher.refreshTokens(this.opts.refreshToken);\n this.opts.accessToken = accessToken;\n this.opts.refreshToken = refreshToken;\n this.latestTokenRefreshExpiry = expiry;\n this.opts.logger?.debug(\"... token refresh complete, new token expiry:\", expiry);\n\n // successfully got new tokens\n return TokenRefreshOutcome.Success;\n } catch (error) {\n // If we get a TokenError or MatrixError, we should log out, otherwise assume transient\n if (error instanceof TokenRefreshLogoutError || error instanceof MatrixError) {\n this.opts.logger?.error(\"Failed to refresh token\", error);\n return TokenRefreshOutcome.Logout;\n }\n\n this.opts.logger?.warn(\"Failed to refresh token\", error);\n return TokenRefreshOutcome.Failure;\n }\n }\n\n /**\n * Attempt to revoke the current access and refresh tokens with the OAuth2 authorization server, e.g. as\n * part of logging out. Does nothing if this is not an OAuth2-native session (ie. no `oauth2ClientConfig`\n * was supplied).\n * @throws when discovery of the auth server metadata, or revocation of either token, fails\n */\n public async revokeTokens(): Promise<void> {\n const tokenRefresher = await this.ensureTokenRefresher();\n if (!tokenRefresher) return;\n\n await Promise.all(\n [\n this.opts.accessToken ? tokenRefresher.revokeToken(this.opts.accessToken, \"access_token\") : undefined,\n this.opts.refreshToken\n ? tokenRefresher.revokeToken(this.opts.refreshToken, \"refresh_token\")\n : undefined,\n ].filter((p): p is Promise<void> => p !== undefined),\n );\n }\n\n /**\n * Lazily constructs (and caches) the {@link TokenRefresher} used to talk to the OAuth2 authorization\n * server, discovering its metadata first if this is the first time it's needed.\n * @returns the token refresher, or undefined if no `oauth2ClientConfig` was supplied\n * @throws when discovery of the auth server metadata fails in a way that isn't worth retrying\n */\n private async ensureTokenRefresher(): Promise<TokenRefresher | undefined> {\n if (this.tokenRefresher) return this.tokenRefresher;\n if (!this.opts.oauth2ClientConfig) return undefined;\n if (!this.opts.authMetadataCallback) return undefined;\n\n if (!this.tokenRefresherPromise) {\n this.tokenRefresherPromise = this.discoverTokenRefresher(\n this.opts.oauth2ClientConfig,\n this.opts.authMetadataCallback,\n );\n }\n\n try {\n this.tokenRefresher = await this.tokenRefresherPromise;\n return this.tokenRefresher;\n } finally {\n // Either we now have `tokenRefresher` cached and won't need this again, or discovery\n // failed and a future call should be free to retry from scratch.\n this.tokenRefresherPromise = undefined;\n }\n }\n\n /**\n * Discovers the OAuth2 auth server metadata and constructs the OAuth2 client and token refresher from it.\n * Throws if the request fails.\n */\n private async discoverTokenRefresher(\n config: OAuth2ClientConfig,\n authMetaDataCallback: () => Promise<ValidatedAuthMetadata>,\n ): Promise<TokenRefresher> {\n const metadata = await authMetaDataCallback();\n\n const oauth2 = new OAuth2(metadata, {\n clientId: config.clientId,\n deviceId: config.deviceId,\n });\n\n return new TokenRefresher(oauth2, (tokens) => this.opts.onTokenRefresh?.(tokens));\n }\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAS,WAAW,EAAE,uBAAuB,QAAQ,aAAa;AAElE,SAAS,KAAK,QAAQ,aAAa;AACnC,SAAS,cAAc,QAAQ,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CAClB,CAAC,MAAM,CAAE,CAAC,IAAyB,CAAC,KAAK,SAAS,CACvD,CAAC;EACL;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACI,MAAc,oBAAoB,GAAwC;IACtE,IAAI,IAAI,CAAC,cAAc,EAAE,OAAO,IAAI,CAAC,cAAc;IACnD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,OAAO,SAAS;IACnD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,OAAO,SAAS;IAErD,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE;MAC7B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,sBAAsB,CACpD,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAC5B,IAAI,CAAC,IAAI,CAAC,oBACd,CAAC;IACL;IAEA,IAAI;MACA,IAAI,CAAC,cAAc,GAAG,MAAM,IAAI,CAAC,qBAAqB;MACtD,OAAO,IAAI,CAAC,cAAc;IAC9B,CAAC,SAAS;MACN;MACA;MACA,IAAI,CAAC,qBAAqB,GAAG,SAAS;IAC1C;EACJ;;EAEA;AACJ;AACA;AACA;EACI,MAAc,sBAAsB,CAChC,MAA0B,EAC1B,oBAA0D,EACnC;IACvB,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAAC,CAAC;IAE7C,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE;MAChC,QAAQ,EAAE,MAAM,CAAC,QAAQ;MACzB,QAAQ,EAAE,MAAM,CAAC;IACrB,CAAC,CAAC;IAEF,OAAO,IAAI,cAAc,CAAC,MAAM,EAAG,MAAM,IAAK,IAAI,CAAC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,CAAC;EACrF;AACJ","ignoreList":[]}
|
package/lib/matrix.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ export * from "./models/event-status.ts";
|
|
|
63
63
|
export * from "./models/profile-keys.ts";
|
|
64
64
|
export * from "./models/related-relations.ts";
|
|
65
65
|
export { type StickyMatrixEvent, RoomStickyEventsEvent } from "./models/room-sticky-events.ts";
|
|
66
|
-
export type { RoomSummary } from "./
|
|
66
|
+
export type { RoomSummary } from "./room-summary-api.ts";
|
|
67
67
|
export * as ContentHelpers from "./content-helpers.ts";
|
|
68
68
|
export * as SecretStorage from "./secret-storage.ts";
|
|
69
69
|
export { createNewMatrixCall, CallEvent } from "./webrtc/call.ts";
|
package/lib/matrix.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKnD,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC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CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAC9G,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpE,YAAY,EAAE,QAAQ,IAAI,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvE,YAAY,EAAE,kBAAkB,IAAI,iBAAiB,EAAE,cAAc,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnH,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI1C;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,WAAW,GAAG,IAAI,CAElE;AAcD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,iBAAiB,GAAG,YAAY,CAElE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAClC,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,aAAa,EAC3B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,iBAAiB,EACvB,iBAAiB,UAAO,GACzB,YAAY,CAEd"}
|
package/lib/matrix.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix.js","names":[],"sources":["../src/matrix.ts"],"sourcesContent":["/*\nCopyright 2015-2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type WidgetApi } from \"matrix-widget-api\";\n\nimport { MemoryCryptoStore } from \"./crypto/store/memory-crypto-store.ts\";\nimport { MemoryStore } from \"./store/memory.ts\";\nimport { MatrixScheduler } from \"./scheduler.ts\";\nimport { MatrixClient, type ICreateClientOpts } from \"./client.ts\";\nimport { RoomWidgetClient, type ICapabilities } from \"./embedded.ts\";\nimport { type CryptoStore } from \"./crypto/store/base.ts\";\n\nexport * from \"./client.ts\";\nexport * from \"./serverCapabilities.ts\";\nexport * from \"./embedded.ts\";\nexport * from \"./http-api/index.ts\";\nexport * from \"./autodiscovery.ts\";\nexport * from \"./sync-accumulator.ts\";\nexport * from \"./errors.ts\";\nexport * from \"./base64.ts\";\nexport * from \"./models/beacon.ts\";\nexport * from \"./models/event.ts\";\nexport * from \"./models/room.ts\";\nexport * from \"./models/event-timeline.ts\";\nexport * from \"./models/event-timeline-set.ts\";\nexport * from \"./models/poll.ts\";\nexport * from \"./models/room-member.ts\";\nexport * from \"./models/room-state.ts\";\nexport * from \"./models/thread.ts\";\nexport * from \"./models/typed-event-emitter.ts\";\nexport * from \"./models/user.ts\";\nexport * from \"./models/device.ts\";\nexport * from \"./models/search-result.ts\";\nexport * from \"./oauth/index.ts\";\nexport * from \"./scheduler.ts\";\nexport * from \"./filter.ts\";\nexport * from \"./timeline-window.ts\";\nexport * from \"./interactive-auth.ts\";\nexport * from \"./version-support.ts\";\nexport * from \"./service-types.ts\";\nexport * from \"./store/memory.ts\";\nexport * from \"./store/indexeddb.ts\";\nexport * from \"./crypto/store/memory-crypto-store.ts\";\nexport * from \"./crypto/store/localStorage-crypto-store.ts\";\nexport * from \"./crypto/store/indexeddb-crypto-store.ts\";\nexport type { OutgoingRoomKeyRequest } from \"./crypto/store/base.ts\";\nexport * from \"./content-repo.ts\";\nexport type * from \"./@types/common.ts\";\nexport type * from \"./@types/uia.ts\";\nexport * from \"./@types/event.ts\";\nexport * from \"./@types/PushRules.ts\";\nexport * from \"./@types/partials.ts\";\nexport * from \"./@types/requests.ts\";\nexport * from \"./@types/search.ts\";\nexport * from \"./@types/beacon.ts\";\nexport * from \"./@types/topic.ts\";\nexport * from \"./@types/location.ts\";\nexport * from \"./@types/threepids.ts\";\nexport * from \"./@types/auth.ts\";\nexport * from \"./@types/polls.ts\";\nexport * from \"./@types/retention.ts\";\nexport type * from \"./@types/local_notifications.ts\";\nexport type * from \"./@types/registration.ts\";\nexport * from \"./@types/read_receipts.ts\";\nexport type * from \"./@types/crypto.ts\";\nexport * from \"./@types/extensible_events.ts\";\nexport type * from \"./@types/IIdentityServerProvider.ts\";\nexport * from \"./@types/membership.ts\";\nexport * from \"./models/room-summary.ts\";\nexport * from \"./models/event-status.ts\";\nexport * from \"./models/profile-keys.ts\";\nexport * from \"./models/related-relations.ts\";\nexport { type StickyMatrixEvent, RoomStickyEventsEvent } from \"./models/room-sticky-events.ts\";\nexport type { RoomSummary } from \"./client.ts\";\nexport * as ContentHelpers from \"./content-helpers.ts\";\nexport * as SecretStorage from \"./secret-storage.ts\";\nexport { createNewMatrixCall, CallEvent } from \"./webrtc/call.ts\";\nexport type { MatrixCall } from \"./webrtc/call.ts\";\nexport {\n GroupCall,\n GroupCallEvent,\n GroupCallIntent,\n GroupCallState,\n GroupCallType,\n GroupCallStatsReportEvent,\n} from \"./webrtc/groupCall.ts\";\n\nexport { SyncState, SetPresence } from \"./sync.ts\";\nexport type { ISyncStateData as SyncStateData } from \"./sync.ts\";\nexport { SlidingSyncEvent } from \"./sliding-sync.ts\";\nexport { MediaHandlerEvent } from \"./webrtc/mediaHandler.ts\";\nexport { CallFeedEvent } from \"./webrtc/callFeed.ts\";\nexport { StatsReport } from \"./webrtc/stats/statsReport.ts\";\nexport { Relations, RelationsEvent } from \"./models/relations.ts\";\nexport { TypedEventEmitter } from \"./models/typed-event-emitter.ts\";\nexport { LocalStorageErrors, localStorageErrorsEventsEmitter } from \"./store/local-storage-events-emitter.ts\";\nexport { IdentityProviderBrand, SSOAction } from \"./@types/auth.ts\";\nexport type { ISSOFlow as SSOFlow, LoginFlow } from \"./@types/auth.ts\";\nexport type { IHierarchyRelation as HierarchyRelation, IHierarchyRoom as HierarchyRoom } from \"./@types/spaces.ts\";\nexport { LocationAssetType } from \"./@types/location.ts\";\nexport { DebugLogger } from \"./logger.ts\";\n\nlet cryptoStoreFactory = (): CryptoStore => new MemoryCryptoStore();\n\n/**\n * Configure a different factory to be used for creating crypto stores\n *\n * @param fac - a function which will return a new `CryptoStore`\n */\nexport function setCryptoStoreFactory(fac: () => CryptoStore): void {\n cryptoStoreFactory = fac;\n}\n\nfunction amendClientOpts(opts: ICreateClientOpts): ICreateClientOpts {\n opts.store =\n opts.store ??\n new MemoryStore({\n localStorage: globalThis.localStorage,\n });\n opts.scheduler = opts.scheduler ?? new MatrixScheduler();\n opts.cryptoStore = opts.cryptoStore ?? cryptoStoreFactory();\n\n return opts;\n}\n\n/**\n * Construct a Matrix Client. Similar to {@link MatrixClient}\n * except that the 'request', 'store' and 'scheduler' dependencies are satisfied.\n * @param opts - The configuration options for this client. These configuration\n * options will be passed directly to {@link MatrixClient}.\n *\n * @returns A new matrix client.\n * @see {@link MatrixClient} for the full list of options for\n * `opts`.\n */\nexport function createClient(opts: ICreateClientOpts): MatrixClient {\n return new MatrixClient(amendClientOpts(opts));\n}\n\n/**\n * Construct a Matrix Client that works in a widget.\n * This client has a subset of features compared to a full client.\n * It uses the widget-api to communicate with matrix. (widget \\<-\\> client \\<-\\> homeserver)\n * @returns A new matrix client with a subset of features.\n * @param opts - The configuration options for this client. These configuration\n * options will be passed directly to {@link MatrixClient}.\n * @param widgetApi - The widget api to use for communication.\n * @param capabilities - The capabilities the widget client will request.\n * @param roomId - The room id the widget is associated with.\n * @param sendContentLoaded - Whether to send a content loaded widget action immediately after initial setup.\n * Set to `false` if the widget uses `waitForIFrameLoad=true` (in this case the client does not expect a content loaded action at all),\n * or if the the widget wants to send the `ContentLoaded` action at a later point in time after the initial setup.\n */\nexport function createRoomWidgetClient(\n widgetApi: WidgetApi,\n capabilities: ICapabilities,\n roomId: string,\n opts: ICreateClientOpts,\n sendContentLoaded = true,\n): MatrixClient {\n return new RoomWidgetClient(widgetApi, capabilities, roomId, amendClientOpts(opts), sendContentLoaded);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAAS,iBAAiB,QAAQ,uCAAuC;AACzE,SAAS,WAAW,QAAQ,mBAAmB;AAC/C,SAAS,eAAe,QAAQ,gBAAgB;AAChD,SAAS,YAAY,QAAgC,aAAa;AAClE,SAAS,gBAAgB,QAA4B,eAAe;AAGpE,cAAc,aAAa;AAC3B,cAAc,yBAAyB;AACvC,cAAc,eAAe;AAC7B,cAAc,qBAAqB;AACnC,cAAc,oBAAoB;AAClC,cAAc,uBAAuB;AACrC,cAAc,aAAa;AAC3B,cAAc,aAAa;AAC3B,cAAc,oBAAoB;AAClC,cAAc,mBAAmB;AACjC,cAAc,kBAAkB;AAChC,cAAc,4BAA4B;AAC1C,cAAc,gCAAgC;AAC9C,cAAc,kBAAkB;AAChC,cAAc,yBAAyB;AACvC,cAAc,wBAAwB;AACtC,cAAc,oBAAoB;AAClC,cAAc,iCAAiC;AAC/C,cAAc,kBAAkB;AAChC,cAAc,oBAAoB;AAClC,cAAc,2BAA2B;AACzC,cAAc,kBAAkB;AAChC,cAAc,gBAAgB;AAC9B,cAAc,aAAa;AAC3B,cAAc,sBAAsB;AACpC,cAAc,uBAAuB;AACrC,cAAc,sBAAsB;AACpC,cAAc,oBAAoB;AAClC,cAAc,mBAAmB;AACjC,cAAc,sBAAsB;AACpC,cAAc,u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;AACA;AACA;AACA,OAAO,SAAS,qBAAqB,CAAC,GAAsB,EAAQ;EAChE,kBAAkB,GAAG,GAAG;AAC5B;AAEA,SAAS,eAAe,CAAC,IAAuB,EAAqB;EACjE,IAAI,CAAC,KAAK,GACN,IAAI,CAAC,KAAK,IACV,IAAI,WAAW,CAAC;IACZ,YAAY,EAAE,UAAU,CAAC;EAC7B,CAAC,CAAC;EACN,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,eAAe,CAAC,CAAC;EACxD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,kBAAkB,CAAC,CAAC;EAE3D,OAAO,IAAI;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,YAAY,CAAC,IAAuB,EAAgB;EAChE,OAAO,IAAI,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,sBAAsB,CAClC,SAAoB,EACpB,YAA2B,EAC3B,MAAc,EACd,IAAuB,EACvB,iBAAiB,GAAG,IAAI,EACZ;EACZ,OAAO,IAAI,gBAAgB,CAAC,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,EAAE,iBAAiB,CAAC;AAC1G","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"matrix.js","names":[],"sources":["../src/matrix.ts"],"sourcesContent":["/*\nCopyright 2015-2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type WidgetApi } from \"matrix-widget-api\";\n\nimport { MemoryCryptoStore } from \"./crypto/store/memory-crypto-store.ts\";\nimport { MemoryStore } from \"./store/memory.ts\";\nimport { MatrixScheduler } from \"./scheduler.ts\";\nimport { MatrixClient, type ICreateClientOpts } from \"./client.ts\";\nimport { RoomWidgetClient, type ICapabilities } from \"./embedded.ts\";\nimport { type CryptoStore } from \"./crypto/store/base.ts\";\n\nexport * from \"./client.ts\";\nexport * from \"./serverCapabilities.ts\";\nexport * from \"./embedded.ts\";\nexport * from \"./http-api/index.ts\";\nexport * from \"./autodiscovery.ts\";\nexport * from \"./sync-accumulator.ts\";\nexport * from \"./errors.ts\";\nexport * from \"./base64.ts\";\nexport * from \"./models/beacon.ts\";\nexport * from \"./models/event.ts\";\nexport * from \"./models/room.ts\";\nexport * from \"./models/event-timeline.ts\";\nexport * from \"./models/event-timeline-set.ts\";\nexport * from \"./models/poll.ts\";\nexport * from \"./models/room-member.ts\";\nexport * from \"./models/room-state.ts\";\nexport * from \"./models/thread.ts\";\nexport * from \"./models/typed-event-emitter.ts\";\nexport * from \"./models/user.ts\";\nexport * from \"./models/device.ts\";\nexport * from \"./models/search-result.ts\";\nexport * from \"./oauth/index.ts\";\nexport * from \"./scheduler.ts\";\nexport * from \"./filter.ts\";\nexport * from \"./timeline-window.ts\";\nexport * from \"./interactive-auth.ts\";\nexport * from \"./version-support.ts\";\nexport * from \"./service-types.ts\";\nexport * from \"./store/memory.ts\";\nexport * from \"./store/indexeddb.ts\";\nexport * from \"./crypto/store/memory-crypto-store.ts\";\nexport * from \"./crypto/store/localStorage-crypto-store.ts\";\nexport * from \"./crypto/store/indexeddb-crypto-store.ts\";\nexport type { OutgoingRoomKeyRequest } from \"./crypto/store/base.ts\";\nexport * from \"./content-repo.ts\";\nexport type * from \"./@types/common.ts\";\nexport type * from \"./@types/uia.ts\";\nexport * from \"./@types/event.ts\";\nexport * from \"./@types/PushRules.ts\";\nexport * from \"./@types/partials.ts\";\nexport * from \"./@types/requests.ts\";\nexport * from \"./@types/search.ts\";\nexport * from \"./@types/beacon.ts\";\nexport * from \"./@types/topic.ts\";\nexport * from \"./@types/location.ts\";\nexport * from \"./@types/threepids.ts\";\nexport * from \"./@types/auth.ts\";\nexport * from \"./@types/polls.ts\";\nexport * from \"./@types/retention.ts\";\nexport type * from \"./@types/local_notifications.ts\";\nexport type * from \"./@types/registration.ts\";\nexport * from \"./@types/read_receipts.ts\";\nexport type * from \"./@types/crypto.ts\";\nexport * from \"./@types/extensible_events.ts\";\nexport type * from \"./@types/IIdentityServerProvider.ts\";\nexport * from \"./@types/membership.ts\";\nexport * from \"./models/room-summary.ts\";\nexport * from \"./models/event-status.ts\";\nexport * from \"./models/profile-keys.ts\";\nexport * from \"./models/related-relations.ts\";\nexport { type StickyMatrixEvent, RoomStickyEventsEvent } from \"./models/room-sticky-events.ts\";\nexport type { RoomSummary } from \"./room-summary-api.ts\";\nexport * as ContentHelpers from \"./content-helpers.ts\";\nexport * as SecretStorage from \"./secret-storage.ts\";\nexport { createNewMatrixCall, CallEvent } from \"./webrtc/call.ts\";\nexport type { MatrixCall } from \"./webrtc/call.ts\";\nexport {\n GroupCall,\n GroupCallEvent,\n GroupCallIntent,\n GroupCallState,\n GroupCallType,\n GroupCallStatsReportEvent,\n} from \"./webrtc/groupCall.ts\";\n\nexport { SyncState, SetPresence } from \"./sync.ts\";\nexport type { ISyncStateData as SyncStateData } from \"./sync.ts\";\nexport { SlidingSyncEvent } from \"./sliding-sync.ts\";\nexport { MediaHandlerEvent } from \"./webrtc/mediaHandler.ts\";\nexport { CallFeedEvent } from \"./webrtc/callFeed.ts\";\nexport { StatsReport } from \"./webrtc/stats/statsReport.ts\";\nexport { Relations, RelationsEvent } from \"./models/relations.ts\";\nexport { TypedEventEmitter } from \"./models/typed-event-emitter.ts\";\nexport { LocalStorageErrors, localStorageErrorsEventsEmitter } from \"./store/local-storage-events-emitter.ts\";\nexport { IdentityProviderBrand, SSOAction } from \"./@types/auth.ts\";\nexport type { ISSOFlow as SSOFlow, LoginFlow } from \"./@types/auth.ts\";\nexport type { IHierarchyRelation as HierarchyRelation, IHierarchyRoom as HierarchyRoom } from \"./@types/spaces.ts\";\nexport { LocationAssetType } from \"./@types/location.ts\";\nexport { DebugLogger } from \"./logger.ts\";\n\nlet cryptoStoreFactory = (): CryptoStore => new MemoryCryptoStore();\n\n/**\n * Configure a different factory to be used for creating crypto stores\n *\n * @param fac - a function which will return a new `CryptoStore`\n */\nexport function setCryptoStoreFactory(fac: () => CryptoStore): void {\n cryptoStoreFactory = fac;\n}\n\nfunction amendClientOpts(opts: ICreateClientOpts): ICreateClientOpts {\n opts.store =\n opts.store ??\n new MemoryStore({\n localStorage: globalThis.localStorage,\n });\n opts.scheduler = opts.scheduler ?? new MatrixScheduler();\n opts.cryptoStore = opts.cryptoStore ?? cryptoStoreFactory();\n\n return opts;\n}\n\n/**\n * Construct a Matrix Client. Similar to {@link MatrixClient}\n * except that the 'request', 'store' and 'scheduler' dependencies are satisfied.\n * @param opts - The configuration options for this client. These configuration\n * options will be passed directly to {@link MatrixClient}.\n *\n * @returns A new matrix client.\n * @see {@link MatrixClient} for the full list of options for\n * `opts`.\n */\nexport function createClient(opts: ICreateClientOpts): MatrixClient {\n return new MatrixClient(amendClientOpts(opts));\n}\n\n/**\n * Construct a Matrix Client that works in a widget.\n * This client has a subset of features compared to a full client.\n * It uses the widget-api to communicate with matrix. (widget \\<-\\> client \\<-\\> homeserver)\n * @returns A new matrix client with a subset of features.\n * @param opts - The configuration options for this client. These configuration\n * options will be passed directly to {@link MatrixClient}.\n * @param widgetApi - The widget api to use for communication.\n * @param capabilities - The capabilities the widget client will request.\n * @param roomId - The room id the widget is associated with.\n * @param sendContentLoaded - Whether to send a content loaded widget action immediately after initial setup.\n * Set to `false` if the widget uses `waitForIFrameLoad=true` (in this case the client does not expect a content loaded action at all),\n * or if the the widget wants to send the `ContentLoaded` action at a later point in time after the initial setup.\n */\nexport function createRoomWidgetClient(\n widgetApi: WidgetApi,\n capabilities: ICapabilities,\n roomId: string,\n opts: ICreateClientOpts,\n sendContentLoaded = true,\n): MatrixClient {\n return new RoomWidgetClient(widgetApi, capabilities, roomId, amendClientOpts(opts), sendContentLoaded);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAAS,iBAAiB,QAAQ,uCAAuC;AACzE,SAAS,WAAW,QAAQ,mBAAmB;AAC/C,SAAS,eAAe,QAAQ,gBAAgB;AAChD,SAAS,YAAY,QAAgC,aAAa;AAClE,SAAS,gBAAgB,QAA4B,eAAe;AAGpE,cAAc,aAAa;AAC3B,cAAc,yBAAyB;AACvC,cAAc,eAAe;AAC7B,cAAc,qBAAqB;AACnC,cAAc,oBAAoB;AAClC,cAAc,uBAAuB;AACrC,cAAc,aAAa;AAC3B,cAAc,aAAa;AAC3B,cAAc,oBAAoB;AAClC,cAAc,mBAAmB;AACjC,cAAc,kBAAkB;AAChC,cAAc,4BAA4B;AAC1C,cAAc,gCAAgC;AAC9C,cAAc,kBAAkB;AAChC,cAAc,yBAAyB;AACvC,cAAc,wBAAwB;AACtC,cAAc,oBAAoB;AAClC,cAAc,iCAAiC;AAC/C,cAAc,kBAAkB;AAChC,cAAc,oBAAoB;AAClC,cAAc,2BAA2B;AACzC,cAAc,kBAAkB;AAChC,cAAc,gBAAgB;AAC9B,cAAc,aAAa;AAC3B,cAAc,sBAAsB;AACpC,cAAc,uBAAuB;AACrC,cAAc,sBAAsB;AACpC,cAAc,oBAAoB;AAClC,cAAc,mBAAmB;AACjC,cAAc,sBAAsB;AACpC,cAAc,uCAAuC;AACrD,cAAc,6CAA6C;AAC3D,cAAc,0CAA0C;AAExD,cAAc,mBAAmB;AAGjC,cAAc,mBAAmB;AACjC,cAAc,uBAAuB;AACrC,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,oBAAoB;AAClC,c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IAAI,WAAW,CAAC;IACZ,YAAY,EAAE,UAAU,CAAC;EAC7B,CAAC,CAAC;EACN,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,eAAe,CAAC,CAAC;EACxD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,kBAAkB,CAAC,CAAC;EAE3D,OAAO,IAAI;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,YAAY,CAAC,IAAuB,EAAgB;EAChE,OAAO,IAAI,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,sBAAsB,CAClC,SAAoB,EACpB,YAA2B,EAC3B,MAAc,EACd,IAAuB,EACvB,iBAAiB,GAAG,IAAI,EACZ;EACZ,OAAO,IAAI,gBAAgB,CAAC,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,EAAE,iBAAiB,CAAC;AAC1G","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CallMembership.d.ts","sourceRoot":"","sources":["../../src/matrixrtc/CallMembership.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAGH,KAAK,iBAAiB,EAEtB,KAAK,qBAAqB,EAE7B,MAAM,2BAA2B,CAAC;AAGnC;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,QAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"CallMembership.d.ts","sourceRoot":"","sources":["../../src/matrixrtc/CallMembership.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,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zB,cAAc,EAAE,cAAc,EAC/B,kBAAkB,EAAE,MAAM,EAU7C;IAED,qCAAqC;IACrC,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED,IAAW,MAAM,IAAI,MAAM,CAS1B;IAED,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED;;;OAGG;IACH,IAAW,MAAM,IAAI,MAAM,CAgD1B;IAED,IAAW,QAAQ,IAAI,MAAM,CAS5B;IAED,IAAW,UAAU,IAAI,aAAa,GAAG,SAAS,CAOjD;IAED;;OAEG;IACH,IAAW,eAAe,IAAI,eAAe,CAO5C;IAED;;;OAGG;IACH,IAAW,WAAW,IAAI,MAAM,CAE/B;IAED;;;OAGG;IACH,IAAW,eAAe,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAerE;IAED,mHAAmH;IACnH,IAAW,KAAK,IAAI,qBAAqB,CAAC,OAAO,CAAC,GAAG,SAAS,CAS7D;IAED;;;;;;;;;;;;;OAaG;IACH,IAAW,QAAQ,IAAI,MAAM,CAkB5B;IAED;;OAEG;IACH,IAAW,YAAY,IAAI,MAAM,CAEhC;IAEM,SAAS,IAAI,MAAM,CAUzB;IAED;;;OAGG;IACI,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAU7C;IAED;;;OAGG;IACI,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAY5C;IAED;;OAEG;IACI,SAAS,IAAI,OAAO,CAS1B;IAED;;;;;;;;;;;;;;;;OAgBG;IACI,YAAY,CAAC,gBAAgB,EAAE,cAAc,GAAG,SAAS,GAAG,SAAS,CAqB3E;IAED;;;OAGG;IACH,IAAW,UAAU,IAAI,SAAS,EAAE,CASnC;CACJ"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
1
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
const _excluded = ["application"];
|
|
2
5
|
/*
|
|
3
6
|
Copyright 2023-2026 The Matrix.org Foundation C.I.C.
|
|
4
7
|
|
|
@@ -28,6 +31,9 @@ import { EventType } from "../@types/event.js";
|
|
|
28
31
|
*/
|
|
29
32
|
export const DEFAULT_EXPIRE_DURATION = 1000 * 60 * 60 * 4;
|
|
30
33
|
|
|
34
|
+
/** The fields of a legacy session membership that belong to the session, not the application */
|
|
35
|
+
const sessionFields = ["application", "call_id", "device_id", "focus_active", "foci_preferred", "created_ts", "scope", "expires", "m.call.intent", "membershipID"];
|
|
36
|
+
|
|
31
37
|
/**
|
|
32
38
|
* Describes the source event type that provided the membership data.
|
|
33
39
|
*/
|
|
@@ -261,12 +267,20 @@ export class CallMembership {
|
|
|
261
267
|
return data.application;
|
|
262
268
|
case MembershipKind.Session:
|
|
263
269
|
default:
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
+
{
|
|
271
|
+
// SessionData has no application object: the application's own
|
|
272
|
+
// data sits at the top level beside the session fields, so
|
|
273
|
+
// everything but those is the application's
|
|
274
|
+
const {
|
|
275
|
+
application
|
|
276
|
+
} = data,
|
|
277
|
+
rest = _objectWithoutProperties(data, _excluded);
|
|
278
|
+
for (const key of sessionFields) delete rest[key];
|
|
279
|
+
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
280
|
+
"type": application,
|
|
281
|
+
"m.call.intent": data["m.call.intent"]
|
|
282
|
+
});
|
|
283
|
+
}
|
|
270
284
|
}
|
|
271
285
|
}
|
|
272
286
|
|