matrix-js-sdk 42.3.0 → 42.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/lib/@types/json.d.ts.map +1 -1
  3. package/lib/@types/json.js.map +1 -1
  4. package/lib/client.d.ts +74 -5
  5. package/lib/client.d.ts.map +1 -1
  6. package/lib/client.js +83 -7
  7. package/lib/client.js.map +1 -1
  8. package/lib/common-crypto/CryptoBackend.d.ts +42 -23
  9. package/lib/common-crypto/CryptoBackend.d.ts.map +1 -1
  10. package/lib/common-crypto/CryptoBackend.js +7 -0
  11. package/lib/common-crypto/CryptoBackend.js.map +1 -1
  12. package/lib/embedded.d.ts +35 -1
  13. package/lib/embedded.d.ts.map +1 -1
  14. package/lib/embedded.js +49 -1
  15. package/lib/embedded.js.map +1 -1
  16. package/lib/http-api/fetch.d.ts +0 -1
  17. package/lib/http-api/fetch.d.ts.map +1 -1
  18. package/lib/http-api/fetch.js +3 -22
  19. package/lib/http-api/fetch.js.map +1 -1
  20. package/lib/http-api/logging.d.ts +10 -0
  21. package/lib/http-api/logging.d.ts.map +1 -0
  22. package/lib/http-api/logging.js +46 -0
  23. package/lib/http-api/logging.js.map +1 -0
  24. package/lib/matrixrtc/EncryptionManager.d.ts +5 -0
  25. package/lib/matrixrtc/EncryptionManager.d.ts.map +1 -1
  26. package/lib/matrixrtc/EncryptionManager.js.map +1 -1
  27. package/lib/matrixrtc/LivekitTransport.d.ts +82 -0
  28. package/lib/matrixrtc/LivekitTransport.d.ts.map +1 -1
  29. package/lib/matrixrtc/LivekitTransport.js +25 -0
  30. package/lib/matrixrtc/LivekitTransport.js.map +1 -1
  31. package/lib/matrixrtc/MatrixRTCSession.d.ts +41 -2
  32. package/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -1
  33. package/lib/matrixrtc/MatrixRTCSession.js +59 -1
  34. package/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
  35. package/lib/matrixrtc/MembershipManager.js +7 -4
  36. package/lib/matrixrtc/MembershipManager.js.map +1 -1
  37. package/lib/matrixrtc/RTCEncryptionManager.d.ts +17 -0
  38. package/lib/matrixrtc/RTCEncryptionManager.d.ts.map +1 -1
  39. package/lib/matrixrtc/RTCEncryptionManager.js +68 -29
  40. package/lib/matrixrtc/RTCEncryptionManager.js.map +1 -1
  41. package/lib/models/room-receipts.d.ts +9 -3
  42. package/lib/models/room-receipts.d.ts.map +1 -1
  43. package/lib/models/room-receipts.js +51 -11
  44. package/lib/models/room-receipts.js.map +1 -1
  45. package/lib/oauth/authorize.d.ts +7 -2
  46. package/lib/oauth/authorize.d.ts.map +1 -1
  47. package/lib/oauth/authorize.js +10 -4
  48. package/lib/oauth/authorize.js.map +1 -1
  49. package/lib/oauth/fetch.d.ts +17 -0
  50. package/lib/oauth/fetch.d.ts.map +1 -0
  51. package/lib/oauth/fetch.js +47 -0
  52. package/lib/oauth/fetch.js.map +1 -0
  53. package/lib/oauth/index.d.ts +15 -2
  54. package/lib/oauth/index.d.ts.map +1 -1
  55. package/lib/oauth/index.js +33 -12
  56. package/lib/oauth/index.js.map +1 -1
  57. package/lib/rust-crypto/index.d.ts +17 -0
  58. package/lib/rust-crypto/index.d.ts.map +1 -1
  59. package/lib/rust-crypto/index.js +4 -2
  60. package/lib/rust-crypto/index.js.map +1 -1
  61. package/lib/rust-crypto/rust-crypto.d.ts +6 -26
  62. package/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
  63. package/lib/rust-crypto/rust-crypto.js +19 -54
  64. package/lib/rust-crypto/rust-crypto.js.map +1 -1
  65. package/lib/sliding-sync-sdk.d.ts.map +1 -1
  66. package/lib/sliding-sync-sdk.js +65 -27
  67. package/lib/sliding-sync-sdk.js.map +1 -1
  68. package/lib/sliding-sync.d.ts +17 -0
  69. package/lib/sliding-sync.d.ts.map +1 -1
  70. package/lib/sliding-sync.js +21 -9
  71. package/lib/sliding-sync.js.map +1 -1
  72. package/lib/sync.d.ts +9 -1
  73. package/lib/sync.d.ts.map +1 -1
  74. package/lib/sync.js +54 -29
  75. package/lib/sync.js.map +1 -1
  76. package/package.json +5 -5
  77. package/src/@types/json.ts +11 -2
  78. package/src/client.ts +126 -11
  79. package/src/common-crypto/CryptoBackend.ts +45 -23
  80. package/src/embedded.ts +67 -4
  81. package/src/http-api/fetch.ts +2 -23
  82. package/src/http-api/logging.ts +46 -0
  83. package/src/matrixrtc/EncryptionManager.ts +6 -0
  84. package/src/matrixrtc/LivekitTransport.ts +86 -0
  85. package/src/matrixrtc/MatrixRTCSession.ts +81 -1
  86. package/src/matrixrtc/MembershipManager.ts +7 -7
  87. package/src/matrixrtc/RTCEncryptionManager.ts +80 -31
  88. package/src/models/room-receipts.ts +54 -10
  89. package/src/oauth/authorize.ts +10 -2
  90. package/src/oauth/fetch.ts +54 -0
  91. package/src/oauth/index.ts +29 -10
  92. package/src/rust-crypto/index.ts +23 -0
  93. package/src/rust-crypto/rust-crypto.ts +25 -67
  94. package/src/sliding-sync-sdk.ts +73 -33
  95. package/src/sliding-sync.ts +31 -14
  96. package/src/sync.ts +58 -35
@@ -0,0 +1,47 @@
1
+ /*
2
+ Copyright 2026 The Matrix.org Foundation C.I.C.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { sanitizeUrlForLogs } from "../http-api/logging.js";
18
+ import { Method } from "../http-api/method.js";
19
+ /**
20
+ * Perform a `fetch` request, logging the request and response in the same manner as
21
+ * `FetchHttpApi` does for Client-Server API requests.
22
+ *
23
+ * Neither the request nor the response body is logged, as they routinely contain credentials.
24
+ * Query parameter values are redacted for the same reason.
25
+ *
26
+ * @internal
27
+ * @param logger - the logger to write the request and response lines to.
28
+ * @param resource - the URL to request.
29
+ * @param options - the options to pass to `fetch`.
30
+ * @returns the `Response`, whatever its status code.
31
+ * @throws rethrows whatever `fetch` threw, having logged it.
32
+ */
33
+ export async function fetchWithLogging(logger, resource, options = {}) {
34
+ const method = options.method ?? Method.Get;
35
+ const urlForLogs = sanitizeUrlForLogs(resource);
36
+ logger.debug(`OAuth2: --> ${method} ${urlForLogs}`);
37
+ const start = Date.now();
38
+ try {
39
+ const res = await globalThis.fetch(resource, options);
40
+ logger.debug(`OAuth2: <-- ${method} ${urlForLogs} [${Date.now() - start}ms ${res.status}]`);
41
+ return res;
42
+ } catch (e) {
43
+ logger.debug(`OAuth2: <-- ${method} ${urlForLogs} [${Date.now() - start}ms ${e}]`);
44
+ throw e;
45
+ }
46
+ }
47
+ //# sourceMappingURL=fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.js","names":[],"sources":["../../src/oauth/fetch.ts"],"sourcesContent":["/*\nCopyright 2026 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 { sanitizeUrlForLogs } from \"../http-api/logging.ts\";\nimport { Method } from \"../http-api/method.ts\";\nimport { type Logger } from \"../logger.ts\";\n\n/**\n * Perform a `fetch` request, logging the request and response in the same manner as\n * `FetchHttpApi` does for Client-Server API requests.\n *\n * Neither the request nor the response body is logged, as they routinely contain credentials.\n * Query parameter values are redacted for the same reason.\n *\n * @internal\n * @param logger - the logger to write the request and response lines to.\n * @param resource - the URL to request.\n * @param options - the options to pass to `fetch`.\n * @returns the `Response`, whatever its status code.\n * @throws rethrows whatever `fetch` threw, having logged it.\n */\nexport async function fetchWithLogging(\n logger: Logger,\n resource: URL | string,\n options: RequestInit = {},\n): Promise<Response> {\n const method = options.method ?? Method.Get;\n const urlForLogs = sanitizeUrlForLogs(resource);\n\n logger.debug(`OAuth2: --> ${method} ${urlForLogs}`);\n\n const start = Date.now();\n try {\n const res = await globalThis.fetch(resource, options);\n logger.debug(`OAuth2: <-- ${method} ${urlForLogs} [${Date.now() - start}ms ${res.status}]`);\n return res;\n } catch (e) {\n logger.debug(`OAuth2: <-- ${method} ${urlForLogs} [${Date.now() - start}ms ${e}]`);\n throw e;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAS,kBAAkB,QAAQ,wBAAwB;AAC3D,SAAS,MAAM,QAAQ,uBAAuB;AAG9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAe,gBAAgB,CAClC,MAAc,EACd,QAAsB,EACtB,OAAoB,GAAG,CAAC,CAAC,EACR;EACjB,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,GAAG;EAC3C,MAAM,UAAU,GAAG,kBAAkB,CAAC,QAAQ,CAAC;EAE/C,MAAM,CAAC,KAAK,CAAC,eAAe,MAAM,IAAI,UAAU,EAAE,CAAC;EAEnD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;EACxB,IAAI;IACA,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC;IACrD,MAAM,CAAC,KAAK,CAAC,eAAe,MAAM,IAAI,UAAU,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,MAAM,GAAG,CAAC,MAAM,GAAG,CAAC;IAC3F,OAAO,GAAG;EACd,CAAC,CAAC,OAAO,CAAC,EAAE;IACR,MAAM,CAAC,KAAK,CAAC,eAAe,MAAM,IAAI,UAAU,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC;IAClF,MAAM,CAAC;EACX;AACJ","ignoreList":[]}
@@ -1,6 +1,7 @@
1
1
  import { type BearerTokenResponse, type DeviceAccessTokenError, type DeviceAccessTokenResponse, type DeviceAuthorizationResponse } from "./authorize.ts";
2
2
  import type { ValidatedAuthMetadata } from "./discover.ts";
3
3
  import { type OAuthRegistrationRequest } from "./register.ts";
4
+ import { type Logger } from "../logger.ts";
4
5
  export * from "./authorize.ts";
5
6
  export * from "./error.ts";
6
7
  export * from "./register.ts";
@@ -21,18 +22,26 @@ type Context = {
21
22
  };
22
23
  export declare class OAuth2 {
23
24
  readonly metadata: ValidatedAuthMetadata;
25
+ private readonly logger;
24
26
  /**
25
27
  * Attempts dynamic registration against the configured registration endpoint.
26
28
  * Will ignore any URIs that do not use client_uri as a common base as per the spec.
27
29
  * @param authMetadata - Auth config from {@link MatrixClient.getAuthMetadata}
28
30
  * @param clientMetadata - The metadata for the client which to register,
29
31
  * grant_types & response_types & token_endpoint_auth_method will be sanely calculated if omitted.
32
+ * @param logger - Optional logger to use for the request, defaults to the root logger of the js-sdk.
30
33
  * @returns Promise<string> resolved with registered clientId
31
34
  * @throws when registration is not supported, on failed request or invalid response
32
35
  */
33
- static registerClient(authMetadata: ValidatedAuthMetadata, clientMetadata: OAuthRegistrationRequest): Promise<string>;
36
+ static registerClient(authMetadata: ValidatedAuthMetadata, clientMetadata: OAuthRegistrationRequest, logger?: Logger): Promise<string>;
34
37
  readonly context: Required<Context>;
35
- constructor(metadata: ValidatedAuthMetadata, context: Context);
38
+ /**
39
+ * @param metadata - The validated OAuth 2.0 metadata for the Identity Provider.
40
+ * @param context - The persistent context needed for the OAuth flows.
41
+ * @param logger - Optional logger to use for the requests made by this instance,
42
+ * defaults to the root logger of the js-sdk.
43
+ */
44
+ constructor(metadata: ValidatedAuthMetadata, context: Context, logger?: Logger);
36
45
  /**
37
46
  * Generate a URL to attempt authorization with the OP
38
47
  * See https://spec.matrix.org/v1.18/client-server-api/#authorization-code-flow
@@ -82,6 +91,10 @@ export declare class OAuth2 {
82
91
  * or an error response if the user denies authorization or the device code expires.
83
92
  */
84
93
  waitForDeviceAuthorizationGrant(session: DeviceAuthorizationResponse): Promise<DeviceAccessTokenResponse | DeviceAccessTokenError>;
94
+ /**
95
+ * Make a request to one of the OAuth 2.0 endpoints, throwing if it responds with an error.
96
+ * @returns the {@link Response}, for the caller to parse if the endpoint returns a body.
97
+ */
85
98
  private fetch;
86
99
  }
87
100
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/oauth/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,2BAA2B,EAMnC,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAEH,KAAK,wBAAwB,EAGhC,MAAM,eAAe,CAAC;AASvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAE9B;;GAEG;AACH,KAAK,OAAO,GAAG;IACX,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,WAAW,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,qBAAa,MAAM;aA0EK,QAAQ,EAAE,qBAAqB;IAzEnD;;;;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EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAYxF;IAED;;;;OAIG;IACU,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAa9F;IAED;;;;;OAKG;IACU,6BAA6B,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAO/F;IAED;;;;;OAKG;IACU,+BAA+B,CACxC,OAAO,EAAE,2BAA2B,GACrC,OAAO,CAAC,yBAAyB,GAAG,sBAAsB,CAAC,CAO7D;IAED;;;OAGG;YACW,KAAK;CAsCtB"}
@@ -21,7 +21,8 @@ import { OAuthGrantType, urlHasCommonBase, validateRegistrationResponse } from "
21
21
  import { encodeUnpaddedBase64Url } from "../base64.js";
22
22
  import { sha256 } from "../digest.js";
23
23
  import { HTTPError, isMatrixErrorResponse, MatrixError, Method } from "../http-api/index.js";
24
- import { logger } from "../logger.js";
24
+ import { logger as rootLogger } from "../logger.js";
25
+ import { fetchWithLogging } from "./fetch.js";
25
26
  import { isOAuth2ErrorResponse, OAuth2Error, OAuth2HTTPError } from "./error.js";
26
27
  import { secureRandomString } from "../randomstring.js";
27
28
  export * from "./authorize.js";
@@ -41,10 +42,11 @@ export class OAuth2 {
41
42
  * @param authMetadata - Auth config from {@link MatrixClient.getAuthMetadata}
42
43
  * @param clientMetadata - The metadata for the client which to register,
43
44
  * grant_types & response_types & token_endpoint_auth_method will be sanely calculated if omitted.
45
+ * @param logger - Optional logger to use for the request, defaults to the root logger of the js-sdk.
44
46
  * @returns Promise<string> resolved with registered clientId
45
47
  * @throws when registration is not supported, on failed request or invalid response
46
48
  */
47
- static async registerClient(authMetadata, clientMetadata) {
49
+ static async registerClient(authMetadata, clientMetadata, logger = rootLogger) {
48
50
  const defaultGrantTypes = [OAuthGrantType.AuthorizationCode, OAuthGrantType.RefreshToken];
49
51
  // ask for device authorization grant if supported
50
52
  if (authMetadata.grant_types_supported.includes(OAuthGrantType.DeviceAuthorization)) {
@@ -66,7 +68,7 @@ export class OAuth2 {
66
68
  tos_uri: urlHasCommonBase(commonBase, clientMetadata.tos_uri) ? clientMetadata.tos_uri : undefined
67
69
  });
68
70
  try {
69
- const response = await fetch(authMetadata.registration_endpoint, {
71
+ const response = await fetchWithLogging(logger, authMetadata.registration_endpoint, {
70
72
  method: Method.Post,
71
73
  headers: {
72
74
  "Accept": "application/json",
@@ -93,9 +95,16 @@ export class OAuth2 {
93
95
  }
94
96
  }
95
97
  }
96
- constructor(metadata, context) {
98
+ /**
99
+ * @param metadata - The validated OAuth 2.0 metadata for the Identity Provider.
100
+ * @param context - The persistent context needed for the OAuth flows.
101
+ * @param logger - Optional logger to use for the requests made by this instance,
102
+ * defaults to the root logger of the js-sdk.
103
+ */
104
+ constructor(metadata, context, logger = rootLogger) {
97
105
  _defineProperty(this, "context", void 0);
98
106
  this.metadata = metadata;
107
+ this.logger = logger;
99
108
  this.context = {
100
109
  clientId: context.clientId,
101
110
  redirectUri: context.redirectUri,
@@ -150,7 +159,8 @@ export class OAuth2 {
150
159
  params.append("code_verifier", this.context.codeVerifier);
151
160
  params.append("redirect_uri", this.context.redirectUri);
152
161
  params.append("code", code);
153
- const tokenResponse = await this.fetch("token", params, OAuth2Error.CodeExchangeFailed);
162
+ const res = await this.fetch("token", params, OAuth2Error.CodeExchangeFailed);
163
+ const tokenResponse = await res.json();
154
164
 
155
165
  // throws when response is invalid
156
166
  validateBearerTokenResponse(tokenResponse);
@@ -166,7 +176,8 @@ export class OAuth2 {
166
176
  params.append("grant_type", "refresh_token");
167
177
  params.append("client_id", this.context.clientId);
168
178
  params.append("refresh_token", refreshToken);
169
- const tokenResponse = await this.fetch("token", params, OAuth2Error.RefreshTokenFailed);
179
+ const res = await this.fetch("token", params, OAuth2Error.RefreshTokenFailed);
180
+ const tokenResponse = await res.json();
170
181
 
171
182
  // throws when response is invalid
172
183
  validateBearerTokenResponse(tokenResponse);
@@ -185,9 +196,12 @@ export class OAuth2 {
185
196
  if (type) {
186
197
  params.append("token_type_hint", type);
187
198
  }
199
+
200
+ // [RFC 7009 section 2.2](https://www.rfc-editor.org/rfc/rfc7009.html#section-2.2) says:
201
+ // > The content of the response body is ignored by the client as all
202
+ // > necessary information is conveyed in the response code.
203
+ // so, we don't do anything with the response body.
188
204
  await this.fetch("revocation", params, OAuth2Error.RevokeTokenFailed);
189
- const headers = new Headers();
190
- headers.set("Content-Type", "application/x-www-form-urlencoded");
191
205
  }
192
206
 
193
207
  /**
@@ -200,7 +214,8 @@ export class OAuth2 {
200
214
  return startDeviceAuthorization({
201
215
  scope: scope ?? generateScope(this.context.deviceId),
202
216
  metadata: this.metadata,
203
- clientId: this.context.clientId
217
+ clientId: this.context.clientId,
218
+ logger: this.logger
204
219
  });
205
220
  }
206
221
 
@@ -214,12 +229,18 @@ export class OAuth2 {
214
229
  return waitForDeviceAuthorization({
215
230
  session,
216
231
  metadata: this.metadata,
217
- clientId: this.context.clientId
232
+ clientId: this.context.clientId,
233
+ logger: this.logger
218
234
  });
219
235
  }
236
+
237
+ /**
238
+ * Make a request to one of the OAuth 2.0 endpoints, throwing if it responds with an error.
239
+ * @returns the {@link Response}, for the caller to parse if the endpoint returns a body.
240
+ */
220
241
  async fetch(target, params, error) {
221
242
  const url = this.metadata[`${target}_endpoint`];
222
- const res = await fetch(url, {
243
+ const res = await fetchWithLogging(this.logger, url, {
223
244
  method: Method.Post,
224
245
  headers: {
225
246
  "Content-Type": "application/x-www-form-urlencoded",
@@ -247,7 +268,7 @@ export class OAuth2 {
247
268
  }
248
269
  throw new HTTPError(error, res.status, res.headers);
249
270
  }
250
- return await res.json();
271
+ return res;
251
272
  }
252
273
  }
253
274
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/oauth/index.ts"],"sourcesContent":["/*\nCopyright 2023 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 {\n type BearerTokenResponse,\n type DeviceAccessTokenError,\n type DeviceAccessTokenResponse,\n type DeviceAuthorizationResponse,\n generateScope,\n normalizeBearerTokenResponseTokenType,\n startDeviceAuthorization,\n validateBearerTokenResponse,\n waitForDeviceAuthorization,\n} from \"./authorize.ts\";\nimport type { ValidatedAuthMetadata } from \"./discover.ts\";\nimport {\n OAuthGrantType,\n type OAuthRegistrationRequest,\n urlHasCommonBase,\n validateRegistrationResponse,\n} from \"./register.ts\";\nimport { encodeUnpaddedBase64Url } from \"../base64.ts\";\nimport { sha256 } from \"../digest.ts\";\nimport { HTTPError, isMatrixErrorResponse, MatrixError, Method } from \"../http-api/index.ts\";\nimport { logger } from \"../logger.ts\";\nimport { isOAuth2ErrorResponse, OAuth2Error, OAuth2HTTPError } from \"./error.ts\";\nimport { secureRandomString } from \"../randomstring.ts\";\nimport { type NonEmptyArray } from \"../@types/common.ts\";\n\nexport * from \"./authorize.ts\";\nexport * from \"./error.ts\";\nexport * from \"./register.ts\";\nexport * from \"./tokenRefresher.ts\";\nexport * from \"./discover.ts\";\n\n/**\n * Type representing the persistent context needed for typical OAuth flows\n */\ntype Context = {\n /** The OAuth client ID */\n clientId: string;\n /** The desired device ID */\n deviceId?: string;\n /** The seed used to generate the challenge code */\n codeVerifier?: string;\n /** The URI to redirect the user to with credentials after auth */\n redirectUri: string;\n};\n\nexport class OAuth2 {\n /**\n * Attempts dynamic registration against the configured registration endpoint.\n * Will ignore any URIs that do not use client_uri as a common base as per the spec.\n * @param authMetadata - Auth config from {@link MatrixClient.getAuthMetadata}\n * @param clientMetadata - The metadata for the client which to register,\n * grant_types & response_types & token_endpoint_auth_method will be sanely calculated if omitted.\n * @returns Promise<string> resolved with registered clientId\n * @throws when registration is not supported, on failed request or invalid response\n */\n public static async registerClient(\n authMetadata: ValidatedAuthMetadata,\n clientMetadata: OAuthRegistrationRequest,\n ): Promise<string> {\n const defaultGrantTypes: NonEmptyArray<string> = [\n OAuthGrantType.AuthorizationCode,\n OAuthGrantType.RefreshToken,\n ];\n // ask for device authorization grant if supported\n if (authMetadata.grant_types_supported.includes(OAuthGrantType.DeviceAuthorization)) {\n defaultGrantTypes.push(OAuthGrantType.DeviceAuthorization);\n }\n\n const grantTypes = clientMetadata.grant_types ?? defaultGrantTypes;\n if (grantTypes.some((scope) => !authMetadata.grant_types_supported.includes(scope))) {\n throw new Error(OAuth2Error.DynamicRegistrationNotSupported);\n }\n\n const commonBase = new URL(clientMetadata.client_uri);\n\n const request: OAuthRegistrationRequest = {\n // Apply some defaults\n response_types: [\"code\"],\n token_endpoint_auth_method: \"none\",\n ...clientMetadata,\n grant_types: grantTypes,\n logo_uri: urlHasCommonBase(commonBase, clientMetadata.logo_uri) ? clientMetadata.logo_uri : undefined,\n policy_uri: urlHasCommonBase(commonBase, clientMetadata.policy_uri) ? clientMetadata.policy_uri : undefined,\n tos_uri: urlHasCommonBase(commonBase, clientMetadata.tos_uri) ? clientMetadata.tos_uri : undefined,\n };\n\n try {\n const response = await fetch(authMetadata.registration_endpoint, {\n method: Method.Post,\n headers: {\n \"Accept\": \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(request),\n });\n\n if (response.status >= 400) {\n throw new Error(OAuth2Error.DynamicRegistrationFailed);\n }\n\n const registrationResponse = await response.json();\n if (validateRegistrationResponse(registrationResponse)) {\n return registrationResponse.client_id;\n }\n\n throw new Error(OAuth2Error.DynamicRegistrationInvalid);\n } catch (error) {\n if (Object.values(OAuth2Error).includes((error as Error).message as OAuth2Error)) {\n throw error;\n } else {\n logger.error(\"Dynamic registration request failed\", error);\n throw new Error(OAuth2Error.DynamicRegistrationFailed, { cause: error });\n }\n }\n }\n\n public readonly context: Required<Context>;\n\n public constructor(\n public readonly metadata: ValidatedAuthMetadata,\n context: Context,\n ) {\n this.context = {\n clientId: context.clientId,\n redirectUri: context.redirectUri,\n deviceId: context.deviceId ?? secureRandomString(10),\n codeVerifier: context.codeVerifier ?? secureRandomString(96),\n };\n }\n\n /**\n * Generate a URL to attempt authorization with the OP\n * See https://spec.matrix.org/v1.18/client-server-api/#authorization-code-flow\n * @param state - A unique opaque identifier, like a transaction ID,\n * that will allow the client to maintain state between the authorization request and the callback.\n * The app should use this to key the storage for where the rest of the auth context is saved.\n * @param responseMode - The manner in which the IdP should send the secrets back to the app. Defaults to `fragment` for privacy.\n * @param prompt - Optional prompt parameter to pass to the IdP to signal intent, e.g. `create` for User registration.\n * @param scope - The OAuth2 scope to request, will be generated based on the device ID if omitted.\n * @returns a Promise with the url as a string\n */\n public async generateAuthorizationCodeGrantUrl(\n state: string,\n responseMode: \"fragment\" | \"query\" = \"fragment\",\n prompt?: string,\n scope?: string,\n ): Promise<string> {\n const challenge = encodeUnpaddedBase64Url(await sha256(this.context.codeVerifier));\n\n const url = new URL(this.metadata.authorization_endpoint);\n url.searchParams.set(\"response_type\", \"code\");\n url.searchParams.set(\"response_mode\", responseMode);\n url.searchParams.set(\"client_id\", this.context.clientId);\n url.searchParams.set(\"redirect_uri\", this.context.redirectUri);\n url.searchParams.set(\"scope\", scope ?? generateScope(this.context.deviceId));\n url.searchParams.set(\"state\", state);\n url.searchParams.set(\"code_challenge_method\", \"S256\");\n url.searchParams.set(\"code_challenge\", challenge);\n\n if (prompt) {\n url.searchParams.set(\"prompt\", prompt);\n }\n\n return url.toString();\n }\n\n /**\n * Attempt to exchange authorization code for bearer token.\n *\n * Takes the authorization code returned by the OAuth2 Provider via the authorization URL, and makes a\n * request to the Token Endpoint, to obtain the access token, refresh token, etc.\n *\n * @param code - authorization code as returned by IdP during authorization\n * @returns a validated bearer token response\n * @throws An `Error` with `message` set to an entry in {@link OAuth2Error},\n * when the request fails, or the returned token response is invalid.\n */\n public async completeAuthorizationCodeGrant(code: string): Promise<BearerTokenResponse> {\n const params = new URLSearchParams();\n params.append(\"grant_type\", \"authorization_code\");\n params.append(\"client_id\", this.context.clientId);\n params.append(\"code_verifier\", this.context.codeVerifier);\n params.append(\"redirect_uri\", this.context.redirectUri);\n params.append(\"code\", code);\n\n const tokenResponse = await this.fetch(\"token\", params, OAuth2Error.CodeExchangeFailed);\n\n // throws when response is invalid\n validateBearerTokenResponse(tokenResponse);\n return normalizeBearerTokenResponseTokenType(tokenResponse);\n }\n\n /**\n * Refresh the access token using the given refresh token and the refresh token grant\n * @param refreshToken - the token to use to refresh the access token\n */\n public async performRefreshTokenGrant(refreshToken: string): Promise<BearerTokenResponse> {\n const params = new URLSearchParams();\n params.append(\"grant_type\", \"refresh_token\");\n params.append(\"client_id\", this.context.clientId);\n params.append(\"refresh_token\", refreshToken);\n\n const tokenResponse = await this.fetch(\"token\", params, OAuth2Error.RefreshTokenFailed);\n\n // throws when response is invalid\n validateBearerTokenResponse(tokenResponse);\n return normalizeBearerTokenResponseTokenType(tokenResponse);\n }\n\n /**\n * Revokes the given token\n * @param token - the token to remove\n * @param type - the type of token, acts as a hint to the IdP\n */\n public async revokeToken(token: string, type?: \"access_token\" | \"refresh_token\"): Promise<void> {\n const params = new URLSearchParams();\n params.append(\"token\", token);\n params.append(\"client_id\", this.context.clientId);\n if (type) {\n params.append(\"token_type_hint\", type);\n }\n\n await this.fetch(\"revocation\", params, OAuth2Error.RevokeTokenFailed);\n\n const headers = new Headers();\n headers.set(\"Content-Type\", \"application/x-www-form-urlencoded\");\n }\n\n /**\n * Begin OAuth2 device authorization flow.\n * @param scope - the scope to request for authorization.\n * @returns a promise that resolves to a device access token response,\n * or an error response if the user denies authorization or the device code expires.\n */\n public async startDeviceAuthorizationGrant(scope?: string): Promise<DeviceAuthorizationResponse> {\n return startDeviceAuthorization({\n scope: scope ?? generateScope(this.context.deviceId),\n metadata: this.metadata,\n clientId: this.context.clientId,\n });\n }\n\n /**\n * Polls the OAuth2 token endpoint until we get a device access token response, or encounter an unrecoverable error.\n * @param session - The session returned from a previous call to {@link OAuth2.startDeviceAuthorizationGrant}.\n * @returns a promise that resolves to a device access token response,\n * or an error response if the user denies authorization or the device code expires.\n */\n public async waitForDeviceAuthorizationGrant(\n session: DeviceAuthorizationResponse,\n ): Promise<DeviceAccessTokenResponse | DeviceAccessTokenError> {\n return waitForDeviceAuthorization({\n session,\n metadata: this.metadata,\n clientId: this.context.clientId,\n });\n }\n\n private async fetch(\n target: \"token\" | \"registration\" | \"revocation\",\n params: URLSearchParams,\n error: OAuth2Error,\n ): Promise<unknown> {\n const url = this.metadata[`${target}_endpoint`];\n const res = await fetch(url, {\n method: Method.Post,\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n \"Accept\": \"application/json\",\n },\n body: params,\n });\n\n if (res.status >= 400) {\n let body: unknown;\n try {\n body = await res.json();\n } catch {\n // The endpoint didn't give us a JSON body, so we can't determine the error type. We'll throw a generic\n // HTTPError below.\n }\n // Because the Matrix C-S API error response format is so similar to the OAuth 2.0 error response format\n // the ordering of these checks is important. We want to check for a Matrix error response first, and only\n // if it isn't one do we check for an OAuth 2.0 error response.\n // This essentially relies on `errcode` not being present in an OAuth 2.0 error response.\n if (isMatrixErrorResponse(body)) {\n throw new MatrixError(body, res.status, undefined, undefined, res.headers);\n }\n if (isOAuth2ErrorResponse(body)) {\n throw new OAuth2HTTPError(error, res.status, res.headers, body);\n }\n throw new HTTPError(error, res.status, res.headers);\n }\n\n return await res.json();\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAKI,aAAa,EACb,qCAAqC,EACrC,wBAAwB,EACxB,2BAA2B,EAC3B,0BAA0B,QACvB,gBAAgB;AAEvB,SACI,cAAc,EAEd,gBAAgB,EAChB,4BAA4B,Q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B,EACF;IAChB,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,MAAM,WAAW,CAAC;IAC/C,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;MACzB,MAAM,EAAE,MAAM,CAAC,IAAI;MACnB,OAAO,EAAE;QACL,cAAc,EAAE,mCAAmC;QACnD,QAAQ,EAAE;MACd,CAAC;MACD,IAAI,EAAE;IACV,CAAC,CAAC;IAEF,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,EAAE;MACnB,IAAI,IAAa;MACjB,IAAI;QACA,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC;MAC3B,CAAC,CAAC,MAAM;QACJ;QACA;MAAA;MAEJ;MACA;MACA;MACA;MACA,IAAI,qBAAqB,CAAC,IAAI,CAAC,EAAE;QAC7B,MAAM,IAAI,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC;MAC9E;MACA,IAAI,qBAAqB,CAAC,IAAI,CAAC,EAAE;QAC7B,MAAM,IAAI,eAAe,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC;MACnE;MACA,MAAM,IAAI,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC;IACvD;IAEA,OAAO,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC;EAC3B;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/oauth/index.ts"],"sourcesContent":["/*\nCopyright 2023 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 {\n type BearerTokenResponse,\n type DeviceAccessTokenError,\n type DeviceAccessTokenResponse,\n type DeviceAuthorizationResponse,\n generateScope,\n normalizeBearerTokenResponseTokenType,\n startDeviceAuthorization,\n validateBearerTokenResponse,\n waitForDeviceAuthorization,\n} from \"./authorize.ts\";\nimport type { ValidatedAuthMetadata } from \"./discover.ts\";\nimport {\n OAuthGrantType,\n type OAuthRegistrationRequest,\n urlHasCommonBase,\n validateRegistrationResponse,\n} from \"./register.ts\";\nimport { encodeUnpaddedBase64Url } from \"../base64.ts\";\nimport { sha256 } from \"../digest.ts\";\nimport { HTTPError, isMatrixErrorResponse, MatrixError, Method } from \"../http-api/index.ts\";\nimport { type Logger, logger as rootLogger } from \"../logger.ts\";\nimport { fetchWithLogging } from \"./fetch.ts\";\nimport { isOAuth2ErrorResponse, OAuth2Error, OAuth2HTTPError } from \"./error.ts\";\nimport { secureRandomString } from \"../randomstring.ts\";\nimport { type NonEmptyArray } from \"../@types/common.ts\";\n\nexport * from \"./authorize.ts\";\nexport * from \"./error.ts\";\nexport * from \"./register.ts\";\nexport * from \"./tokenRefresher.ts\";\nexport * from \"./discover.ts\";\n\n/**\n * Type representing the persistent context needed for typical OAuth flows\n */\ntype Context = {\n /** The OAuth client ID */\n clientId: string;\n /** The desired device ID */\n deviceId?: string;\n /** The seed used to generate the challenge code */\n codeVerifier?: string;\n /** The URI to redirect the user to with credentials after auth */\n redirectUri: string;\n};\n\nexport class OAuth2 {\n /**\n * Attempts dynamic registration against the configured registration endpoint.\n * Will ignore any URIs that do not use client_uri as a common base as per the spec.\n * @param authMetadata - Auth config from {@link MatrixClient.getAuthMetadata}\n * @param clientMetadata - The metadata for the client which to register,\n * grant_types & response_types & token_endpoint_auth_method will be sanely calculated if omitted.\n * @param logger - Optional logger to use for the request, defaults to the root logger of the js-sdk.\n * @returns Promise<string> resolved with registered clientId\n * @throws when registration is not supported, on failed request or invalid response\n */\n public static async registerClient(\n authMetadata: ValidatedAuthMetadata,\n clientMetadata: OAuthRegistrationRequest,\n logger: Logger = rootLogger,\n ): Promise<string> {\n const defaultGrantTypes: NonEmptyArray<string> = [\n OAuthGrantType.AuthorizationCode,\n OAuthGrantType.RefreshToken,\n ];\n // ask for device authorization grant if supported\n if (authMetadata.grant_types_supported.includes(OAuthGrantType.DeviceAuthorization)) {\n defaultGrantTypes.push(OAuthGrantType.DeviceAuthorization);\n }\n\n const grantTypes = clientMetadata.grant_types ?? defaultGrantTypes;\n if (grantTypes.some((scope) => !authMetadata.grant_types_supported.includes(scope))) {\n throw new Error(OAuth2Error.DynamicRegistrationNotSupported);\n }\n\n const commonBase = new URL(clientMetadata.client_uri);\n\n const request: OAuthRegistrationRequest = {\n // Apply some defaults\n response_types: [\"code\"],\n token_endpoint_auth_method: \"none\",\n ...clientMetadata,\n grant_types: grantTypes,\n logo_uri: urlHasCommonBase(commonBase, clientMetadata.logo_uri) ? clientMetadata.logo_uri : undefined,\n policy_uri: urlHasCommonBase(commonBase, clientMetadata.policy_uri) ? clientMetadata.policy_uri : undefined,\n tos_uri: urlHasCommonBase(commonBase, clientMetadata.tos_uri) ? clientMetadata.tos_uri : undefined,\n };\n\n try {\n const response = await fetchWithLogging(logger, authMetadata.registration_endpoint, {\n method: Method.Post,\n headers: {\n \"Accept\": \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(request),\n });\n\n if (response.status >= 400) {\n throw new Error(OAuth2Error.DynamicRegistrationFailed);\n }\n\n const registrationResponse = await response.json();\n if (validateRegistrationResponse(registrationResponse)) {\n return registrationResponse.client_id;\n }\n\n throw new Error(OAuth2Error.DynamicRegistrationInvalid);\n } catch (error) {\n if (Object.values(OAuth2Error).includes((error as Error).message as OAuth2Error)) {\n throw error;\n } else {\n logger.error(\"Dynamic registration request failed\", error);\n throw new Error(OAuth2Error.DynamicRegistrationFailed, { cause: error });\n }\n }\n }\n\n public readonly context: Required<Context>;\n\n /**\n * @param metadata - The validated OAuth 2.0 metadata for the Identity Provider.\n * @param context - The persistent context needed for the OAuth flows.\n * @param logger - Optional logger to use for the requests made by this instance,\n * defaults to the root logger of the js-sdk.\n */\n public constructor(\n public readonly metadata: ValidatedAuthMetadata,\n context: Context,\n private readonly logger: Logger = rootLogger,\n ) {\n this.context = {\n clientId: context.clientId,\n redirectUri: context.redirectUri,\n deviceId: context.deviceId ?? secureRandomString(10),\n codeVerifier: context.codeVerifier ?? secureRandomString(96),\n };\n }\n\n /**\n * Generate a URL to attempt authorization with the OP\n * See https://spec.matrix.org/v1.18/client-server-api/#authorization-code-flow\n * @param state - A unique opaque identifier, like a transaction ID,\n * that will allow the client to maintain state between the authorization request and the callback.\n * The app should use this to key the storage for where the rest of the auth context is saved.\n * @param responseMode - The manner in which the IdP should send the secrets back to the app. Defaults to `fragment` for privacy.\n * @param prompt - Optional prompt parameter to pass to the IdP to signal intent, e.g. `create` for User registration.\n * @param scope - The OAuth2 scope to request, will be generated based on the device ID if omitted.\n * @returns a Promise with the url as a string\n */\n public async generateAuthorizationCodeGrantUrl(\n state: string,\n responseMode: \"fragment\" | \"query\" = \"fragment\",\n prompt?: string,\n scope?: string,\n ): Promise<string> {\n const challenge = encodeUnpaddedBase64Url(await sha256(this.context.codeVerifier));\n\n const url = new URL(this.metadata.authorization_endpoint);\n url.searchParams.set(\"response_type\", \"code\");\n url.searchParams.set(\"response_mode\", responseMode);\n url.searchParams.set(\"client_id\", this.context.clientId);\n url.searchParams.set(\"redirect_uri\", this.context.redirectUri);\n url.searchParams.set(\"scope\", scope ?? generateScope(this.context.deviceId));\n url.searchParams.set(\"state\", state);\n url.searchParams.set(\"code_challenge_method\", \"S256\");\n url.searchParams.set(\"code_challenge\", challenge);\n\n if (prompt) {\n url.searchParams.set(\"prompt\", prompt);\n }\n\n return url.toString();\n }\n\n /**\n * Attempt to exchange authorization code for bearer token.\n *\n * Takes the authorization code returned by the OAuth2 Provider via the authorization URL, and makes a\n * request to the Token Endpoint, to obtain the access token, refresh token, etc.\n *\n * @param code - authorization code as returned by IdP during authorization\n * @returns a validated bearer token response\n * @throws An `Error` with `message` set to an entry in {@link OAuth2Error},\n * when the request fails, or the returned token response is invalid.\n */\n public async completeAuthorizationCodeGrant(code: string): Promise<BearerTokenResponse> {\n const params = new URLSearchParams();\n params.append(\"grant_type\", \"authorization_code\");\n params.append(\"client_id\", this.context.clientId);\n params.append(\"code_verifier\", this.context.codeVerifier);\n params.append(\"redirect_uri\", this.context.redirectUri);\n params.append(\"code\", code);\n\n const res = await this.fetch(\"token\", params, OAuth2Error.CodeExchangeFailed);\n const tokenResponse = await res.json();\n\n // throws when response is invalid\n validateBearerTokenResponse(tokenResponse);\n return normalizeBearerTokenResponseTokenType(tokenResponse);\n }\n\n /**\n * Refresh the access token using the given refresh token and the refresh token grant\n * @param refreshToken - the token to use to refresh the access token\n */\n public async performRefreshTokenGrant(refreshToken: string): Promise<BearerTokenResponse> {\n const params = new URLSearchParams();\n params.append(\"grant_type\", \"refresh_token\");\n params.append(\"client_id\", this.context.clientId);\n params.append(\"refresh_token\", refreshToken);\n\n const res = await this.fetch(\"token\", params, OAuth2Error.RefreshTokenFailed);\n const tokenResponse = await res.json();\n\n // throws when response is invalid\n validateBearerTokenResponse(tokenResponse);\n return normalizeBearerTokenResponseTokenType(tokenResponse);\n }\n\n /**\n * Revokes the given token\n * @param token - the token to remove\n * @param type - the type of token, acts as a hint to the IdP\n */\n public async revokeToken(token: string, type?: \"access_token\" | \"refresh_token\"): Promise<void> {\n const params = new URLSearchParams();\n params.append(\"token\", token);\n params.append(\"client_id\", this.context.clientId);\n if (type) {\n params.append(\"token_type_hint\", type);\n }\n\n // [RFC 7009 section 2.2](https://www.rfc-editor.org/rfc/rfc7009.html#section-2.2) says:\n // > The content of the response body is ignored by the client as all\n // > necessary information is conveyed in the response code.\n // so, we don't do anything with the response body.\n await this.fetch(\"revocation\", params, OAuth2Error.RevokeTokenFailed);\n }\n\n /**\n * Begin OAuth2 device authorization flow.\n * @param scope - the scope to request for authorization.\n * @returns a promise that resolves to a device access token response,\n * or an error response if the user denies authorization or the device code expires.\n */\n public async startDeviceAuthorizationGrant(scope?: string): Promise<DeviceAuthorizationResponse> {\n return startDeviceAuthorization({\n scope: scope ?? generateScope(this.context.deviceId),\n metadata: this.metadata,\n clientId: this.context.clientId,\n logger: this.logger,\n });\n }\n\n /**\n * Polls the OAuth2 token endpoint until we get a device access token response, or encounter an unrecoverable error.\n * @param session - The session returned from a previous call to {@link OAuth2.startDeviceAuthorizationGrant}.\n * @returns a promise that resolves to a device access token response,\n * or an error response if the user denies authorization or the device code expires.\n */\n public async waitForDeviceAuthorizationGrant(\n session: DeviceAuthorizationResponse,\n ): Promise<DeviceAccessTokenResponse | DeviceAccessTokenError> {\n return waitForDeviceAuthorization({\n session,\n metadata: this.metadata,\n clientId: this.context.clientId,\n logger: this.logger,\n });\n }\n\n /**\n * Make a request to one of the OAuth 2.0 endpoints, throwing if it responds with an error.\n * @returns the {@link Response}, for the caller to parse if the endpoint returns a body.\n */\n private async fetch(\n target: \"token\" | \"registration\" | \"revocation\",\n params: URLSearchParams,\n error: OAuth2Error,\n ): Promise<Response> {\n const url = this.metadata[`${target}_endpoint`];\n const res = await fetchWithLogging(this.logger, url, {\n method: Method.Post,\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n \"Accept\": \"application/json\",\n },\n body: params,\n });\n\n if (res.status >= 400) {\n let body: unknown;\n try {\n body = await res.json();\n } catch {\n // The endpoint didn't give us a JSON body, so we can't determine the error type. We'll throw a generic\n // HTTPError below.\n }\n // Because the Matrix C-S API error response format is so similar to the OAuth 2.0 error response format\n // the ordering of these checks is important. We want to check for a Matrix error response first, and only\n // if it isn't one do we check for an OAuth 2.0 error response.\n // This essentially relies on `errcode` not being present in an OAuth 2.0 error response.\n if (isMatrixErrorResponse(body)) {\n throw new MatrixError(body, res.status, undefined, undefined, res.headers);\n }\n if (isOAuth2ErrorResponse(body)) {\n throw new OAuth2HTTPError(error, res.status, res.headers, body);\n }\n throw new HTTPError(error, res.status, res.headers);\n }\n\n return res;\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAKI,aAAa,EACb,qCAAqC,EACrC,wBAAwB,EACxB,2BAA2B,EAC3B,0BAA0B,QACvB,gBAAgB;AAEvB,SACI,cAAc,EAEd,gBAAgB,EAChB,4BAA4B,QACzB,eAAe;AACtB,SAAS,uBAAuB,QAAQ,cAAc;AACtD,SAAS,MAAM,QAAQ,cAAc;AACrC,SAAS,SAAS,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,QAAQ,sBAAsB;AAC5F,SAAsB,MAAM,IAAI,UAAU,QAAQ,cAAc;AAChE,SAAS,gBAAgB,QAAQ,YAAY;AAC7C,SAAS,qBAAqB,EAAE,WAAW,EAAE,eAAe,QAAQ,YAAY;AAChF,SAAS,kBAAkB,QAAQ,oBAAoB;AAGvD,cAAc,gBAAgB;AAC9B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,qBAAqB;AACnC,cAAc,eAAe;;AAE7B;AACA;AACA;;AAYA,OAAO,MAAM,MAAM,CAAC;EAChB;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACI,aAAoB,cAAc,CAC9B,YAAmC,EACnC,cAAwC,EACxC,MAAc,GAAG,UAAU,EACZ;IACf,MAAM,iBAAwC,GAAG,CAC7C,cAAc,CAAC,iBAAiB,EAChC,cAAc,CAAC,YAAY,CAC9B;IACD;IACA,IAAI,YAAY,CAAC,qBAAqB,CAAC,QAAQ,CAAC,cAAc,CAAC,mBAAmB,CAAC,EAAE;MACjF,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,mBAAmB,CAAC;IAC9D;IAEA,MAAM,UAAU,GAAG,cAAc,CAAC,WAAW,IAAI,iBAAiB;IAClE,IAA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CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC;MAC9E;MACA,IAAI,qBAAqB,CAAC,IAAI,CAAC,EAAE;QAC7B,MAAM,IAAI,eAAe,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC;MACnE;MACA,MAAM,IAAI,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC;IACvD;IAEA,OAAO,GAAG;EACd;AACJ","ignoreList":[]}
@@ -67,6 +67,23 @@ export interface InitRustCryptoArgs {
67
67
  * considered verified, without any manual verification taking place.
68
68
  */
69
69
  caCertsPem?: string;
70
+ /**
71
+ * Optional async function for signing some data with an X.509 certificate.
72
+ * Used to sign the user's identity so compatible clients will recognise
73
+ * this user as verified without manual verification taking place. If you
74
+ * supply this you must also supply {@link InitRustCryptoArgs#x509Validity}.
75
+ */
76
+ x509Signer?: (item: Uint8Array) => Promise<{
77
+ signature_bytes: Uint8Array;
78
+ certificate_chain: string;
79
+ signature_scheme: "RsaPssSha512";
80
+ }>;
81
+ /**
82
+ * Optional function returning the validity period of the X.509 certificate
83
+ * used for signing, as the number of milliseconds since the Unix epoch. If
84
+ * you supply this you must also supply {@link InitRustCryptoArgs#x509Signer}.
85
+ */
86
+ x509Validity?: () => number;
70
87
  }
71
88
  /**
72
89
  * Create a new `RustCrypto` implementation
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rust-crypto/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EAA2C,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;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CAAC;QACvC,eAAe,EAAE,UAAU,CAAC;QAC5B,iBAAiB,EAAE,MAAM,CAAC;QAC1B,gBAAgB,EAAE,cAAc,CAAC;KACpC,CAAC,CAAC;IAEH;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,MAAM,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC,CAkClF"}
@@ -73,10 +73,12 @@ async function initOlmMachine({
73
73
  cryptoCallbacks,
74
74
  legacyCryptoStore,
75
75
  enableEncryptedStateEvents,
76
- caCertsPem
76
+ caCertsPem,
77
+ x509Signer,
78
+ x509Validity
77
79
  }, storeHandle) {
78
80
  logger.debug("Init OlmMachine");
79
- const olmMachine = await RustSdkCryptoJs.OlmMachine.initFromStore(new RustSdkCryptoJs.UserId(userId), new RustSdkCryptoJs.DeviceId(deviceId), storeHandle, logger, caCertsPem);
81
+ const olmMachine = await RustSdkCryptoJs.OlmMachine.initFromStore(new RustSdkCryptoJs.UserId(userId), new RustSdkCryptoJs.DeviceId(deviceId), storeHandle, logger, caCertsPem, x509Signer, x509Validity);
80
82
 
81
83
  // A final migration step, now that we have an OlmMachine.
82
84
  if (legacyCryptoStore) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/rust-crypto/index.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 * as RustSdkCryptoJs from \"@matrix-org/matrix-sdk-crypto-wasm\";\nimport { StoreHandle } from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport { MAX_INVITE_ACCEPTANCE_MS_FOR_KEY_BUNDLE, RustCrypto } from \"./rust-crypto.ts\";\nimport { type IHttpOpts, type MatrixHttpApi } from \"../http-api/index.ts\";\nimport { type ServerSideSecretStorage } from \"../secret-storage.ts\";\nimport { type Logger } from \"../logger.ts\";\nimport { type CryptoStore, MigrationState } from \"../crypto/store/base.ts\";\nimport {\n migrateFromLegacyCrypto,\n migrateLegacyLocalTrustIfNeeded,\n migrateRoomSettingsFromLegacyCrypto,\n} from \"./libolm_migration.ts\";\nimport { type CryptoCallbacks } from \"../crypto-api/index.ts\";\n\n/**\n * The arguments used to initialise RustCrypto, passed in to initRustCrypto.\n *\n * @internal\n */\nexport interface InitRustCryptoArgs {\n /** A `Logger` instance that will be used for debug output. */\n logger: Logger;\n\n /**\n * Low-level HTTP interface: used to make outgoing requests required by the rust SDK.\n * We expect it to set the access token, etc.\n */\n http: MatrixHttpApi<IHttpOpts & { onlyData: true }>;\n\n /** The local user's User ID. */\n userId: string;\n\n /** The local user's Device ID. */\n deviceId: string;\n\n /** Interface to server-side secret storage. */\n secretStorage: ServerSideSecretStorage;\n\n /** Crypto callbacks provided by the application. */\n cryptoCallbacks: CryptoCallbacks;\n\n /**\n * The prefix to use on the indexeddbs created by rust-crypto.\n * If `null`, a memory store will be used.\n */\n storePrefix: string | null;\n\n /**\n * A passphrase to use to encrypt the indexeddb created by rust-crypto.\n *\n * Ignored if `storePrefix` is null, or `storeKey` is set. If neither this nor `storeKey` is set\n * (and `storePrefix` is not null), the indexeddb will be unencrypted.\n */\n storePassphrase?: string;\n\n /**\n * A key to use to encrypt the indexeddb created by rust-crypto.\n *\n * Ignored if `storePrefix` is null. Otherwise, if it is set, it must be a 32-byte cryptographic key, which\n * will be used to encrypt the indexeddb. See also `storePassphrase`.\n */\n storeKey?: Uint8Array;\n\n /** If defined, we will check if any data needs migrating from this store to the rust store. */\n legacyCryptoStore?: CryptoStore;\n\n /** The pickle key for `legacyCryptoStore` */\n legacyPickleKey?: string;\n\n /**\n * A callback which will receive progress updates on migration from `legacyCryptoStore`.\n *\n * Called with (-1, -1) to mark the end of migration.\n */\n legacyMigrationProgressListener?: (progress: number, total: number) => void;\n\n /**\n * Whether to enable support for encrypting state events.\n */\n enableEncryptedStateEvents?: boolean;\n\n /**\n * Optional PEM-formatted string that provides CA certificates. These will\n * be used to check X.509 signatures on user identities. Any user identity\n * that has a valid signature according to the supplied CAs will be\n * considered verified, without any manual verification taking place.\n */\n caCertsPem?: string;\n}\n\n/**\n * Create a new `RustCrypto` implementation\n *\n * @param args - InitRustCryptoArgs\n * @internal\n */\nexport async function initRustCrypto(args: InitRustCryptoArgs): Promise<RustCrypto> {\n const { logger } = args;\n\n // initialise the rust matrix-sdk-crypto-wasm, if it hasn't already been done\n logger.debug(\"Initialising Rust crypto-sdk WASM artifact\");\n await RustSdkCryptoJs.initAsync();\n\n logger.debug(\"Opening Rust CryptoStore\");\n let storeHandle;\n if (args.storePrefix) {\n if (args.storeKey) {\n storeHandle = await StoreHandle.openWithKey(args.storePrefix, args.storeKey, logger);\n } else {\n storeHandle = await StoreHandle.open(args.storePrefix, args.storePassphrase, logger);\n }\n } else {\n storeHandle = await StoreHandle.open(null, null, logger);\n }\n\n if (args.legacyCryptoStore) {\n // We have a legacy crypto store, which we may need to migrate from.\n await migrateFromLegacyCrypto({\n legacyStore: args.legacyCryptoStore,\n storeHandle,\n ...args,\n });\n }\n\n const rustCrypto = await initOlmMachine(args, storeHandle);\n\n storeHandle.free();\n\n logger.debug(\"Completed rust crypto-sdk setup\");\n return rustCrypto;\n}\n\nasync function initOlmMachine(\n {\n logger,\n http,\n userId,\n deviceId,\n secretStorage,\n cryptoCallbacks,\n legacyCryptoStore,\n enableEncryptedStateEvents,\n caCertsPem,\n }: InitRustCryptoArgs,\n storeHandle: StoreHandle,\n): Promise<RustCrypto> {\n logger.debug(\"Init OlmMachine\");\n\n const olmMachine = await RustSdkCryptoJs.OlmMachine.initFromStore(\n new RustSdkCryptoJs.UserId(userId),\n new RustSdkCryptoJs.DeviceId(deviceId),\n storeHandle,\n logger,\n caCertsPem,\n );\n\n // A final migration step, now that we have an OlmMachine.\n if (legacyCryptoStore) {\n await migrateRoomSettingsFromLegacyCrypto({\n logger,\n legacyStore: legacyCryptoStore,\n olmMachine,\n });\n }\n\n // Disable room key requests, per https://github.com/vector-im/element-web/issues/26524.\n olmMachine.roomKeyRequestsEnabled = false;\n\n const rustCrypto = new RustCrypto(\n logger,\n olmMachine,\n http,\n userId,\n deviceId,\n secretStorage,\n cryptoCallbacks,\n enableEncryptedStateEvents,\n );\n\n olmMachine.registerRoomKeyUpdatedCallback((sessions: RustSdkCryptoJs.RoomKeyInfo[]) =>\n rustCrypto.onRoomKeysUpdated(sessions),\n );\n olmMachine.registerRoomKeysWithheldCallback((withheld: RustSdkCryptoJs.RoomKeyWithheldInfo[]) =>\n rustCrypto.onRoomKeysWithheld(withheld),\n );\n olmMachine.registerUserIdentityUpdatedCallback((userId: RustSdkCryptoJs.UserId) =>\n rustCrypto.onUserIdentityUpdated(userId),\n );\n olmMachine.registerDevicesUpdatedCallback((userIds: string[]) => rustCrypto.onDevicesUpdated(userIds));\n\n // Check if there are any key backup secrets pending processing. There may be multiple secrets to process if several devices have gossiped them.\n // The `registerReceiveSecretCallback` function will only be triggered for new secrets. If the client is restarted before processing them, the secrets will need to be manually handled.\n void rustCrypto.checkSecrets(\"m.megolm_backup.v1\");\n\n // Register a callback to be notified when a new secret is received, as for now only the key backup secret is supported (the cross signing secrets are handled automatically by the OlmMachine)\n olmMachine.registerReceiveSecretCallback((name: string, _value: string) =>\n // Instead of directly checking the secret value, we poll the inbox to get all values for that secret type.\n // Once we have all the values, we can safely clear the secret inbox.\n rustCrypto.checkSecrets(name),\n );\n\n // Tell the OlmMachine to think about its outgoing requests before we hand control back to the application.\n //\n // This is primarily a fudge to get it to correctly populate the `users_for_key_query` list, so that future\n // calls to getIdentity (etc) block until the key queries are performed.\n //\n // Note that we don't actually need to *make* any requests here; it is sufficient to tell the Rust side to think\n // about them.\n //\n // XXX: find a less hacky way to do this.\n await olmMachine.outgoingRequests();\n\n if (legacyCryptoStore && (await legacyCryptoStore.containsData())) {\n const migrationState = await legacyCryptoStore.getMigrationState();\n if (migrationState < MigrationState.INITIAL_OWN_KEY_QUERY_DONE) {\n logger.debug(`Performing initial key query after migration`);\n // We need to do an initial keys query so that the rust stack can properly update trust of\n // the user device and identity from the migrated private keys.\n // If not done, there is a short period where the own device/identity trust will be undefined after migration.\n let initialKeyQueryDone = false;\n while (!initialKeyQueryDone) {\n try {\n await rustCrypto.userHasCrossSigningKeys(userId);\n initialKeyQueryDone = true;\n } catch (e) {\n // If the initial key query fails, we retry until it succeeds.\n logger.error(\"Failed to check for cross-signing keys after migration, retrying\", e);\n }\n }\n\n // If the private master cross-signing key was not cached in the legacy store, the rust session\n // will not be able to establish the trust of the user identity.\n // That means that after migration the session could revert to unverified.\n // In order to avoid asking the users to re-verify their sessions, we need to migrate the legacy local trust\n // (if the legacy session was already verified) to the new session.\n await migrateLegacyLocalTrustIfNeeded({ legacyCryptoStore, rustCrypto, logger });\n\n await legacyCryptoStore.setMigrationState(MigrationState.INITIAL_OWN_KEY_QUERY_DONE);\n }\n }\n\n // If we have any recently-joined rooms, see if we have a pending key bundle for them.\n for (const pendingDetails of await olmMachine.getAllRoomsPendingKeyBundles()) {\n const roomId = pendingDetails.roomId.toString();\n if (Date.now() - pendingDetails.inviteAcceptedAtMillis <= MAX_INVITE_ACCEPTANCE_MS_FOR_KEY_BUNDLE) {\n logger.info(\n `Checking for pending key bundle for recently-joined room ${roomId} (joined ${new Date(pendingDetails.inviteAcceptedAtMillis).toISOString()})`,\n );\n await rustCrypto.maybeAcceptKeyBundle(roomId, pendingDetails.inviterId.toString());\n } else {\n logger.info(\n `Clearing pending-key-bundle flag for room ${roomId} (too old: joined ${new Date(pendingDetails.inviteAcceptedAtMillis).toISOString()})`,\n );\n await olmMachine.clearRoomPendingKey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AM,CAAC,IAAI,CACP,4DAA4D,MAAM,YAAY,IAAI,IAAI,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC,WAAW,CAAC,CAAC,GAC/I,CAAC;MACD,MAAM,UAAU,CAAC,oBAAoB,CAAC,MAAM,EAAE,cAAc,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtF,CAAC,MAAM;MACH,MAAM,CAAC,IAAI,CACP,6CAA6C,MAAM,qBAAqB,IAAI,IAAI,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC,WAAW,CAAC,CAAC,GACzI,CAAC;MACD,MAAM,UAAU,CAAC,yBAAyB,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAClF;EACJ;EAEA,OAAO,UAAU;AACrB","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/rust-crypto/index.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 * as RustSdkCryptoJs from \"@matrix-org/matrix-sdk-crypto-wasm\";\nimport { StoreHandle } from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport { MAX_INVITE_ACCEPTANCE_MS_FOR_KEY_BUNDLE, RustCrypto } from \"./rust-crypto.ts\";\nimport { type IHttpOpts, type MatrixHttpApi } from \"../http-api/index.ts\";\nimport { type ServerSideSecretStorage } from \"../secret-storage.ts\";\nimport { type Logger } from \"../logger.ts\";\nimport { type CryptoStore, MigrationState } from \"../crypto/store/base.ts\";\nimport {\n migrateFromLegacyCrypto,\n migrateLegacyLocalTrustIfNeeded,\n migrateRoomSettingsFromLegacyCrypto,\n} from \"./libolm_migration.ts\";\nimport { type CryptoCallbacks } from \"../crypto-api/index.ts\";\n\n/**\n * The arguments used to initialise RustCrypto, passed in to initRustCrypto.\n *\n * @internal\n */\nexport interface InitRustCryptoArgs {\n /** A `Logger` instance that will be used for debug output. */\n logger: Logger;\n\n /**\n * Low-level HTTP interface: used to make outgoing requests required by the rust SDK.\n * We expect it to set the access token, etc.\n */\n http: MatrixHttpApi<IHttpOpts & { onlyData: true }>;\n\n /** The local user's User ID. */\n userId: string;\n\n /** The local user's Device ID. */\n deviceId: string;\n\n /** Interface to server-side secret storage. */\n secretStorage: ServerSideSecretStorage;\n\n /** Crypto callbacks provided by the application. */\n cryptoCallbacks: CryptoCallbacks;\n\n /**\n * The prefix to use on the indexeddbs created by rust-crypto.\n * If `null`, a memory store will be used.\n */\n storePrefix: string | null;\n\n /**\n * A passphrase to use to encrypt the indexeddb created by rust-crypto.\n *\n * Ignored if `storePrefix` is null, or `storeKey` is set. If neither this nor `storeKey` is set\n * (and `storePrefix` is not null), the indexeddb will be unencrypted.\n */\n storePassphrase?: string;\n\n /**\n * A key to use to encrypt the indexeddb created by rust-crypto.\n *\n * Ignored if `storePrefix` is null. Otherwise, if it is set, it must be a 32-byte cryptographic key, which\n * will be used to encrypt the indexeddb. See also `storePassphrase`.\n */\n storeKey?: Uint8Array;\n\n /** If defined, we will check if any data needs migrating from this store to the rust store. */\n legacyCryptoStore?: CryptoStore;\n\n /** The pickle key for `legacyCryptoStore` */\n legacyPickleKey?: string;\n\n /**\n * A callback which will receive progress updates on migration from `legacyCryptoStore`.\n *\n * Called with (-1, -1) to mark the end of migration.\n */\n legacyMigrationProgressListener?: (progress: number, total: number) => void;\n\n /**\n * Whether to enable support for encrypting state events.\n */\n enableEncryptedStateEvents?: boolean;\n\n /**\n * Optional PEM-formatted string that provides CA certificates. These will\n * be used to check X.509 signatures on user identities. Any user identity\n * that has a valid signature according to the supplied CAs will be\n * considered verified, without any manual verification taking place.\n */\n caCertsPem?: string;\n\n /**\n * Optional async function for signing some data with an X.509 certificate.\n * Used to sign the user's identity so compatible clients will recognise\n * this user as verified without manual verification taking place. If you\n * supply this you must also supply {@link InitRustCryptoArgs#x509Validity}.\n */\n x509Signer?: (item: Uint8Array) => Promise<{\n signature_bytes: Uint8Array;\n certificate_chain: string;\n signature_scheme: \"RsaPssSha512\";\n }>;\n\n /**\n * Optional function returning the validity period of the X.509 certificate\n * used for signing, as the number of milliseconds since the Unix epoch. If\n * you supply this you must also supply {@link InitRustCryptoArgs#x509Signer}.\n */\n x509Validity?: () => number;\n}\n\n/**\n * Create a new `RustCrypto` implementation\n *\n * @param args - InitRustCryptoArgs\n * @internal\n */\nexport async function initRustCrypto(args: InitRustCryptoArgs): Promise<RustCrypto> {\n const { logger } = args;\n\n // initialise the rust matrix-sdk-crypto-wasm, if it hasn't already been done\n logger.debug(\"Initialising Rust crypto-sdk WASM artifact\");\n await RustSdkCryptoJs.initAsync();\n\n logger.debug(\"Opening Rust CryptoStore\");\n let storeHandle;\n if (args.storePrefix) {\n if (args.storeKey) {\n storeHandle = await StoreHandle.openWithKey(args.storePrefix, args.storeKey, logger);\n } else {\n storeHandle = await StoreHandle.open(args.storePrefix, args.storePassphrase, logger);\n }\n } else {\n storeHandle = await StoreHandle.open(null, null, logger);\n }\n\n if (args.legacyCryptoStore) {\n // We have a legacy crypto store, which we may need to migrate from.\n await migrateFromLegacyCrypto({\n legacyStore: args.legacyCryptoStore,\n storeHandle,\n ...args,\n });\n }\n\n const rustCrypto = await initOlmMachine(args, storeHandle);\n\n storeHandle.free();\n\n logger.debug(\"Completed rust crypto-sdk setup\");\n return rustCrypto;\n}\n\nasync function initOlmMachine(\n {\n logger,\n http,\n userId,\n deviceId,\n secretStorage,\n cryptoCallbacks,\n legacyCryptoStore,\n enableEncryptedStateEvents,\n caCertsPem,\n x509Signer,\n x509Validity,\n }: InitRustCryptoArgs,\n storeHandle: StoreHandle,\n): Promise<RustCrypto> {\n logger.debug(\"Init OlmMachine\");\n\n const olmMachine = await RustSdkCryptoJs.OlmMachine.initFromStore(\n new RustSdkCryptoJs.UserId(userId),\n new RustSdkCryptoJs.DeviceId(deviceId),\n storeHandle,\n logger,\n caCertsPem,\n x509Signer,\n x509Validity,\n );\n\n // A final migration step, now that we have an OlmMachine.\n if (legacyCryptoStore) {\n await migrateRoomSettingsFromLegacyCrypto({\n logger,\n legacyStore: legacyCryptoStore,\n olmMachine,\n });\n }\n\n // Disable room key requests, per https://github.com/vector-im/element-web/issues/26524.\n olmMachine.roomKeyRequestsEnabled = false;\n\n const rustCrypto = new RustCrypto(\n logger,\n olmMachine,\n http,\n userId,\n deviceId,\n secretStorage,\n cryptoCallbacks,\n enableEncryptedStateEvents,\n );\n\n olmMachine.registerRoomKeyUpdatedCallback((sessions: RustSdkCryptoJs.RoomKeyInfo[]) =>\n rustCrypto.onRoomKeysUpdated(sessions),\n );\n olmMachine.registerRoomKeysWithheldCallback((withheld: RustSdkCryptoJs.RoomKeyWithheldInfo[]) =>\n rustCrypto.onRoomKeysWithheld(withheld),\n );\n olmMachine.registerUserIdentityUpdatedCallback((userId: RustSdkCryptoJs.UserId) =>\n rustCrypto.onUserIdentityUpdated(userId),\n );\n olmMachine.registerDevicesUpdatedCallback((userIds: string[]) => rustCrypto.onDevicesUpdated(userIds));\n\n // Check if there are any key backup secrets pending processing. There may be multiple secrets to process if several devices have gossiped them.\n // The `registerReceiveSecretCallback` function will only be triggered for new secrets. If the client is restarted before processing them, the secrets will need to be manually handled.\n void rustCrypto.checkSecrets(\"m.megolm_backup.v1\");\n\n // Register a callback to be notified when a new secret is received, as for now only the key backup secret is supported (the cross signing secrets are handled automatically by the OlmMachine)\n olmMachine.registerReceiveSecretCallback((name: string, _value: string) =>\n // Instead of directly checking the secret value, we poll the inbox to get all values for that secret type.\n // Once we have all the values, we can safely clear the secret inbox.\n rustCrypto.checkSecrets(name),\n );\n\n // Tell the OlmMachine to think about its outgoing requests before we hand control back to the application.\n //\n // This is primarily a fudge to get it to correctly populate the `users_for_key_query` list, so that future\n // calls to getIdentity (etc) block until the key queries are performed.\n //\n // Note that we don't actually need to *make* any requests here; it is sufficient to tell the Rust side to think\n // about them.\n //\n // XXX: find a less hacky way to do this.\n await olmMachine.outgoingRequests();\n\n if (legacyCryptoStore && (await legacyCryptoStore.containsData())) {\n const migrationState = await legacyCryptoStore.getMigrationState();\n if (migrationState < MigrationState.INITIAL_OWN_KEY_QUERY_DONE) {\n logger.debug(`Performing initial key query after migration`);\n // We need to do an initial keys query so that the rust stack can properly update trust of\n // the user device and identity from the migrated private keys.\n // If not done, there is a short period where the own device/identity trust will be undefined after migration.\n let initialKeyQueryDone = false;\n while (!initialKeyQueryDone) {\n try {\n await rustCrypto.userHasCrossSigningKeys(userId);\n initialKeyQueryDone = true;\n } catch (e) {\n // If the initial key query fails, we retry until it succeeds.\n logger.error(\"Failed to check for cross-signing keys after migration, retrying\", e);\n }\n }\n\n // If the private master cross-signing key was not cached in the legacy store, the rust session\n // will not be able to establish the trust of the user identity.\n // That means that after migration the session could revert to unverified.\n // In order to avoid asking the users to re-verify their sessions, we need to migrate the legacy local trust\n // (if the legacy session was already verified) to the new session.\n await migrateLegacyLocalTrustIfNeeded({ legacyCryptoStore, rustCrypto, logger });\n\n await legacyCryptoStore.setMigrationState(MigrationState.INITIAL_OWN_KEY_QUERY_DONE);\n }\n }\n\n // If we have any recently-joined rooms, see if we have a pending key bundle for them.\n for (const pendingDetails of await olmMachine.getAllRoomsPendingKeyBundles()) {\n const roomId = pendingDetails.roomId.toString();\n if (Date.now() - pendingDetails.inviteAcceptedAtMillis <= MAX_INVITE_ACCEPTANCE_MS_FOR_KEY_BUNDLE) {\n logger.info(\n `Checking for pending key bundle for recently-joined room ${roomId} (joined ${new Date(pendingDetails.inviteAcceptedAtMillis).toISOString()})`,\n );\n await rustCrypto.maybeAcceptKeyBundle(roomId, pendingDetails.inviterId.toString());\n } else {\n logger.info(\n `Clearing pending-key-bundle flag for room ${roomId} (too old: joined ${new Date(pendingDetails.inviteAcceptedAtMillis).toISOString()})`,\n );\n await olmMachine.clearRoomPendingKeyBundle(new RustSdkCryptoJs.RoomId(roomId));\n }\n }\n\n return rustCrypto;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAK,eAAe,MAAM,oCAAoC;AACrE,SAAS,WAAW,QAAQ,oCAAoC;AAEhE,SAAS,uCAAuC,EAAE,UAAU,QAAQ,kBAAkB;AAItF,SAA2B,cAAc,QAAQ,yBAAyB;AAC1E,SACI,uBAAuB,EACvB,+BAA+B,EAC/B,mCAAmC,QAChC,uBAAuB;;AAG9B;AACA;AACA;AACA;AACA;;AA2FA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAe,cAAc,CAAC,IAAwB,EAAuB;EAChF,MAAM;IAAE;EAAO,CAAC,GAAG,IAAI;;EAEvB;EACA,MAAM,CAAC,KAAK,CAAC,4CAA4C,CAAC;EAC1D,MAAM,eAAe,CAAC,SAAS,CAAC,CAAC;EAEjC,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC;EACxC,IAAI,WAAW;EACf,IAAI,IAAI,CAAC,WAAW,EAAE;IAClB,IAAI,IAAI,CAAC,QAAQ,EAAE;MACf,WAAW,GAAG,MAAM,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC;IACxF,CAAC,MAAM;MACH,WAAW,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC;IACxF;EACJ,CAAC,MAAM;IACH,WAAW,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC;EAC5D;EAEA,IAAI,IAAI,CAAC,iBAAiB,EAAE;IACxB;IACA,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CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/C,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,cAAc,CAAC,sBAAsB,IAAI,uCAAuC,EAAE;MAC/F,MAAM,CAAC,IAAI,CACP,4DAA4D,MAAM,YAAY,IAAI,IAAI,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC,WAAW,CAAC,CAAC,GAC/I,CAAC;MACD,MAAM,UAAU,CAAC,oBAAoB,CAAC,MAAM,EAAE,cAAc,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtF,CAAC,MAAM;MACH,MAAM,CAAC,IAAI,CACP,6CAA6C,MAAM,qBAAqB,IAAI,IAAI,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC,WAAW,CAAC,CAAC,GACzI,CAAC;MACD,MAAM,UAAU,CAAC,yBAAyB,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAClF;EACJ;EAEA,OAAO,UAAU;AACrB","ignoreList":[]}
@@ -1,11 +1,11 @@
1
1
  import * as RustSdkCryptoJs from "@matrix-org/matrix-sdk-crypto-wasm";
2
2
  import type { IMegolmSessionData } from "../@types/crypto.ts";
3
- import { type IDeviceLists, type IToDeviceEvent, type ReceivedToDeviceMessage } from "../sync-accumulator.ts";
3
+ import { type ReceivedToDeviceMessage } from "../sync-accumulator.ts";
4
4
  import type { ToDeviceBatch, ToDevicePayload } from "../models/ToDeviceMessage.ts";
5
5
  import { type MatrixEvent } from "../models/event.ts";
6
6
  import { type Room } from "../models/room.ts";
7
7
  import { type RoomMember } from "../models/room-member.ts";
8
- import { type BackupDecryptor, type CryptoBackend, type EventDecryptionResult, type OnSyncCompletedData } from "../common-crypto/CryptoBackend.ts";
8
+ import { type BackupDecryptor, type CryptoBackend, type EventDecryptionResult, type OnSyncCompletedData, type SyncCryptoChanges } from "../common-crypto/CryptoBackend.ts";
9
9
  import { type Logger } from "../logger.ts";
10
10
  import { type IHttpOpts, type MatrixHttpApi } from "../http-api/index.ts";
11
11
  import { type BackupTrustInfo, type BootstrapCrossSigningOpts, type CreateSecretStorageOpts, type CrossSigningKeys, CrossSigningKey, type CrossSigningStatus, type CryptoApi, type CryptoCallbacks, CryptoEvent, type CryptoEventHandlerMap, type DeviceIsolationMode, DeviceVerificationStatus, type EventEncryptionInfo, type GeneratedSecretStorageKey, type ImportRoomKeysOpts, type KeyBackupCheck, type KeyBackupInfo, type KeyBackupRestoreOpts, type KeyBackupRestoreResult, type OwnDeviceKeys, type SecretStorageStatus, type StartDehydrationOpts, UserVerificationStatus, type VerificationRequest } from "../crypto-api/index.ts";
@@ -435,32 +435,12 @@ export declare class RustCrypto extends TypedEventEmitter<RustCryptoEvents, Cryp
435
435
  */
436
436
  shareRoomHistoryWithUser(roomId: string, userId: string): Promise<void>;
437
437
  /**
438
- * Apply sync changes to the olm machine
439
- * @param events - the received to-device messages
440
- * @param oneTimeKeysCounts - the received one time key counts
441
- * @param unusedFallbackKeys - the received unused fallback keys
442
- * @param devices - the received device list updates
443
- * @returns A list of processed to-device messages.
444
- */
445
- private receiveSyncChanges;
446
- /** called by the sync loop to preprocess incoming to-device messages
447
- *
448
- * @param events - the received to-device messages
449
- * @returns A list of preprocessed to-device messages.
450
- */
451
- preprocessToDeviceMessages(events: IToDeviceEvent[]): Promise<ReceivedToDeviceMessage[]>;
452
- /** called by the sync loop to process one time key counts and unused fallback keys
453
- *
454
- * @param oneTimeKeysCounts - the received one time key counts
455
- * @param unusedFallbackKeys - the received unused fallback keys
456
- */
457
- processKeyCounts(oneTimeKeysCounts?: Record<string, number>, unusedFallbackKeys?: string[]): Promise<void>;
458
- /** called by the sync loop to process the notification that device lists have
459
- * been changed.
438
+ * Implementation of {@link SyncCryptoCallbacks.processSyncChanges}.
460
439
  *
461
- * @param deviceLists - device_lists field from /sync
440
+ * Passes all of the encryption-relevant data from a sync response to the OlmMachine in a single call, and
441
+ * post-processes the resulting to-device messages.
462
442
  */
463
- processDeviceLists(deviceLists: IDeviceLists): Promise<void>;
443
+ processSyncChanges({ toDeviceEvents, deviceLists, oneTimeKeysCounts, unusedFallbackKeys, useMsc4186, }: SyncCryptoChanges): Promise<ReceivedToDeviceMessage[]>;
464
444
  /** called by the sync loop on m.room.encryption events
465
445
  *
466
446
  * @param room - in which the event was received
@@ -1 +1 @@
1
- {"version":3,"file":"rust-crypto.d.ts","sourceRoot":"","sources":["../../src/rust-crypto/rust-crypto.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,eAAe,MAAM,oCAAoC,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,KAAK,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAC9G,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EACH,KAAK,eAAe,EACpB,KAAK,aAAa,EAElB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAU,MAAM,sBAAsB,CAAC;AAKlF,OAAO,EAEH,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,eAAe,EAEf,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,WAAW,EACX,KAAK,qBAAqB,EAI1B,KAAK,mBAAmB,EAExB,wBAAwB,EAExB,KAAK,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