matrix-js-sdk 41.9.0 → 42.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.
Files changed (240) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/lib/@types/auth.d.ts +0 -5
  3. package/lib/@types/auth.d.ts.map +1 -1
  4. package/lib/@types/auth.js +0 -6
  5. package/lib/@types/auth.js.map +1 -1
  6. package/lib/@types/type-guards.d.ts +43 -0
  7. package/lib/@types/type-guards.d.ts.map +1 -0
  8. package/lib/@types/type-guards.js +104 -0
  9. package/lib/@types/type-guards.js.map +1 -0
  10. package/lib/NamespacedValue.d.ts.map +1 -1
  11. package/lib/ReEmitter.d.ts.map +1 -1
  12. package/lib/ToDeviceMessageQueue.d.ts.map +1 -1
  13. package/lib/autodiscovery.d.ts.map +1 -1
  14. package/lib/capabilityPoller.d.ts.map +1 -1
  15. package/lib/client.d.ts +4 -7
  16. package/lib/client.d.ts.map +1 -1
  17. package/lib/client.js +10 -22
  18. package/lib/client.js.map +1 -1
  19. package/lib/common-crypto/CryptoBackend.d.ts.map +1 -1
  20. package/lib/content-helpers.d.ts.map +1 -1
  21. package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts.map +1 -1
  22. package/lib/crypto/store/indexeddb-crypto-store.d.ts.map +1 -1
  23. package/lib/crypto/store/localStorage-crypto-store.d.ts.map +1 -1
  24. package/lib/crypto/store/memory-crypto-store.d.ts.map +1 -1
  25. package/lib/crypto-api/index.d.ts +1 -1
  26. package/lib/crypto-api/index.d.ts.map +1 -1
  27. package/lib/crypto-api/index.js.map +1 -1
  28. package/lib/crypto-api/verification.d.ts +23 -5
  29. package/lib/crypto-api/verification.d.ts.map +1 -1
  30. package/lib/crypto-api/verification.js.map +1 -1
  31. package/lib/embedded.d.ts.map +1 -1
  32. package/lib/errors.d.ts.map +1 -1
  33. package/lib/extensible_events_v1/ExtensibleEvent.d.ts.map +1 -1
  34. package/lib/extensible_events_v1/InvalidEventError.d.ts.map +1 -1
  35. package/lib/extensible_events_v1/MessageEvent.d.ts.map +1 -1
  36. package/lib/extensible_events_v1/PollEndEvent.d.ts.map +1 -1
  37. package/lib/extensible_events_v1/PollResponseEvent.d.ts.map +1 -1
  38. package/lib/extensible_events_v1/PollStartEvent.d.ts.map +1 -1
  39. package/lib/filter-component.d.ts.map +1 -1
  40. package/lib/filter.d.ts.map +1 -1
  41. package/lib/http-api/errors.d.ts.map +1 -1
  42. package/lib/http-api/fetch.d.ts +1 -1
  43. package/lib/http-api/fetch.d.ts.map +1 -1
  44. package/lib/http-api/fetch.js.map +1 -1
  45. package/lib/http-api/index.d.ts +1 -7
  46. package/lib/http-api/index.d.ts.map +1 -1
  47. package/lib/http-api/index.js +0 -15
  48. package/lib/http-api/index.js.map +1 -1
  49. package/lib/http-api/interface.d.ts +0 -9
  50. package/lib/http-api/interface.d.ts.map +1 -1
  51. package/lib/http-api/interface.js +0 -2
  52. package/lib/http-api/interface.js.map +1 -1
  53. package/lib/http-api/refresh.d.ts.map +1 -1
  54. package/lib/index.d.ts.map +1 -1
  55. package/lib/interactive-auth.d.ts.map +1 -1
  56. package/lib/logger.d.ts.map +1 -1
  57. package/lib/matrix.d.ts +1 -1
  58. package/lib/matrix.d.ts.map +1 -1
  59. package/lib/matrix.js +1 -1
  60. package/lib/matrix.js.map +1 -1
  61. package/lib/matrixrtc/CallMembership.d.ts.map +1 -1
  62. package/lib/matrixrtc/LivekitTransport.d.ts.map +1 -1
  63. package/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -1
  64. package/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +1 -1
  65. package/lib/matrixrtc/MembershipManager.d.ts.map +1 -1
  66. package/lib/matrixrtc/MembershipManagerActionScheduler.d.ts.map +1 -1
  67. package/lib/matrixrtc/RTCEncryptionManager.d.ts.map +1 -1
  68. package/lib/matrixrtc/ToDeviceKeyTransport.d.ts.map +1 -1
  69. package/lib/matrixrtc/membershipData/common.d.ts.map +1 -1
  70. package/lib/matrixrtc/membershipData/rtc.d.ts.map +1 -1
  71. package/lib/matrixrtc/membershipData/session.d.ts.map +1 -1
  72. package/lib/matrixrtc/types.d.ts.map +1 -1
  73. package/lib/matrixrtc/utils.d.ts.map +1 -1
  74. package/lib/models/MSC3089Branch.d.ts.map +1 -1
  75. package/lib/models/MSC3089TreeSpace.d.ts.map +1 -1
  76. package/lib/models/beacon.d.ts.map +1 -1
  77. package/lib/models/device.d.ts.map +1 -1
  78. package/lib/models/event-context.d.ts.map +1 -1
  79. package/lib/models/event-timeline-set.d.ts.map +1 -1
  80. package/lib/models/event-timeline.d.ts.map +1 -1
  81. package/lib/models/event.d.ts.map +1 -1
  82. package/lib/models/invites-ignorer.d.ts.map +1 -1
  83. package/lib/models/poll.d.ts.map +1 -1
  84. package/lib/models/read-receipt.d.ts.map +1 -1
  85. package/lib/models/related-relations.d.ts.map +1 -1
  86. package/lib/models/relations-container.d.ts.map +1 -1
  87. package/lib/models/relations.d.ts.map +1 -1
  88. package/lib/models/room-member.d.ts.map +1 -1
  89. package/lib/models/room-receipts.d.ts.map +1 -1
  90. package/lib/models/room-retention.d.ts.map +1 -1
  91. package/lib/models/room-state.d.ts.map +1 -1
  92. package/lib/models/room-sticky-events.d.ts.map +1 -1
  93. package/lib/models/room-summary.d.ts.map +1 -1
  94. package/lib/models/room.d.ts.map +1 -1
  95. package/lib/models/search-result.d.ts.map +1 -1
  96. package/lib/models/thread.d.ts.map +1 -1
  97. package/lib/models/typed-event-emitter.d.ts.map +1 -1
  98. package/lib/models/user.d.ts.map +1 -1
  99. package/lib/oauth/authorize.d.ts +133 -0
  100. package/lib/oauth/authorize.d.ts.map +1 -0
  101. package/lib/oauth/authorize.js +193 -0
  102. package/lib/oauth/authorize.js.map +1 -0
  103. package/lib/oauth/discover.d.ts +58 -0
  104. package/lib/oauth/discover.d.ts.map +1 -0
  105. package/lib/oauth/discover.js +35 -0
  106. package/lib/oauth/discover.js.map +1 -0
  107. package/lib/oauth/error.d.ts +19 -0
  108. package/lib/oauth/error.d.ts.map +1 -0
  109. package/lib/oauth/error.js +36 -0
  110. package/lib/oauth/error.js.map +1 -0
  111. package/lib/oauth/index.d.ts +87 -0
  112. package/lib/oauth/index.d.ts.map +1 -0
  113. package/lib/oauth/index.js +234 -0
  114. package/lib/oauth/index.js.map +1 -0
  115. package/lib/oauth/register.d.ts +136 -0
  116. package/lib/oauth/register.d.ts.map +1 -0
  117. package/lib/oauth/register.js +73 -0
  118. package/lib/oauth/register.js.map +1 -0
  119. package/lib/oauth/tokenRefresher.d.ts +21 -0
  120. package/lib/oauth/tokenRefresher.d.ts.map +1 -0
  121. package/lib/oauth/tokenRefresher.js +68 -0
  122. package/lib/oauth/tokenRefresher.js.map +1 -0
  123. package/lib/pushprocessor.d.ts.map +1 -1
  124. package/lib/receipt-accumulator.d.ts.map +1 -1
  125. package/lib/rendezvous/MSC4108SignInWithQR.d.ts +7 -7
  126. package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +1 -1
  127. package/lib/rendezvous/MSC4108SignInWithQR.js +11 -11
  128. package/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -1
  129. package/lib/rendezvous/RendezvousError.d.ts.map +1 -1
  130. package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +1 -1
  131. package/lib/rendezvous/index.d.ts.map +1 -1
  132. package/lib/rendezvous/index.js.map +1 -1
  133. package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +1 -1
  134. package/lib/retentionPolicy.d.ts.map +1 -1
  135. package/lib/room-hierarchy.d.ts.map +1 -1
  136. package/lib/rust-crypto/CrossSigningIdentity.d.ts.map +1 -1
  137. package/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +1 -1
  138. package/lib/rust-crypto/DehydratedDeviceManager.js +11 -13
  139. package/lib/rust-crypto/DehydratedDeviceManager.js.map +1 -1
  140. package/lib/rust-crypto/KeyClaimManager.d.ts.map +1 -1
  141. package/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +1 -1
  142. package/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +1 -1
  143. package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +1 -1
  144. package/lib/rust-crypto/RoomEncryptor.d.ts.map +1 -1
  145. package/lib/rust-crypto/backup.d.ts.map +1 -1
  146. package/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
  147. package/lib/rust-crypto/verification.d.ts.map +1 -1
  148. package/lib/scheduler.d.ts.map +1 -1
  149. package/lib/secret-storage.d.ts.map +1 -1
  150. package/lib/serverCapabilities.d.ts.map +1 -1
  151. package/lib/sliding-sync-sdk.d.ts.map +1 -1
  152. package/lib/sliding-sync.d.ts.map +1 -1
  153. package/lib/store/indexeddb-local-backend.d.ts.map +1 -1
  154. package/lib/store/indexeddb-remote-backend.d.ts.map +1 -1
  155. package/lib/store/indexeddb-store-worker.d.ts.map +1 -1
  156. package/lib/store/indexeddb.d.ts.map +1 -1
  157. package/lib/store/memory.d.ts.map +1 -1
  158. package/lib/store/stub.d.ts.map +1 -1
  159. package/lib/sync-accumulator.d.ts.map +1 -1
  160. package/lib/sync.d.ts.map +1 -1
  161. package/lib/testing.d.ts +2 -10
  162. package/lib/testing.d.ts.map +1 -1
  163. package/lib/testing.js +4 -19
  164. package/lib/testing.js.map +1 -1
  165. package/lib/timeline-window.d.ts.map +1 -1
  166. package/lib/utils.d.ts.map +1 -1
  167. package/lib/webrtc/call.d.ts.map +1 -1
  168. package/lib/webrtc/callEventHandler.d.ts.map +1 -1
  169. package/lib/webrtc/callFeed.d.ts.map +1 -1
  170. package/lib/webrtc/groupCall.d.ts.map +1 -1
  171. package/lib/webrtc/groupCallEventHandler.d.ts.map +1 -1
  172. package/lib/webrtc/mediaHandler.d.ts.map +1 -1
  173. package/lib/webrtc/stats/callFeedStatsReporter.d.ts.map +1 -1
  174. package/lib/webrtc/stats/callStatsReportGatherer.d.ts.map +1 -1
  175. package/lib/webrtc/stats/connectionStatsBuilder.d.ts.map +1 -1
  176. package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts.map +1 -1
  177. package/lib/webrtc/stats/groupCallStats.d.ts.map +1 -1
  178. package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts.map +1 -1
  179. package/lib/webrtc/stats/media/mediaTrackHandler.d.ts.map +1 -1
  180. package/lib/webrtc/stats/media/mediaTrackStats.d.ts.map +1 -1
  181. package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts.map +1 -1
  182. package/lib/webrtc/stats/statsReportEmitter.d.ts.map +1 -1
  183. package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts.map +1 -1
  184. package/lib/webrtc/stats/trackStatsBuilder.d.ts.map +1 -1
  185. package/lib/webrtc/stats/transportStatsBuilder.d.ts.map +1 -1
  186. package/lib/webrtc/stats/valueFormatter.d.ts.map +1 -1
  187. package/package.json +7 -9
  188. package/src/@types/auth.ts +0 -6
  189. package/src/@types/type-guards.ts +126 -0
  190. package/src/client.ts +13 -29
  191. package/src/crypto-api/index.ts +1 -1
  192. package/src/crypto-api/verification.ts +23 -5
  193. package/src/http-api/fetch.ts +1 -1
  194. package/src/http-api/index.ts +1 -23
  195. package/src/http-api/interface.ts +0 -11
  196. package/src/matrix.ts +1 -1
  197. package/src/oauth/authorize.ts +274 -0
  198. package/src/oauth/discover.ts +102 -0
  199. package/src/{oidc → oauth}/error.ts +8 -7
  200. package/src/oauth/index.ts +297 -0
  201. package/src/oauth/register.ts +166 -0
  202. package/src/oauth/tokenRefresher.ts +77 -0
  203. package/src/rendezvous/MSC4108SignInWithQR.ts +11 -12
  204. package/src/rendezvous/index.ts +2 -2
  205. package/src/rust-crypto/DehydratedDeviceManager.ts +14 -13
  206. package/src/testing.ts +3 -22
  207. package/lib/oidc/authorize.d.ts +0 -157
  208. package/lib/oidc/authorize.d.ts.map +0 -1
  209. package/lib/oidc/authorize.js +0 -365
  210. package/lib/oidc/authorize.js.map +0 -1
  211. package/lib/oidc/discovery.d.ts +0 -22
  212. package/lib/oidc/discovery.d.ts.map +0 -1
  213. package/lib/oidc/discovery.js +0 -65
  214. package/lib/oidc/discovery.js.map +0 -1
  215. package/lib/oidc/error.d.ts +0 -18
  216. package/lib/oidc/error.d.ts.map +0 -1
  217. package/lib/oidc/error.js +0 -35
  218. package/lib/oidc/error.js.map +0 -1
  219. package/lib/oidc/index.d.ts +0 -16
  220. package/lib/oidc/index.d.ts.map +0 -1
  221. package/lib/oidc/index.js +0 -30
  222. package/lib/oidc/index.js.map +0 -1
  223. package/lib/oidc/register.d.ts +0 -70
  224. package/lib/oidc/register.d.ts.map +0 -1
  225. package/lib/oidc/register.js +0 -134
  226. package/lib/oidc/register.js.map +0 -1
  227. package/lib/oidc/tokenRefresher.d.ts +0 -91
  228. package/lib/oidc/tokenRefresher.d.ts.map +0 -1
  229. package/lib/oidc/tokenRefresher.js +0 -173
  230. package/lib/oidc/tokenRefresher.js.map +0 -1
  231. package/lib/oidc/validate.d.ts +0 -78
  232. package/lib/oidc/validate.d.ts.map +0 -1
  233. package/lib/oidc/validate.js +0 -181
  234. package/lib/oidc/validate.js.map +0 -1
  235. package/src/oidc/authorize.ts +0 -431
  236. package/src/oidc/discovery.ts +0 -67
  237. package/src/oidc/index.ts +0 -33
  238. package/src/oidc/register.ts +0 -168
  239. package/src/oidc/tokenRefresher.ts +0 -184
  240. package/src/oidc/validate.ts +0 -265
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","names":[],"sources":["../../src/oauth/register.ts"],"sourcesContent":["/*\nCopyright 2023-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 { type NonEmptyArray } from \"../@types/common.ts\";\nimport { hasRequiredStringProperty, isRecord } from \"../@types/type-guards.ts\";\n\ntype LocalizableKeys = \"client_name\" | \"client_uri\" | \"policy_uri\" | \"tos_uri\" | \"logo_uri\";\n\n/**\n * Request body for dynamic registration as defined by https://spec.matrix.org/v1.18/client-server-api/#client-registration\n */\nexport type OAuthRegistrationRequest = {\n /**\n * Kind of the application.\n *\n * The homeserver MUST support the web and native values to be able to perform redirect URI validation.\n *\n * Defaults to web if omitted.\n */\n application_type?: \"web\" | \"native\";\n /**\n * Human-readable name of the client to be presented to the user.\n *\n * This field can be localized by specifying `client_name#$lang`.\n */\n client_name?: string;\n /**\n * A URL to a valid web page that SHOULD give the user more information about the client.\n *\n * This URL MUST use the https scheme and SHOULD NOT require authentication to access.\n * It MUST NOT use a user or password in the authority component of the URI.\n *\n * The server MAY reject client registrations if this field is invalid or missing.\n *\n * This URI is a common base for all the other URIs in the metadata:\n * those MUST be either on the same host or on a subdomain of the host of the client_uri.\n * The port number, path and query components MAY be different.\n *\n * For example, if the client_uri is https://example.com/,\n * then one of the redirect_uris can be https://example.com/callback or https://app.example.com/callback,\n * but not https://app.com/callback.\n *\n * This field can be localized by specifying `client_uri#$lang`.\n */\n client_uri: string;\n /**\n * Array of the OAuth 2.0 grant types that the client may use.\n *\n * This MUST include:\n *\n * the authorization_code value to use the authorization code grant,\n * the refresh_token value to use the refresh token grant.\n */\n grant_types?: NonEmptyArray<string>;\n /**\n * URL that references a logo for the client.\n *\n * This URL MUST use the https scheme.\n *\n * This field can be localized by specifying `logo_uri#$lang`.\n */\n logo_uri?: string;\n /**\n * URL that points to a human-readable policy document for the client.\n *\n * This URL MUST use the https scheme and SHOULD NOT require authentication to access.\n * It MUST NOT use a user or password in the authority component of the URI.\n *\n * This field can be localized by specifying `policy_uri#$lang`.\n */\n policy_uri?: string;\n /**\n * Array of redirection URIs for use in redirect-based flows.\n *\n * At least one URI is required to use the authorization code grant.\n */\n redirect_uris?: NonEmptyArray<string>;\n /**\n * Array of the OAuth 2.0 response types that the client may use.\n *\n * This MUST include the code value to use the authorization code grant.\n */\n response_types?: NonEmptyArray<string>;\n /**\n * String indicator of the requested authentication method for the token endpoint.\n */\n token_endpoint_auth_method?: string;\n /**\n * URL that points to a human-readable terms of service document for the client.\n *\n * This URL MUST use the https scheme and SHOULD NOT require authentication to access.\n * It MUST NOT use a user or password in the authority component of the URI.\n *\n * This field can be localized by specifying `tos_uri#$lang`.\n */\n tos_uri?: string;\n} & {\n // --- Dynamic Localized Fields (e.g., client_name#es-ES) ---\n [K in `${LocalizableKeys}#${string}`]?: string;\n};\n\n/**\n * The OAuth 2.0 grant types that are defined for Matrix in https://spec.matrix.org/v1.17/client-server-api/#grant-types\n */\nexport enum OAuthGrantType {\n /**\n * As per RFC 6749 section 4.1, the authorization code grant lets the client obtain an access token through a browser redirect.\n *\n * See https://spec.matrix.org/v1.18/client-server-api/#authorization-code-grant\n */\n AuthorizationCode = \"authorization_code\",\n /**\n * As per RFC 6749 section 6, the refresh token grant lets the client exchange a refresh token for an access token.\n *\n * https://spec.matrix.org/v1.18/client-server-api/#refresh-token-grant\n */\n RefreshToken = \"refresh_token\",\n /**\n * As per RFC 8628, the device authorization grant lets clients on devices with limited input capabilities obtain\n * an access token by having the user complete authorization on a separate device with a web browser.\n *\n * See https://spec.matrix.org/v1.18/client-server-api/#device-authorization-grant\n */\n DeviceAuthorization = \"urn:ietf:params:oauth:grant-type:device_code\",\n}\n\n/**\n * Check that URIs have a common base,\n * as per https://spec.matrix.org/v1.18/client-server-api/#redirect-uri-validation\n */\nexport function urlHasCommonBase(base: URL, urlStr?: string): boolean {\n if (!urlStr) return false;\n const url = new URL(urlStr);\n if (url.protocol !== base.protocol) return false;\n if (url.hostname !== base.hostname && !url.hostname.endsWith(`.${base.hostname}`)) return false;\n return true;\n}\n\n/**\n * Response from dynamic registration\n */\ntype RegistrationResponse = {\n client_id: string;\n};\n\n/**\n * Validate the given response matches the format expected for a {@link RegistrationResponse}\n * @param response - the response to validate\n * @throws if the response does not match the expected format\n */\nexport function validateRegistrationResponse(response: unknown): response is RegistrationResponse {\n return isRecord(response) && hasRequiredStringProperty(response, \"client_id\");\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAAS,yBAAyB,EAAE,QAAQ,QAAQ,0BAA0B;;AAI9E;AACA;AACA;;AA2FA;AACA;AACA;AACA,WAAY,cAAc,0BAAd,cAAc;EACtB;AACJ;AACA;AACA;AACA;EALY,cAAc;EAOtB;AACJ;AACA;AACA;AACA;EAXY,cAAc;EAatB;AACJ;AACA;AACA;AACA;AACA;EAlBY,cAAc;EAAA,OAAd,cAAc;AAAA;;AAsB1B;AACA;AACA;AACA;AACA,OAAO,SAAS,gBAAgB,CAAC,IAAS,EAAE,MAAe,EAAW;EAClE,IAAI,CAAC,MAAM,EAAE,OAAO,KAAK;EACzB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC;EAC3B,IAAI,GAAG,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ,EAAE,OAAO,KAAK;EAChD,IAAI,GAAG,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,OAAO,KAAK;EAC/F,OAAO,IAAI;AACf;;AAEA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,4BAA4B,CAAC,QAAiB,EAAoC;EAC9F,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,yBAAyB,CAAC,QAAQ,EAAE,WAAW,CAAC;AACjF","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ import { type AccessTokens, type TokenRefreshFunction } from "../http-api/index.ts";
2
+ import { type OAuth2 } from "./index.ts";
3
+ /**
4
+ * Class responsible for refreshing OAuth2 access tokens
5
+ */
6
+ export declare class TokenRefresher {
7
+ private readonly auth;
8
+ private readonly onRefresh;
9
+ private inflightRefreshRequest?;
10
+ constructor(auth: OAuth2, onRefresh: (tokens: AccessTokens) => Promise<void>);
11
+ /**
12
+ * Attempt token refresh using given refresh token
13
+ * @param refreshToken - refresh token to use in request with token issuer
14
+ * @returns tokens - Promise that resolves with new access and refresh tokens
15
+ * @throws when token refresh fails
16
+ */
17
+ tokenRefreshFunction: TokenRefreshFunction;
18
+ private shouldLogoutOnError;
19
+ private getNewTokens;
20
+ }
21
+ //# sourceMappingURL=tokenRefresher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenRefresher.d.ts","sourceRoot":"","sources":["../../src/oauth/tokenRefresher.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,YAAY,EAAa,KAAK,oBAAoB,EAA2B,MAAM,sBAAsB,CAAC;AACxH,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC;;GAEG;AACH,qBAAa,cAAc;IAInB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAJ9B,OAAO,CAAC,sBAAsB,CAAC,CAAwB;IAEvD,YACqB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,EACnE;IAEJ;;;;;OAKG;IACI,oBAAoB,EAAE,oBAAoB,CAiB/C;IAEF,OAAO,CAAC,mBAAmB;YAKb,YAAY;CAgB7B"}
@@ -0,0 +1,68 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ /*
3
+ Copyright 2023 The Matrix.org Foundation C.I.C.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ */
17
+
18
+ import { HTTPError, TokenRefreshLogoutError } from "../http-api/index.js";
19
+ /**
20
+ * Class responsible for refreshing OAuth2 access tokens
21
+ */
22
+ export class TokenRefresher {
23
+ constructor(auth, onRefresh) {
24
+ _defineProperty(this, "inflightRefreshRequest", void 0);
25
+ /**
26
+ * Attempt token refresh using given refresh token
27
+ * @param refreshToken - refresh token to use in request with token issuer
28
+ * @returns tokens - Promise that resolves with new access and refresh tokens
29
+ * @throws when token refresh fails
30
+ */
31
+ _defineProperty(this, "tokenRefreshFunction", async refreshToken => {
32
+ if (!this.inflightRefreshRequest) {
33
+ this.inflightRefreshRequest = this.getNewTokens(refreshToken);
34
+ }
35
+ try {
36
+ const tokens = await this.inflightRefreshRequest;
37
+ return tokens;
38
+ } catch (e) {
39
+ // If we encounter a 40x error then signal that it should cause a logout by upgrading it to a TokenRefreshLogoutError
40
+ if (e instanceof HTTPError && this.shouldLogoutOnError(e)) {
41
+ throw new TokenRefreshLogoutError(e);
42
+ }
43
+ throw e;
44
+ } finally {
45
+ this.inflightRefreshRequest = undefined;
46
+ }
47
+ });
48
+ this.auth = auth;
49
+ this.onRefresh = onRefresh;
50
+ }
51
+ shouldLogoutOnError(error) {
52
+ // As per https://spec.matrix.org/v1.18/client-server-api/#refresh-token-grant
53
+ return typeof error.httpStatus === "number" && error.httpStatus < 500 && error.httpStatus >= 400;
54
+ }
55
+ async getNewTokens(refreshToken) {
56
+ const requestStart = Date.now();
57
+ const response = await this.auth.performRefreshTokenGrant(refreshToken);
58
+ const tokens = {
59
+ accessToken: response.access_token,
60
+ refreshToken: response.refresh_token,
61
+ // We use the request start time to calculate the expiry time as we don't know when the server received our request
62
+ expiry: response.expires_in ? new Date(requestStart + response.expires_in * 1000) : undefined
63
+ };
64
+ await this.onRefresh(tokens);
65
+ return tokens;
66
+ }
67
+ }
68
+ //# sourceMappingURL=tokenRefresher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenRefresher.js","names":[],"sources":["../../src/oauth/tokenRefresher.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 { type AccessTokens, HTTPError, type TokenRefreshFunction, TokenRefreshLogoutError } from \"../http-api/index.ts\";\nimport { type OAuth2 } from \"./index.ts\";\n\n/**\n * Class responsible for refreshing OAuth2 access tokens\n */\nexport class TokenRefresher {\n private inflightRefreshRequest?: Promise<AccessTokens>;\n\n public constructor(\n private readonly auth: OAuth2,\n private readonly onRefresh: (tokens: AccessTokens) => Promise<void>,\n ) {}\n\n /**\n * Attempt token refresh using given refresh token\n * @param refreshToken - refresh token to use in request with token issuer\n * @returns tokens - Promise that resolves with new access and refresh tokens\n * @throws when token refresh fails\n */\n public tokenRefreshFunction: TokenRefreshFunction = async (refreshToken: string): Promise<AccessTokens> => {\n if (!this.inflightRefreshRequest) {\n this.inflightRefreshRequest = this.getNewTokens(refreshToken);\n }\n\n try {\n const tokens = await this.inflightRefreshRequest;\n return tokens;\n } catch (e) {\n // If we encounter a 40x error then signal that it should cause a logout by upgrading it to a TokenRefreshLogoutError\n if (e instanceof HTTPError && this.shouldLogoutOnError(e)) {\n throw new TokenRefreshLogoutError(e);\n }\n throw e;\n } finally {\n this.inflightRefreshRequest = undefined;\n }\n };\n\n private shouldLogoutOnError(error: HTTPError): boolean {\n // As per https://spec.matrix.org/v1.18/client-server-api/#refresh-token-grant\n return typeof error.httpStatus === \"number\" && error.httpStatus < 500 && error.httpStatus >= 400;\n }\n\n private async getNewTokens(refreshToken: string): Promise<AccessTokens> {\n const requestStart = Date.now();\n\n const response = await this.auth.performRefreshTokenGrant(refreshToken);\n\n const tokens = {\n accessToken: response.access_token,\n refreshToken: response.refresh_token,\n // We use the request start time to calculate the expiry time as we don't know when the server received our request\n expiry: response.expires_in ? new Date(requestStart + response.expires_in * 1000) : undefined,\n } satisfies AccessTokens;\n\n await this.onRefresh(tokens);\n\n return tokens;\n }\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAA4B,SAAS,EAA6B,uBAAuB,QAAQ,sBAAsB;AAGvH;AACA;AACA;AACA,OAAO,MAAM,cAAc,CAAC;EAGjB,WAAW,CACG,IAAY,EACZ,SAAkD,EACrE;IAAA;IAEF;AACJ;AACA;AACA;AACA;AACA;IALI,8CAMoD,MAAO,YAAoB,IAA4B;MACvG,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE;QAC9B,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;MACjE;MAEA,IAAI;QACA,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,sBAAsB;QAChD,OAAO,MAAM;MACjB,CAAC,CAAC,OAAO,CAAC,EAAE;QACR;QACA,IAAI,CAAC,YAAY,SAAS,IAAI,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE;UACvD,MAAM,IAAI,uBAAuB,CAAC,CAAC,CAAC;QACxC;QACA,MAAM,CAAC;MACX,CAAC,SAAS;QACN,IAAI,CAAC,sBAAsB,GAAG,SAAS;MAC3C;IACJ,CAAC;IAAA,KA3BoB,IAAY,GAAZ,IAAY;IAAA,KACZ,SAAkD,GAAlD,SAAkD;EACpE;EA2BK,mBAAmB,CAAC,KAAgB,EAAW;IACnD;IACA,OAAO,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ,IAAI,K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IAAI,CAGvD;IAED;;;;;;OAMG;IACI,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,IAAI,EAAE,YAAY,CAAA;KAAE,GAAG,IAAI,CAa5F;CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"receipt-accumulator.d.ts","sourceRoot":"","sources":["../src/receipt-accumulator.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAY3D;;;;;;;;;;GAUG;AACH,qBAAa,kBAAkB;IAC3B,4DAA4D;IAC5D,OAAO,CAAC,sBAAsB,CAA8C;IAE5E,+EAA+E;IAC/E,OAAO,CAAC,oBAAoB,CAE1B;IAEF;;;OAGG;IACH,OAAO,CAAC,aAAa;IAIrB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAInB;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAIrB;;;;;OAKG;IACH,OAAO,CAAE,WAAW;IAQpB;;;OAGG;IACI,sBAAsB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,SAAS,GAAG,IAAI;IA8DxE;;;;OAIG;IACI,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI;CAgC5E"}
1
+ {"version":3,"file":"receipt-accumulator.d.ts","sourceRoot":"","sources":["../src/receipt-accumulator.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAY3D;;;;;;;;;;GAUG;AACH,qBAAa,kBAAkB;IAC3B,4DAA4D;IAC5D,OAAO,CAAC,sBAAsB,CAA8C;IAE5E,+EAA+E;IAC/E,OAAO,CAAC,oBAAoB,CAE1B;IAEF;;;OAGG;IACH,OAAO,CAAC,aAAa;IAIrB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAInB;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAIrB;;;;;OAKG;IACH,OAAO,CAAE,WAAW;IAQpB;;;OAGG;IACI,sBAAsB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,SAAS,GAAG,IAAI,CA4DvE;IAED;;;;OAIG;IACI,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CA+BxE;CACJ"}
@@ -1,7 +1,7 @@
1
1
  import { ClientRendezvousFailureReason, MSC4108FailureReason, type RendezvousFailureListener } from "./index.ts";
2
2
  import { type MatrixClient } from "../client.ts";
3
3
  import { type MSC4108SecureChannel } from "./channels/MSC4108SecureChannel.ts";
4
- import { type DeviceAccessTokenResponse, type ValidatedAuthMetadata } from "../oidc/index.ts";
4
+ import { type DeviceAccessTokenResponse, type ValidatedAuthMetadata } from "../oauth/index.ts";
5
5
  import { type CryptoApi } from "../crypto-api/index.ts";
6
6
  /**
7
7
  * Enum representing the payload types transmissible over [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)
@@ -30,7 +30,7 @@ interface SecretsPayload extends MSC4108Payload, Awaited<ReturnType<NonNullable<
30
30
  }
31
31
  /**
32
32
  * Prototype of the unstable [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)
33
- * sign in with QR + OIDC flow.
33
+ * sign in with QR + OAuth2 flow.
34
34
  * @experimental Note that this is UNSTABLE and may have breaking changes without notice.
35
35
  */
36
36
  export declare class MSC4108SignInWithQR {
@@ -71,7 +71,7 @@ export declare class MSC4108SignInWithQR {
71
71
  */
72
72
  get isNewDevice(): boolean;
73
73
  /**
74
- * The first step in the OIDC QR login process.
74
+ * The first step in the OAuth2 QR login process.
75
75
  * To be called after the QR code has been rendered or scanned.
76
76
  * The scanning device has to discover the homeserver details, if they scanned the code then they already have it.
77
77
  * If the new device is the one rendering the QR code then it has to wait be sent the homeserver details via the rendezvous channel.
@@ -80,9 +80,9 @@ export declare class MSC4108SignInWithQR {
80
80
  serverName?: string;
81
81
  }>;
82
82
  /**
83
- * The second & third step in the OIDC QR login process.
83
+ * The second & third step in the OAuth2 QR login process.
84
84
  * To be called after `negotiateProtocols` for the existing device.
85
- * To be called after OIDC negotiation for the new device.
85
+ * To be called after OAuth2 negotiation for the new device.
86
86
  *
87
87
  * @param input - Required for the new device to start the device authorization grant, not required for the existing device reciprocating the login
88
88
  */
@@ -95,7 +95,7 @@ export declare class MSC4108SignInWithQR {
95
95
  userCode?: string;
96
96
  }>;
97
97
  /**
98
- * The fourth step in the OIDC QR login process.
98
+ * The fourth step in the OAuth2 QR login process.
99
99
  * The reciprocating device must perform step 5 for this method to resolve.
100
100
  * To be called after {@link deviceAuthorizationGrant} only on the new device.
101
101
  */
@@ -103,7 +103,7 @@ export declare class MSC4108SignInWithQR {
103
103
  clientId: string;
104
104
  }): Promise<DeviceAccessTokenResponse | undefined>;
105
105
  /**
106
- * The fifth (and final) step in the OIDC QR login process.
106
+ * The fifth (and final) step in the OAuth2 QR login process.
107
107
  * To be called after the new device has completed authentication.
108
108
  */
109
109
  shareSecrets(): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"MSC4108SignInWithQR.d.ts","sourceRoot":"","sources":["../../src/rendezvous/MSC4108SignInWithQR.ts"],"names":[],"mappings":"AAkBA,OAAO,EACH,6BAA6B,EAC7B,oBAAoB,EAEpB,KAAK,yBAAyB,EACjC,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAG/E,OAAO,EACH,KAAK,yBAAyB,EAK9B,KAAK,qBAAqB,EAG7B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD;;;;GAIG;AACH,oBAAY,WAAW;IACnB,SAAS,sBAAsB;IAC/B,QAAQ,qBAAqB;IAC7B,OAAO,oBAAoB;IAC3B,OAAO,oBAAoB;IAC3B,OAAO,oBAAoB;IAC3B,gBAAgB,8BAA8B;IAC9C,QA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UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CA4DlE;IAED;;;;;;OAMG;IACU,wBAAwB,CAAC,KAAK,CAAC,EAAE;QAC1C,QAAQ,EAAE,qBAAqB,CAAC;QAChC,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC;QACR,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,CAgGD;IAED;;;;OAIG;IACU,wBAAwB,CAAC,EAClC,QAAQ,GACX,EAAE;QACC,QAAQ,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,yBAAyB,GAAG,SAAS,CAAC,CAqDjD;IAED;;;OAGG;IACU,YAAY,IAAI,OAAO,CAAC;QAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC,CAuF/E;YAEa,OAAO;YAIP,IAAI;IAIlB;;OAEG;IACU,4BAA4B,IAAI,OAAO,CAAC,IAAI,CAAC,CAQzD;IAED;;;OAGG;IACU,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC,CAG/F;IAED;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAElC;CACJ"}
@@ -21,7 +21,7 @@ import { ClientRendezvousFailureReason, MSC4108FailureReason, RendezvousError }
21
21
  import { logger } from "../logger.js";
22
22
  import { MatrixError } from "../http-api/index.js";
23
23
  import { sleep } from "../utils.js";
24
- import { generateScope, OAuthGrantType, startDeviceAuthorization, waitForDeviceAuthorization } from "../oidc/index.js";
24
+ import { generateScope, OAuthGrantType, startDeviceAuthorization, waitForDeviceAuthorization } from "../oauth/index.js";
25
25
  /**
26
26
  * Enum representing the payload types transmissible over [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)
27
27
  * secure channels.
@@ -49,7 +49,7 @@ function isDeviceAuthorizationGrantProtocolPayload(payload) {
49
49
  }
50
50
  /**
51
51
  * Prototype of the unstable [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)
52
- * sign in with QR + OIDC flow.
52
+ * sign in with QR + OAuth2 flow.
53
53
  * @experimental Note that this is UNSTABLE and may have breaking changes without notice.
54
54
  */
55
55
  export class MSC4108SignInWithQR {
@@ -115,7 +115,7 @@ export class MSC4108SignInWithQR {
115
115
  }
116
116
 
117
117
  /**
118
- * The first step in the OIDC QR login process.
118
+ * The first step in the OAuth2 QR login process.
119
119
  * To be called after the QR code has been rendered or scanned.
120
120
  * The scanning device has to discover the homeserver details, if they scanned the code then they already have it.
121
121
  * If the new device is the one rendering the QR code then it has to wait be sent the homeserver details via the rendezvous channel.
@@ -130,13 +130,13 @@ export class MSC4108SignInWithQR {
130
130
  // MSC4108-Flow: ExistingScanned - take homeserver from QR code which should already be set
131
131
  } else {
132
132
  // MSC4108-Flow: NewScanned -send protocols message
133
- let oidcClientConfig;
133
+ let authMetadata;
134
134
  try {
135
- oidcClientConfig = await this.client.getAuthMetadata();
135
+ authMetadata = await this.client.getAuthMetadata();
136
136
  } catch (e) {
137
- logger.error("Failed to discover OIDC metadata", e);
137
+ logger.error("Failed to discover OAuth2 metadata", e);
138
138
  }
139
- if (oidcClientConfig?.grant_types_supported.includes(OAuthGrantType.DeviceAuthorization)) {
139
+ if (authMetadata?.grant_types_supported.includes(OAuthGrantType.DeviceAuthorization)) {
140
140
  await this.send({
141
141
  type: PayloadType.Protocols,
142
142
  protocols: ["device_authorization_grant"],
@@ -174,9 +174,9 @@ export class MSC4108SignInWithQR {
174
174
  }
175
175
 
176
176
  /**
177
- * The second & third step in the OIDC QR login process.
177
+ * The second & third step in the OAuth2 QR login process.
178
178
  * To be called after `negotiateProtocols` for the existing device.
179
- * To be called after OIDC negotiation for the new device.
179
+ * To be called after OAuth2 negotiation for the new device.
180
180
  *
181
181
  * @param input - Required for the new device to start the device authorization grant, not required for the existing device reciprocating the login
182
182
  */
@@ -268,7 +268,7 @@ export class MSC4108SignInWithQR {
268
268
  }
269
269
 
270
270
  /**
271
- * The fourth step in the OIDC QR login process.
271
+ * The fourth step in the OAuth2 QR login process.
272
272
  * The reciprocating device must perform step 5 for this method to resolve.
273
273
  * To be called after {@link deviceAuthorizationGrant} only on the new device.
274
274
  */
@@ -318,7 +318,7 @@ export class MSC4108SignInWithQR {
318
318
  }
319
319
 
320
320
  /**
321
- * The fifth (and final) step in the OIDC QR login process.
321
+ * The fifth (and final) step in the OAuth2 QR login process.
322
322
  * To be called after the new device has completed authentication.
323
323
  */
324
324
  async shareSecrets() {
@@ -1 +1 @@
1
- {"version":3,"file":"MSC4108SignInWithQR.js","names":[],"sources":["../../src/rendezvous/MSC4108SignInWithQR.ts"],"sourcesContent":["/*\nCopyright 2024 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 { QrCodeIntent } from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport {\n ClientRendezvousFailureReason,\n MSC4108FailureReason,\n RendezvousError,\n type RendezvousFailureListener,\n} from \"./index.ts\";\nimport { type MatrixClient } from \"../client.ts\";\nimport { logger } from \"../logger.ts\";\nimport { type MSC4108SecureChannel } from \"./channels/MSC4108SecureChannel.ts\";\nimport { MatrixError } from \"../http-api/index.ts\";\nimport { sleep } from \"../utils.ts\";\nimport {\n type DeviceAccessTokenResponse,\n type DeviceAuthorizationResponse,\n generateScope,\n OAuthGrantType,\n startDeviceAuthorization,\n type ValidatedAuthMetadata,\n waitForDeviceAuthorization,\n type OidcClientConfig,\n} from \"../oidc/index.ts\";\nimport { type CryptoApi } from \"../crypto-api/index.ts\";\n\n/**\n * Enum representing the payload types transmissible over [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * secure channels.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport enum PayloadType {\n Protocols = \"m.login.protocols\",\n Protocol = \"m.login.protocol\",\n Failure = \"m.login.failure\",\n Success = \"m.login.success\",\n Secrets = \"m.login.secrets\",\n ProtocolAccepted = \"m.login.protocol_accepted\",\n Declined = \"m.login.declined\",\n}\n\n/**\n * Type representing the base payload format for [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * messages sent over the secure channel.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport interface MSC4108Payload {\n type: PayloadType;\n}\n\ninterface ProtocolsPayload extends MSC4108Payload {\n type: PayloadType.Protocols;\n protocols: string[];\n homeserver: string;\n}\n\ninterface ProtocolPayload extends MSC4108Payload {\n type: PayloadType.Protocol;\n protocol: Exclude<string, \"device_authorization_grant\">;\n device_id: string;\n}\n\ninterface DeviceAuthorizationGrantProtocolPayload extends ProtocolPayload {\n protocol: \"device_authorization_grant\";\n device_authorization_grant: {\n verification_uri: string;\n verification_uri_complete?: string;\n };\n}\n\nfunction isDeviceAuthorizationGrantProtocolPayload(\n payload: ProtocolPayload,\n): payload is DeviceAuthorizationGrantProtocolPayload {\n return payload.protocol === \"device_authorization_grant\";\n}\n\ninterface FailurePayload extends MSC4108Payload {\n type: PayloadType.Failure;\n reason: MSC4108FailureReason;\n homeserver?: string;\n}\n\ninterface DeclinedPayload extends MSC4108Payload {\n type: PayloadType.Declined;\n}\n\ninterface SuccessPayload extends MSC4108Payload {\n type: PayloadType.Success;\n}\n\ninterface AcceptedPayload extends MSC4108Payload {\n type: PayloadType.ProtocolAccepted;\n}\n\ninterface SecretsPayload extends MSC4108Payload, Awaited<ReturnType<NonNullable<CryptoApi[\"exportSecretsBundle\"]>>> {\n type: PayloadType.Secrets;\n}\n\n/**\n * Prototype of the unstable [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * sign in with QR + OIDC flow.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport class MSC4108SignInWithQR {\n private readonly ourIntent: QrCodeIntent;\n private _code?: Uint8Array;\n private expectingNewDeviceId?: string;\n private metadata?: ValidatedAuthMetadata;\n private grantInProgress?: DeviceAuthorizationResponse;\n\n /**\n * Returns the check code for the secure channel or undefined if not generated yet.\n */\n public get checkCode(): string | undefined {\n return this.channel?.getCheckCode();\n }\n\n /**\n * @param channel - The secure channel used for communication\n * @param client - The Matrix client in used on the device already logged in\n * @param didScanCode - Whether this side of the channel scanned the QR code from the other party\n * @param onFailure - Callback for when the rendezvous fails\n */\n public constructor(\n private readonly channel: MSC4108SecureChannel,\n private readonly didScanCode: boolean,\n private readonly client?: MatrixClient,\n public onFailure?: RendezvousFailureListener,\n ) {\n this.ourIntent = client ? QrCodeIntent.Reciprocate : QrCodeIntent.Login;\n }\n\n /**\n * Returns the code representing the rendezvous suitable for rendering in a QR code or undefined if not generated yet.\n */\n public get code(): Uint8Array | undefined {\n return this._code;\n }\n\n /**\n * Generate the code including doing partial set up of the channel where required.\n */\n public async generateCode(): Promise<void> {\n if (this._code) {\n return;\n }\n\n if (this.ourIntent === QrCodeIntent.Reciprocate && this.client) {\n this._code = await this.channel.generateCode(this.ourIntent, this.client.getDomain()!);\n } else if (this.ourIntent === QrCodeIntent.Login) {\n this._code = await this.channel.generateCode(this.ourIntent);\n }\n }\n\n /**\n * Returns true if the device is the already logged in device reciprocating a new login on the other side of the channel.\n */\n public get isExistingDevice(): boolean {\n return this.ourIntent === QrCodeIntent.Reciprocate;\n }\n\n /**\n * Returns true if the device is the new device logging in being reciprocated by the device on the other side of the channel.\n */\n public get isNewDevice(): boolean {\n return !this.isExistingDevice;\n }\n\n /**\n * The first step in the OIDC QR login process.\n * To be called after the QR code has been rendered or scanned.\n * The scanning device has to discover the homeserver details, if they scanned the code then they already have it.\n * If the new device is the one rendering the QR code then it has to wait be sent the homeserver details via the rendezvous channel.\n */\n public async negotiateProtocols(): Promise<{ serverName?: string }> {\n logger.info(`negotiateProtocols(isNewDevice=${this.isNewDevice} didScanCode=${this.didScanCode})`);\n await this.channel.connect();\n\n if (this.didScanCode) {\n // Secure Channel step 6 completed, we trust the channel\n\n if (this.isNewDevice) {\n // MSC4108-Flow: ExistingScanned - take homeserver from QR code which should already be set\n } else {\n // MSC4108-Flow: NewScanned -send protocols message\n let oidcClientConfig: OidcClientConfig | undefined;\n try {\n oidcClientConfig = await this.client!.getAuthMetadata();\n } catch (e) {\n logger.error(\"Failed to discover OIDC metadata\", e);\n }\n\n if (oidcClientConfig?.grant_types_supported.includes(OAuthGrantType.DeviceAuthorization)) {\n await this.send<ProtocolsPayload>({\n type: PayloadType.Protocols,\n protocols: [\"device_authorization_grant\"],\n homeserver: this.client!.getDomain()!,\n });\n } else {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnsupportedProtocol,\n });\n throw new RendezvousError(\n \"Device code grant unsupported\",\n MSC4108FailureReason.UnsupportedProtocol,\n );\n }\n }\n } else if (this.isNewDevice) {\n // MSC4108-Flow: ExistingScanned - wait for protocols message\n logger.info(\"Waiting for protocols message\");\n const payload = await this.receive<ProtocolsPayload>();\n\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type !== PayloadType.Protocols) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\n \"Unexpected message received\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n\n return { serverName: payload.homeserver };\n } else {\n // MSC4108-Flow: NewScanned - nothing to do\n }\n return {};\n }\n\n /**\n * The second & third step in the OIDC QR login process.\n * To be called after `negotiateProtocols` for the existing device.\n * To be called after OIDC negotiation for the new device.\n *\n * @param input - Required for the new device to start the device authorization grant, not required for the existing device reciprocating the login\n */\n public async deviceAuthorizationGrant(input?: {\n metadata: ValidatedAuthMetadata;\n clientId: string;\n deviceId: string;\n }): Promise<{\n verificationUri?: string;\n userCode?: string;\n }> {\n if (this.isNewDevice) {\n if (!input) {\n throw new Error(\"Input must be provided for new device\");\n }\n\n const { metadata, clientId, deviceId } = input;\n\n const scope = generateScope(deviceId);\n\n // MSC4108-Flow: NewDevice - start device authorization grant\n const dagResponse = await startDeviceAuthorization({\n clientId,\n scope,\n metadata,\n });\n\n this.metadata = metadata;\n this.grantInProgress = dagResponse;\n\n const protocol: DeviceAuthorizationGrantProtocolPayload = {\n type: PayloadType.Protocol,\n protocol: \"device_authorization_grant\",\n device_id: deviceId,\n device_authorization_grant: {\n verification_uri: dagResponse.verification_uri,\n verification_uri_complete: dagResponse.verification_uri_complete,\n },\n };\n\n await this.send(protocol);\n\n return {\n verificationUri: dagResponse.verification_uri_complete ?? dagResponse.verification_uri,\n userCode: dagResponse.user_code,\n };\n } else {\n // The user needs to do step 7 for the out-of-band confirmation\n // but, first we receive the protocol chosen by the other device so that\n // the confirmation_uri is ready to go\n logger.info(\"Waiting for protocol message\");\n const payload = await this.receive<ProtocolPayload | DeviceAuthorizationGrantProtocolPayload>();\n\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type !== PayloadType.Protocol) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\n \"Unexpected message received\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n\n if (isDeviceAuthorizationGrantProtocolPayload(payload)) {\n const { device_authorization_grant: dag, device_id: expectingNewDeviceId } = payload;\n const { verification_uri: verificationUri, verification_uri_complete: verificationUriComplete } = dag;\n\n let deviceAlreadyExists = true;\n try {\n await this.client?.getDevice(expectingNewDeviceId);\n } catch (err: MatrixError | unknown) {\n if (err instanceof MatrixError && err.httpStatus === 404) {\n deviceAlreadyExists = false;\n }\n }\n\n if (deviceAlreadyExists) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.DeviceAlreadyExists,\n });\n throw new RendezvousError(\n \"Specified device ID already exists\",\n MSC4108FailureReason.DeviceAlreadyExists,\n );\n }\n\n this.expectingNewDeviceId = expectingNewDeviceId;\n\n return { verificationUri: verificationUriComplete ?? verificationUri };\n }\n\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnsupportedProtocol,\n });\n throw new RendezvousError(\n \"Received a request for an unsupported protocol\",\n MSC4108FailureReason.UnsupportedProtocol,\n );\n }\n }\n\n /**\n * The fourth step in the OIDC QR login process.\n * The reciprocating device must perform step 5 for this method to resolve.\n * To be called after {@link deviceAuthorizationGrant} only on the new device.\n */\n public async completeLoginOnNewDevice({\n clientId,\n }: {\n clientId: string;\n }): Promise<DeviceAccessTokenResponse | undefined> {\n if (!this.isNewDevice || !this.grantInProgress || !this.metadata) {\n throw new Error(\"Can only complete login on new device\");\n }\n\n logger.info(\"Waiting for protocol accepted message\");\n // wait for accepted message\n const payload = await this.receive<AcceptedPayload | FailurePayload>();\n\n if (!payload) {\n throw new RendezvousError(\n \"No response from existing device\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n if (payload.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", (payload as FailurePayload).reason);\n }\n if (payload.type !== PayloadType.ProtocolAccepted) {\n throw new RendezvousError(\"Unexpected message received\", MSC4108FailureReason.UnexpectedMessageReceived);\n }\n\n // poll for DAG\n const res = await waitForDeviceAuthorization({\n session: this.grantInProgress,\n metadata: this.metadata,\n clientId,\n });\n\n if (!res) {\n throw new RendezvousError(\n \"No response from device authorization endpoint\",\n ClientRendezvousFailureReason.Unknown,\n );\n }\n\n if (\"error\" in res) {\n let reason: MSC4108FailureReason = MSC4108FailureReason.UnexpectedMessageReceived;\n if (res.error === \"expired_token\") {\n reason = MSC4108FailureReason.AuthorizationExpired;\n } else if (res.error === \"access_denied\") {\n reason = MSC4108FailureReason.UserCancelled;\n }\n const payload: FailurePayload = {\n type: PayloadType.Failure,\n reason,\n };\n await this.send(payload);\n\n throw new RendezvousError(\"Rejection from device authorization endpoint\", reason);\n }\n\n return res;\n }\n\n /**\n * The fifth (and final) step in the OIDC QR login process.\n * To be called after the new device has completed authentication.\n */\n public async shareSecrets(): Promise<{ secrets?: Omit<SecretsPayload, \"type\"> }> {\n if (this.isNewDevice) {\n await this.send<SuccessPayload>({\n type: PayloadType.Success,\n });\n // then wait for secrets\n logger.info(\"Waiting for secrets message\");\n const payload = await this.receive<SecretsPayload>();\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type !== PayloadType.Secrets) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\n \"Unexpected message received\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n return { secrets: payload };\n // then done?\n } else {\n if (!this.expectingNewDeviceId) {\n throw new Error(\"No new device ID expected\");\n }\n await this.send<AcceptedPayload>({\n type: PayloadType.ProtocolAccepted,\n });\n\n logger.info(\"Waiting for outcome message\");\n const payload = await this.receive<SuccessPayload | DeclinedPayload>();\n\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type === PayloadType.Declined) {\n throw new RendezvousError(\"User declined\", ClientRendezvousFailureReason.UserDeclined);\n }\n\n if (payload?.type !== PayloadType.Success) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\"Unexpected message\", MSC4108FailureReason.UnexpectedMessageReceived);\n }\n\n const timeout = Date.now() + 10000; // wait up to 10 seconds\n do {\n // is the device visible via the Homeserver?\n try {\n const device = await this.client?.getDevice(this.expectingNewDeviceId);\n\n if (device) {\n // if so, return the secrets\n const secretsBundle = await this.client!.getCrypto()!.exportSecretsBundle!();\n if (this.channel.cancelled) {\n throw new RendezvousError(\"User cancelled\", MSC4108FailureReason.UserCancelled);\n }\n // send secrets\n await this.send<SecretsPayload>({\n type: PayloadType.Secrets,\n ...secretsBundle,\n });\n return { secrets: secretsBundle };\n // let the other side close the rendezvous session\n }\n } catch (err: MatrixError | unknown) {\n if (err instanceof MatrixError && err.httpStatus === 404) {\n // not found, so keep waiting until timeout\n } else {\n throw err;\n }\n }\n await sleep(1000);\n } while (Date.now() < timeout);\n\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.DeviceNotFound,\n });\n throw new RendezvousError(\"New device not found\", MSC4108FailureReason.DeviceNotFound);\n }\n }\n\n private async receive<T extends MSC4108Payload>(): Promise<T | FailurePayload | undefined> {\n return (await this.channel.secureReceive()) as T | undefined;\n }\n\n private async send<T extends MSC4108Payload>(payload: T): Promise<void> {\n await this.channel.secureSend(payload);\n }\n\n /**\n * Decline the login on the existing device.\n */\n public async declineLoginOnExistingDevice(): Promise<void> {\n if (!this.isExistingDevice) {\n throw new Error(\"Can only decline login on existing device\");\n }\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UserCancelled,\n });\n }\n\n /**\n * Cancels the rendezvous session.\n * @param reason the reason for the cancellation\n */\n public async cancel(reason: MSC4108FailureReason | ClientRendezvousFailureReason): Promise<void> {\n this.onFailure?.(reason);\n await this.channel.cancel(reason);\n }\n\n /**\n * Closes the rendezvous session.\n */\n public async close(): Promise<void> {\n await this.channel.close();\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAS,YAAY,QAAQ,oCAAoC;AAEjE,SACI,6BAA6B,EAC7B,oBAAoB,EACpB,eAAe,QAEZ,YAAY;AAEnB,SAAS,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C;MACjC,CAAC,CAAC;MACF,MAAM,IAAI,eAAe,CAAC,sBAAsB,EAAE,oBAAoB,CAAC,cAAc,CAAC;IAC1F;EACJ;EAEA,MAAc,OAAO,GAAsE;IACvF,OAAQ,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;EAC9C;EAEA,MAAc,IAAI,CAA2B,OAAU,EAAiB;IACpE,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC;EAC1C;;EAEA;AACJ;AACA;EACI,MAAa,4BAA4B,GAAkB;IACvD,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE;MACxB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC;IAChE;IACA,MAAM,IAAI,CAAC,IAAI,CAAiB;MAC5B,IAAI,EAAE,WAAW,CAAC,OAAO;MACzB,MAAM,EAAE,oBAAoB,CAAC;IACjC,CAAC,CAAC;EACN;;EAEA;AACJ;AACA;AACA;EACI,MAAa,MAAM,CAAC,MAA4D,EAAiB;IAC7F,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC;IACxB,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;EACrC;;EAEA;AACJ;AACA;EACI,MAAa,KAAK,GAAkB;IAChC,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;EAC9B;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"MSC4108SignInWithQR.js","names":[],"sources":["../../src/rendezvous/MSC4108SignInWithQR.ts"],"sourcesContent":["/*\nCopyright 2024 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 { QrCodeIntent } from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport {\n ClientRendezvousFailureReason,\n MSC4108FailureReason,\n RendezvousError,\n type RendezvousFailureListener,\n} from \"./index.ts\";\nimport { type MatrixClient } from \"../client.ts\";\nimport { logger } from \"../logger.ts\";\nimport { type MSC4108SecureChannel } from \"./channels/MSC4108SecureChannel.ts\";\nimport { MatrixError } from \"../http-api/index.ts\";\nimport { sleep } from \"../utils.ts\";\nimport {\n type DeviceAccessTokenResponse,\n type DeviceAuthorizationResponse,\n generateScope,\n OAuthGrantType,\n startDeviceAuthorization,\n type ValidatedAuthMetadata,\n waitForDeviceAuthorization,\n} from \"../oauth/index.ts\";\nimport { type CryptoApi } from \"../crypto-api/index.ts\";\n\n/**\n * Enum representing the payload types transmissible over [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * secure channels.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport enum PayloadType {\n Protocols = \"m.login.protocols\",\n Protocol = \"m.login.protocol\",\n Failure = \"m.login.failure\",\n Success = \"m.login.success\",\n Secrets = \"m.login.secrets\",\n ProtocolAccepted = \"m.login.protocol_accepted\",\n Declined = \"m.login.declined\",\n}\n\n/**\n * Type representing the base payload format for [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * messages sent over the secure channel.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport interface MSC4108Payload {\n type: PayloadType;\n}\n\ninterface ProtocolsPayload extends MSC4108Payload {\n type: PayloadType.Protocols;\n protocols: string[];\n homeserver: string;\n}\n\ninterface ProtocolPayload extends MSC4108Payload {\n type: PayloadType.Protocol;\n protocol: Exclude<string, \"device_authorization_grant\">;\n device_id: string;\n}\n\ninterface DeviceAuthorizationGrantProtocolPayload extends ProtocolPayload {\n protocol: \"device_authorization_grant\";\n device_authorization_grant: {\n verification_uri: string;\n verification_uri_complete?: string;\n };\n}\n\nfunction isDeviceAuthorizationGrantProtocolPayload(\n payload: ProtocolPayload,\n): payload is DeviceAuthorizationGrantProtocolPayload {\n return payload.protocol === \"device_authorization_grant\";\n}\n\ninterface FailurePayload extends MSC4108Payload {\n type: PayloadType.Failure;\n reason: MSC4108FailureReason;\n homeserver?: string;\n}\n\ninterface DeclinedPayload extends MSC4108Payload {\n type: PayloadType.Declined;\n}\n\ninterface SuccessPayload extends MSC4108Payload {\n type: PayloadType.Success;\n}\n\ninterface AcceptedPayload extends MSC4108Payload {\n type: PayloadType.ProtocolAccepted;\n}\n\ninterface SecretsPayload extends MSC4108Payload, Awaited<ReturnType<NonNullable<CryptoApi[\"exportSecretsBundle\"]>>> {\n type: PayloadType.Secrets;\n}\n\n/**\n * Prototype of the unstable [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * sign in with QR + OAuth2 flow.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport class MSC4108SignInWithQR {\n private readonly ourIntent: QrCodeIntent;\n private _code?: Uint8Array;\n private expectingNewDeviceId?: string;\n private metadata?: ValidatedAuthMetadata;\n private grantInProgress?: DeviceAuthorizationResponse;\n\n /**\n * Returns the check code for the secure channel or undefined if not generated yet.\n */\n public get checkCode(): string | undefined {\n return this.channel?.getCheckCode();\n }\n\n /**\n * @param channel - The secure channel used for communication\n * @param client - The Matrix client in used on the device already logged in\n * @param didScanCode - Whether this side of the channel scanned the QR code from the other party\n * @param onFailure - Callback for when the rendezvous fails\n */\n public constructor(\n private readonly channel: MSC4108SecureChannel,\n private readonly didScanCode: boolean,\n private readonly client?: MatrixClient,\n public onFailure?: RendezvousFailureListener,\n ) {\n this.ourIntent = client ? QrCodeIntent.Reciprocate : QrCodeIntent.Login;\n }\n\n /**\n * Returns the code representing the rendezvous suitable for rendering in a QR code or undefined if not generated yet.\n */\n public get code(): Uint8Array | undefined {\n return this._code;\n }\n\n /**\n * Generate the code including doing partial set up of the channel where required.\n */\n public async generateCode(): Promise<void> {\n if (this._code) {\n return;\n }\n\n if (this.ourIntent === QrCodeIntent.Reciprocate && this.client) {\n this._code = await this.channel.generateCode(this.ourIntent, this.client.getDomain()!);\n } else if (this.ourIntent === QrCodeIntent.Login) {\n this._code = await this.channel.generateCode(this.ourIntent);\n }\n }\n\n /**\n * Returns true if the device is the already logged in device reciprocating a new login on the other side of the channel.\n */\n public get isExistingDevice(): boolean {\n return this.ourIntent === QrCodeIntent.Reciprocate;\n }\n\n /**\n * Returns true if the device is the new device logging in being reciprocated by the device on the other side of the channel.\n */\n public get isNewDevice(): boolean {\n return !this.isExistingDevice;\n }\n\n /**\n * The first step in the OAuth2 QR login process.\n * To be called after the QR code has been rendered or scanned.\n * The scanning device has to discover the homeserver details, if they scanned the code then they already have it.\n * If the new device is the one rendering the QR code then it has to wait be sent the homeserver details via the rendezvous channel.\n */\n public async negotiateProtocols(): Promise<{ serverName?: string }> {\n logger.info(`negotiateProtocols(isNewDevice=${this.isNewDevice} didScanCode=${this.didScanCode})`);\n await this.channel.connect();\n\n if (this.didScanCode) {\n // Secure Channel step 6 completed, we trust the channel\n\n if (this.isNewDevice) {\n // MSC4108-Flow: ExistingScanned - take homeserver from QR code which should already be set\n } else {\n // MSC4108-Flow: NewScanned -send protocols message\n let authMetadata: ValidatedAuthMetadata | undefined;\n try {\n authMetadata = await this.client!.getAuthMetadata();\n } catch (e) {\n logger.error(\"Failed to discover OAuth2 metadata\", e);\n }\n\n if (authMetadata?.grant_types_supported.includes(OAuthGrantType.DeviceAuthorization)) {\n await this.send<ProtocolsPayload>({\n type: PayloadType.Protocols,\n protocols: [\"device_authorization_grant\"],\n homeserver: this.client!.getDomain()!,\n });\n } else {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnsupportedProtocol,\n });\n throw new RendezvousError(\n \"Device code grant unsupported\",\n MSC4108FailureReason.UnsupportedProtocol,\n );\n }\n }\n } else if (this.isNewDevice) {\n // MSC4108-Flow: ExistingScanned - wait for protocols message\n logger.info(\"Waiting for protocols message\");\n const payload = await this.receive<ProtocolsPayload>();\n\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type !== PayloadType.Protocols) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\n \"Unexpected message received\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n\n return { serverName: payload.homeserver };\n } else {\n // MSC4108-Flow: NewScanned - nothing to do\n }\n return {};\n }\n\n /**\n * The second & third step in the OAuth2 QR login process.\n * To be called after `negotiateProtocols` for the existing device.\n * To be called after OAuth2 negotiation for the new device.\n *\n * @param input - Required for the new device to start the device authorization grant, not required for the existing device reciprocating the login\n */\n public async deviceAuthorizationGrant(input?: {\n metadata: ValidatedAuthMetadata;\n clientId: string;\n deviceId: string;\n }): Promise<{\n verificationUri?: string;\n userCode?: string;\n }> {\n if (this.isNewDevice) {\n if (!input) {\n throw new Error(\"Input must be provided for new device\");\n }\n\n const { metadata, clientId, deviceId } = input;\n\n const scope = generateScope(deviceId);\n\n // MSC4108-Flow: NewDevice - start device authorization grant\n const dagResponse = await startDeviceAuthorization({\n clientId,\n scope,\n metadata,\n });\n\n this.metadata = metadata;\n this.grantInProgress = dagResponse;\n\n const protocol: DeviceAuthorizationGrantProtocolPayload = {\n type: PayloadType.Protocol,\n protocol: \"device_authorization_grant\",\n device_id: deviceId,\n device_authorization_grant: {\n verification_uri: dagResponse.verification_uri,\n verification_uri_complete: dagResponse.verification_uri_complete,\n },\n };\n\n await this.send(protocol);\n\n return {\n verificationUri: dagResponse.verification_uri_complete ?? dagResponse.verification_uri,\n userCode: dagResponse.user_code,\n };\n } else {\n // The user needs to do step 7 for the out-of-band confirmation\n // but, first we receive the protocol chosen by the other device so that\n // the confirmation_uri is ready to go\n logger.info(\"Waiting for protocol message\");\n const payload = await this.receive<ProtocolPayload | DeviceAuthorizationGrantProtocolPayload>();\n\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type !== PayloadType.Protocol) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\n \"Unexpected message received\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n\n if (isDeviceAuthorizationGrantProtocolPayload(payload)) {\n const { device_authorization_grant: dag, device_id: expectingNewDeviceId } = payload;\n const { verification_uri: verificationUri, verification_uri_complete: verificationUriComplete } = dag;\n\n let deviceAlreadyExists = true;\n try {\n await this.client?.getDevice(expectingNewDeviceId);\n } catch (err: MatrixError | unknown) {\n if (err instanceof MatrixError && err.httpStatus === 404) {\n deviceAlreadyExists = false;\n }\n }\n\n if (deviceAlreadyExists) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.DeviceAlreadyExists,\n });\n throw new RendezvousError(\n \"Specified device ID already exists\",\n MSC4108FailureReason.DeviceAlreadyExists,\n );\n }\n\n this.expectingNewDeviceId = expectingNewDeviceId;\n\n return { verificationUri: verificationUriComplete ?? verificationUri };\n }\n\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnsupportedProtocol,\n });\n throw new RendezvousError(\n \"Received a request for an unsupported protocol\",\n MSC4108FailureReason.UnsupportedProtocol,\n );\n }\n }\n\n /**\n * The fourth step in the OAuth2 QR login process.\n * The reciprocating device must perform step 5 for this method to resolve.\n * To be called after {@link deviceAuthorizationGrant} only on the new device.\n */\n public async completeLoginOnNewDevice({\n clientId,\n }: {\n clientId: string;\n }): Promise<DeviceAccessTokenResponse | undefined> {\n if (!this.isNewDevice || !this.grantInProgress || !this.metadata) {\n throw new Error(\"Can only complete login on new device\");\n }\n\n logger.info(\"Waiting for protocol accepted message\");\n // wait for accepted message\n const payload = await this.receive<AcceptedPayload | FailurePayload>();\n\n if (!payload) {\n throw new RendezvousError(\n \"No response from existing device\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n if (payload.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", (payload as FailurePayload).reason);\n }\n if (payload.type !== PayloadType.ProtocolAccepted) {\n throw new RendezvousError(\"Unexpected message received\", MSC4108FailureReason.UnexpectedMessageReceived);\n }\n\n // poll for DAG\n const res = await waitForDeviceAuthorization({\n session: this.grantInProgress,\n metadata: this.metadata,\n clientId,\n });\n\n if (!res) {\n throw new RendezvousError(\n \"No response from device authorization endpoint\",\n ClientRendezvousFailureReason.Unknown,\n );\n }\n\n if (\"error\" in res) {\n let reason: MSC4108FailureReason = MSC4108FailureReason.UnexpectedMessageReceived;\n if (res.error === \"expired_token\") {\n reason = MSC4108FailureReason.AuthorizationExpired;\n } else if (res.error === \"access_denied\") {\n reason = MSC4108FailureReason.UserCancelled;\n }\n const payload: FailurePayload = {\n type: PayloadType.Failure,\n reason,\n };\n await this.send(payload);\n\n throw new RendezvousError(\"Rejection from device authorization endpoint\", reason);\n }\n\n return res;\n }\n\n /**\n * The fifth (and final) step in the OAuth2 QR login process.\n * To be called after the new device has completed authentication.\n */\n public async shareSecrets(): Promise<{ secrets?: Omit<SecretsPayload, \"type\"> }> {\n if (this.isNewDevice) {\n await this.send<SuccessPayload>({\n type: PayloadType.Success,\n });\n // then wait for secrets\n logger.info(\"Waiting for secrets message\");\n const payload = await this.receive<SecretsPayload>();\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type !== PayloadType.Secrets) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\n \"Unexpected message received\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n return { secrets: payload };\n // then done?\n } else {\n if (!this.expectingNewDeviceId) {\n throw new Error(\"No new device ID expected\");\n }\n await this.send<AcceptedPayload>({\n type: PayloadType.ProtocolAccepted,\n });\n\n logger.info(\"Waiting for outcome message\");\n const payload = await this.receive<SuccessPayload | DeclinedPayload>();\n\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type === PayloadType.Declined) {\n throw new RendezvousError(\"User declined\", ClientRendezvousFailureReason.UserDeclined);\n }\n\n if (payload?.type !== PayloadType.Success) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\"Unexpected message\", MSC4108FailureReason.UnexpectedMessageReceived);\n }\n\n const timeout = Date.now() + 10000; // wait up to 10 seconds\n do {\n // is the device visible via the Homeserver?\n try {\n const device = await this.client?.getDevice(this.expectingNewDeviceId);\n\n if (device) {\n // if so, return the secrets\n const secretsBundle = await this.client!.getCrypto()!.exportSecretsBundle!();\n if (this.channel.cancelled) {\n throw new RendezvousError(\"User cancelled\", MSC4108FailureReason.UserCancelled);\n }\n // send secrets\n await this.send<SecretsPayload>({\n type: PayloadType.Secrets,\n ...secretsBundle,\n });\n return { secrets: secretsBundle };\n // let the other side close the rendezvous session\n }\n } catch (err: MatrixError | unknown) {\n if (err instanceof MatrixError && err.httpStatus === 404) {\n // not found, so keep waiting until timeout\n } else {\n throw err;\n }\n }\n await sleep(1000);\n } while (Date.now() < timeout);\n\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.DeviceNotFound,\n });\n throw new RendezvousError(\"New device not found\", MSC4108FailureReason.DeviceNotFound);\n }\n }\n\n private async receive<T extends MSC4108Payload>(): Promise<T | FailurePayload | undefined> {\n return (await this.channel.secureReceive()) as T | undefined;\n }\n\n private async send<T extends MSC4108Payload>(payload: T): Promise<void> {\n await this.channel.secureSend(payload);\n }\n\n /**\n * Decline the login on the existing device.\n */\n public async declineLoginOnExistingDevice(): Promise<void> {\n if (!this.isExistingDevice) {\n throw new Error(\"Can only decline login on existing device\");\n }\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UserCancelled,\n });\n }\n\n /**\n * Cancels the rendezvous session.\n * @param reason the reason for the cancellation\n */\n public async cancel(reason: MSC4108FailureReason | ClientRendezvousFailureReason): Promise<void> {\n this.onFailure?.(reason);\n await this.channel.cancel(reason);\n }\n\n /**\n * Closes the rendezvous session.\n */\n public async close(): Promise<void> {\n await this.channel.close();\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAS,YAAY,QAAQ,oCAAoC;AAEjE,SACI,6BAA6B,EAC7B,oBAAoB,EACpB,eAAe,QAEZ,YAAY;AAEnB,SAAS,MAAM,QAAQ,cAAc;AAErC,SAAS,WAAW,QAAQ,sBAAsB;AAClD,SAAS,KAAK,QAAQ,aAAa;AACnC,SAGI,aAAa,EACb,cAAc,EACd,wBAAwB,EAExB,0BAA0B,QACvB,mBAAmB;AAG1B;AACA;AACA;AACA;AACA;AACA,WAAY,WAAW,0BAAX,WAAW;EAAX,WAAW;EAAX,WAAW;EAAX,WAAW;EAAX,WAAW;EAAX,WAAW;EAAX,WAAW;EAAX,WAAW;EAAA,OAAX,WAAW;AAAA;;AAUvB;AACA;AACA;AACA;AACA;;AAyBA,SAAS,yCAAyC,CAC9C,OAAwB,EAC0B;EAClD,OAAO,OAAO,CAAC,QAAQ,KAAK,4BAA4B;AAC5D;AAwBA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM,mBAAmB,CAAC;EAO7B;AACJ;AACA;EACI,IAAW,SAAS,GAAuB;IACvC,OAAO,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;EACvC;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACW,WAAW,CACG,OAA6B,EAC7B,WAAoB,EACpB,MAAqB,EAC/B,SAAqC,EAC9C;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA,KAJmB,OAA6B,GAA7B,OAA6B;IAAA,KAC7B,W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AI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;EAC9B;AACJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"RendezvousError.d.ts","sourceRoot":"","sources":["../../src/rendezvous/RendezvousError.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D,qBAAa,eAAgB,SAAQ,KAAK;aAGlB,IAAI,EAAE,uBAAuB;gBAD7C,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,uBAAuB;CAIpD"}
1
+ {"version":3,"file":"RendezvousError.d.ts","sourceRoot":"","sources":["../../src/rendezvous/RendezvousError.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D,qBAAa,eAAgB,SAAQ,KAAK;aAGlB,IAAI,EAAE,uBAAuB;IAFjD,YACI,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,uBAAuB,EAGhD;CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"MSC4108SecureChannel.d.ts","sourceRoot":"","sources":["../../../src/rendezvous/channels/MSC4108SecureChannel.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,KAAK,mBAAmB,EAIxB,YAAY,EACf,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACH,6BAA6B,EAC7B,oBAAoB,EACpB,KAAK,cAAc,EAEnB,KAAK,yBAAyB,EACjC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AAG1F;;;;;GAKG;AACH,qBAAa,oBAAoB;IAMzB,OAAO,CAAC,iBAAiB;IACzB,OAAO,CAAC,cAAc,CAAC;IAChB,SAAS,CAAC,EAAE,yBAAyB;IAPhD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAQ;IACtC,OAAO,CAAC,kBAAkB,CAAC,CAAmB;IAC9C,OAAO,CAAC,SAAS,CAAS;gBAGd,iBAAi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BAA0B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AAEpC;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAgBpF;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,2BAA2B,CAC7C,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,yBAAyB,EACpC,WAAW,EAAE,WAAW,GACzB,OAAO,CAAC,mBAAmB,CAAC,CAG9B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,oBAAoB,CACtC,UAAU,EAAE,YAAY,EACxB,SAAS,EAAE,yBAAyB,EACpC,WAAW,EAAE,WAAW,GACzB,OAAO,CAAC,mBAAmB,CAAC,CAM9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/rendezvous/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 { type MatrixClient, OAuthGrantType, type OidcClientConfig } from \"../matrix.ts\";\nimport { MSC4108FailureReason, type RendezvousFailureListener } from \"./RendezvousFailureReason.ts\";\nimport { MSC4108SignInWithQR } from \"./MSC4108SignInWithQR.ts\";\nimport { MSC4108RendezvousSession } from \"./transports/MSC4108RendezvousSession.ts\";\nimport { MSC4108SecureChannel } from \"./channels/MSC4108SecureChannel.ts\";\nimport { RendezvousIntent } from \"./RendezvousIntent.ts\";\nimport { logger } from \"../logger.ts\";\n\nexport * from \"./MSC4108SignInWithQR.ts\";\nexport type * from \"./RendezvousChannel.ts\";\nexport type * from \"./RendezvousCode.ts\";\nexport * from \"./RendezvousError.ts\";\nexport * from \"./RendezvousFailureReason.ts\";\nexport * from \"./RendezvousIntent.ts\";\nexport type * from \"./RendezvousTransport.ts\";\nexport * from \"./transports/index.ts\";\nexport * from \"./channels/index.ts\";\n\n/**\n * Check if the homeserver that the client is connected to supports a variant of sign-in with QR that we can use.\n *\n * @param client the client to check for sign-in with QR support\n * @returns true if the homeserver that the client is connected to supports a variant of sign-in with QR that we can use, false otherwise.\n */\nexport async function isSignInWithQRAvailable(client: MatrixClient): Promise<boolean> {\n let metadata: OidcClientConfig;\n try {\n metadata = await client.getAuthMetadata();\n } catch (e) {\n logger.warn(\"Failed to fetch auth metadata, assuming sign-in with QR is unavailable\", e);\n return false;\n }\n\n // check for support of device authorization grant\n if (!metadata.grant_types_supported.includes(OAuthGrantType.DeviceAuthorization)) {\n return false;\n }\n\n // check for unstable support for MSC4108 2024 version\n return client.doesServerSupportUnstableFeature(\"org.matrix.msc4108\");\n}\n\n/**\n * Start a linking flow from an existing authenticated client by generating a QR code that can be scanned by the new device.\n * The new device will then authenticate with the server and link itself to the same account as the existing client and\n * share the end-to-end encryption keys.\n *\n * @param client the existing client\n * @param onFailure callback for when the linking process fails\n * @param abortSignal an AbortSignal that can be used to cancel the linking process,\n * for example when the user cancels out of the flow.\n * This will unbind the {@link onFailure} callback and prevent any further steps in the flow from being executed.\n * @returns a promise that resolves to an instance of the linking flow\n */\nexport async function linkNewDeviceByGeneratingQR(\n client: MatrixClient,\n onFailure: RendezvousFailureListener,\n abortSignal: AbortSignal,\n): Promise<MSC4108SignInWithQR> {\n // we assume rust crypto is already initialised\n return initGenerateQrFlow(RendezvousIntent.RECIPROCATE_LOGIN_ON_EXISTING_DEVICE, client, onFailure, abortSignal);\n}\n\n/**\n * Start a sign-in flow by generating a QR code that can be scanned by an existing authenticated client.\n * The existing client will then help complete the authentication of the new device and link it to the same account,\n * sharing the end-to-end encryption keys.\n *\n * @param tempClient temporary client used during the flow for the rendezvous channel\n * @param onFailure callback for when the sign-in process fails\n * @param abortSignal an AbortSignal that can be used to cancel the linking process,\n * for example when the user cancels out of the flow.\n * This will unbind the {@link onFailure} callback and prevent any further steps in the flow from being executed.\n * @returns a promise that resolves to an instance of the sign-in flow\n */\nexport async function signInByGeneratingQR(\n tempClient: MatrixClient,\n onFailure: RendezvousFailureListener,\n abortSignal: AbortSignal,\n): Promise<MSC4108SignInWithQR> {\n // ensure rust crypto is initialized as needed for the secure channel\n const RustSdkCryptoJs = await import(\"@matrix-org/matrix-sdk-crypto-wasm\");\n await RustSdkCryptoJs.initAsync();\n\n return initGenerateQrFlow(RendezvousIntent.LOGIN_ON_NEW_DEVICE, tempClient, onFailure, abortSignal);\n}\n\nasync function initGenerateQrFlow(\n intent: RendezvousIntent,\n client: MatrixClient,\n onFailure: RendezvousFailureListener,\n abortSignal: AbortSignal,\n): Promise<MSC4108SignInWithQR> {\n const session = new MSC4108RendezvousSession({\n onFailure,\n client,\n });\n const channel = new MSC4108SecureChannel(session, undefined, onFailure);\n const flow = new MSC4108SignInWithQR(\n channel,\n false,\n intent === RendezvousIntent.LOGIN_ON_NEW_DEVICE ? undefined : client,\n onFailure,\n );\n\n if (abortSignal.aborted) return flow;\n\n abortSignal.onabort = (): void => {\n // Detach failure handlers\n session.onFailure = undefined;\n channel.onFailure = undefined;\n flow.onFailure = undefined;\n // Cancel the session\n void flow.cancel(MSC4108FailureReason.UserCancelled);\n };\n\n await session.send(\"\"); // open channel\n\n if (!abortSignal.aborted) {\n await flow.generateCode();\n }\n\n return flow;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAA4B,cAAc,QAA+B,cAAc;AACvF,SAAS,oBAAoB,QAAwC,8BAA8B;AACnG,SAAS,mBAAmB,QAAQ,0BAA0B;AAC9D,SAAS,wBAAwB,QAAQ,0CAA0C;AACnF,SAAS,oBAAoB,QAAQ,oC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AEA,eAAe,kBAAkB,CAC7B,MAAwB,EACxB,MAAoB,EACpB,SAAoC,EACpC,WAAwB,EACI;EAC5B,MAAM,OAAO,GAAG,IAAI,wBAAwB,CAAC;IACzC,SAAS;IACT;EACJ,CAAC,CAAC;EACF,MAAM,OAAO,GAAG,IAAI,oBAAoB,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC;EACvE,MAAM,IAAI,GAAG,IAAI,mBAAmB,CAChC,OAAO,EACP,KAAK,EACL,MAAM,KAAK,gBAAgB,CAAC,mBAAmB,GAAG,SAAS,GAAG,MAAM,EACpE,SACJ,CAAC;EAED,IAAI,WAAW,CAAC,OAAO,EAAE,OAAO,IAAI;EAEpC,WAAW,CAAC,OAAO,GAAG,MAAY;IAC9B;IACA,OAAO,CAAC,SAAS,GAAG,SAAS;IAC7B,OAAO,CAAC,SAAS,GAAG,SAAS;IAC7B,IAAI,CAAC,SAAS,GAAG,SAAS;IAC1B;IACA,KAAK,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,aAAa,CAAC;EACxD,CAAC;EAED,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;;EAExB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;IACtB,MAAM,IAAI,CAAC,YAAY,CAAC,CAAC;EAC7B;EAEA,OAAO,IAAI;AACf","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/rendezvous/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 { type MatrixClient, OAuthGrantType, type ValidatedAuthMetadata } from \"../matrix.ts\";\nimport { MSC4108FailureReason, type RendezvousFailureListener } from \"./RendezvousFailureReason.ts\";\nimport { MSC4108SignInWithQR } from \"./MSC4108SignInWithQR.ts\";\nimport { MSC4108RendezvousSession } from \"./transports/MSC4108RendezvousSession.ts\";\nimport { MSC4108SecureChannel } from \"./channels/MSC4108SecureChannel.ts\";\nimport { RendezvousIntent } from \"./RendezvousIntent.ts\";\nimport { logger } from \"../logger.ts\";\n\nexport * from \"./MSC4108SignInWithQR.ts\";\nexport type * from \"./RendezvousChannel.ts\";\nexport type * from \"./RendezvousCode.ts\";\nexport * from \"./RendezvousError.ts\";\nexport * from \"./RendezvousFailureReason.ts\";\nexport * from \"./RendezvousIntent.ts\";\nexport type * from \"./RendezvousTransport.ts\";\nexport * from \"./transports/index.ts\";\nexport * from \"./channels/index.ts\";\n\n/**\n * Check if the homeserver that the client is connected to supports a variant of sign-in with QR that we can use.\n *\n * @param client the client to check for sign-in with QR support\n * @returns true if the homeserver that the client is connected to supports a variant of sign-in with QR that we can use, false otherwise.\n */\nexport async function isSignInWithQRAvailable(client: MatrixClient): Promise<boolean> {\n let metadata: ValidatedAuthMetadata;\n try {\n metadata = await client.getAuthMetadata();\n } catch (e) {\n logger.warn(\"Failed to fetch auth metadata, assuming sign-in with QR is unavailable\", e);\n return false;\n }\n\n // check for support of device authorization grant\n if (!metadata.grant_types_supported.includes(OAuthGrantType.DeviceAuthorization)) {\n return false;\n }\n\n // check for unstable support for MSC4108 2024 version\n return client.doesServerSupportUnstableFeature(\"org.matrix.msc4108\");\n}\n\n/**\n * Start a linking flow from an existing authenticated client by generating a QR code that can be scanned by the new device.\n * The new device will then authenticate with the server and link itself to the same account as the existing client and\n * share the end-to-end encryption keys.\n *\n * @param client the existing client\n * @param onFailure callback for when the linking process fails\n * @param abortSignal an AbortSignal that can be used to cancel the linking process,\n * for example when the user cancels out of the flow.\n * This will unbind the {@link onFailure} callback and prevent any further steps in the flow from being executed.\n * @returns a promise that resolves to an instance of the linking flow\n */\nexport async function linkNewDeviceByGeneratingQR(\n client: MatrixClient,\n onFailure: RendezvousFailureListener,\n abortSignal: AbortSignal,\n): Promise<MSC4108SignInWithQR> {\n // we assume rust crypto is already initialised\n return initGenerateQrFlow(RendezvousIntent.RECIPROCATE_LOGIN_ON_EXISTING_DEVICE, client, onFailure, abortSignal);\n}\n\n/**\n * Start a sign-in flow by generating a QR code that can be scanned by an existing authenticated client.\n * The existing client will then help complete the authentication of the new device and link it to the same account,\n * sharing the end-to-end encryption keys.\n *\n * @param tempClient temporary client used during the flow for the rendezvous channel\n * @param onFailure callback for when the sign-in process fails\n * @param abortSignal an AbortSignal that can be used to cancel the linking process,\n * for example when the user cancels out of the flow.\n * This will unbind the {@link onFailure} callback and prevent any further steps in the flow from being executed.\n * @returns a promise that resolves to an instance of the sign-in flow\n */\nexport async function signInByGeneratingQR(\n tempClient: MatrixClient,\n onFailure: RendezvousFailureListener,\n abortSignal: AbortSignal,\n): Promise<MSC4108SignInWithQR> {\n // ensure rust crypto is initialized as needed for the secure channel\n const RustSdkCryptoJs = await import(\"@matrix-org/matrix-sdk-crypto-wasm\");\n await RustSdkCryptoJs.initAsync();\n\n return initGenerateQrFlow(RendezvousIntent.LOGIN_ON_NEW_DEVICE, tempClient, onFailure, abortSignal);\n}\n\nasync function initGenerateQrFlow(\n intent: RendezvousIntent,\n client: MatrixClient,\n onFailure: RendezvousFailureListener,\n abortSignal: AbortSignal,\n): Promise<MSC4108SignInWithQR> {\n const session = new MSC4108RendezvousSession({\n onFailure,\n client,\n });\n const channel = new MSC4108SecureChannel(session, undefined, onFailure);\n const flow = new MSC4108SignInWithQR(\n channel,\n false,\n intent === RendezvousIntent.LOGIN_ON_NEW_DEVICE ? undefined : client,\n onFailure,\n );\n\n if (abortSignal.aborted) return flow;\n\n abortSignal.onabort = (): void => {\n // Detach failure handlers\n session.onFailure = undefined;\n channel.onFailure = undefined;\n flow.onFailure = undefined;\n // Cancel the session\n void flow.cancel(MSC4108FailureReason.UserCancelled);\n };\n\n await session.send(\"\"); // open channel\n\n if (!abortSignal.aborted) {\n await flow.generateCode();\n }\n\n return flow;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAA4B,cAAc,QAAoC,cAAc;AAC5F,SAAS,oBAAoB,QAAwC,8BAA8B;AACnG,SAAS,mBAAmB,QAAQ,0BAA0B;AAC9D,SAAS,wBAAwB,QAAQ,0CAA0C;AACnF,SAAS,oBAAoB,QAAQ,oCAAoC;AACzE,SAAS,gBAAgB,QAAQ,uBAAuB;AACxD,SAAS,MAAM,QAAQ,cAAc;AAErC,cAAc,0BAA0B;AAGxC,cAAc,sBAAsB;AACpC,cAAc,8BAA8B;AAC5C,cAAc,uBAAuB;AAErC,cAAc,uBAAuB;AACrC,cAAc,qBAAqB;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAe,uBAAuB,CAAC,MAAoB,EAAoB;EAClF,IAAI,QAA+B;EACnC,IAAI;IACA,QAAQ,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;EAC7C,CAAC,CAAC,OAAO,CAAC,EAAE;IACR,MAAM,CAAC,IAAI,CAAC,wEAAwE,EAAE,CAAC,CAAC;IACxF,OAAO,KAAK;EAChB;;EAEA;EACA,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,QAAQ,CAAC,cAAc,CAAC,mBAAmB,CAAC,EAAE;IAC9E,OAAO,KAAK;EAChB;;EAEA;EACA,OAAO,MAAM,CAAC,gCAAgC,CAAC,oBAAoB,CAAC;AACxE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAe,2BAA2B,CAC7C,MAAoB,EACpB,SAAoC,EACpC,WAAwB,EACI;EAC5B;EACA,OAAO,kBAAkB,CAAC,gBAAgB,CAAC,oCAAoC,EAAE,MAAM,EAAE,SAAS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;OAGG;IACU,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuD9C;;;OAGG;IACU,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IA6CnD;;;;OAIG;IACU,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBhG;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAetC"}
1
+ {"version":3,"file":"MSC4108RendezvousSession.d.ts","sourceRoot":"","sources":["../../../src/rendezvous/transports/MSC4108RendezvousSession.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,KAAK,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAClH,OAAO,EAAE,KAAK,YAAY,EAAU,MAAM,iBAAiB,CAAC;AAG5D;;;;GAIG;AACH,qBAAa,wBAAwB;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAe;IACvC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAA0B;IAC5C,SAAS,CAAC,EAAE,yBAAyB,CAAC;IAC7C,OAAO,CAAC,IAAI,CAAC,CAAS;IACtB,OAAO,CAAC,SAAS,CAAC,CAAO;IACzB,OAAO,CAAC,YAAY,CAAC,CAAgC;IACrD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,MAAM,CAAS;IAEvB,YAAmB,EACf,SAAS,EACT,GAAG,EACH,OAAO,GACV,EAAE;QACC,OAAO,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;QAClC,SAAS,CAAC,EAAE,yBAAyB,CAAC;QACtC,GAAG,EAAE,MAAM,CAAC;KACf,EAAE;IACH,YAAmB,EACf,SAAS,EACT,MAAM,EACN,gBAAgB,E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kBAAkB,GAAG,SAAS,CAEpF;IAEM,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAEzE;IAGM,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAe7D;CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"CrossSigningIdentity.d.ts","sourceRoot":"","sources":["../../src/rust-crypto/CrossSigningIdentity.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,KAAK,UAAU,EAGlB,MAAM,oCAAoC,CAAC;AAG5C,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAE9E,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEpE;;;GAGG;AACH,qBAAa,oBAAoB;IAEzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,wBAAwB;IACzC,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAHb,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,wBAAwB,EAAE,wBAAwB,EAClD,aAAa,EAAE,uBAAuB;IAG3D;;OAEG;IACU,qBAAqB,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAuFlF;;;;;;OAMG;YACW,iBAAiB;IA+B/B;;;;OAIG;YACW,+BAA+B;CAoBhD"}
1
+ {"version":3,"file":"CrossSigningIdentity.d.ts","sourceRoot":"","sources":["../../src/rust-crypto/CrossSigningIdentity.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,KAAK,UAAU,EAGlB,MAAM,oCAAoC,CAAC;AAG5C,OAAO,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yB,GAAG,IAAI,CAAC,qBAAqB,EAAE,uBAAuB,CAAC,CAAC"}
@@ -27,7 +27,7 @@ import { TypedEventEmitter } from "../models/typed-event-emitter.js";
27
27
  */
28
28
 
29
29
  /**
30
- * The response body of `POST /_matrix/client/unstable/org.matrix.msc3814.v1/dehydrated_device/events`.
30
+ * The response body of `GET /_matrix/client/unstable/org.matrix.msc3814.v1/dehydrated_device/{device_id}/events`.
31
31
  */
32
32
 
33
33
  /**
@@ -229,22 +229,20 @@ export class DehydratedDeviceManager extends TypedEventEmitter {
229
229
  const path = encodeUri("/dehydrated_device/$device_id/events", {
230
230
  $device_id: dehydratedDeviceResp.device_id
231
231
  });
232
- // eslint-disable-next-line no-constant-condition
233
- while (true) {
234
- const eventResp = await this.http.authedRequest(Method.Post, path, undefined, nextBatch ? {
235
- next_batch: nextBatch
236
- } : {}, {
232
+ do {
233
+ const eventResp = await this.http.authedRequest(Method.Get, path, nextBatch ? {
234
+ from: nextBatch
235
+ } : undefined, undefined, {
237
236
  prefix: UnstablePrefix
238
237
  });
239
- if (eventResp.events.length === 0) {
240
- break;
241
- }
242
238
  toDeviceCount += eventResp.events.length;
243
239
  nextBatch = eventResp.next_batch;
244
- const roomKeyInfos = await rehydratedDevice.receiveEvents(JSON.stringify(eventResp.events));
245
- roomKeyCount += roomKeyInfos.length;
246
- this.emit(CryptoEvent.RehydrationProgress, roomKeyCount, toDeviceCount);
247
- }
240
+ if (eventResp.events.length > 0) {
241
+ const roomKeyInfos = await rehydratedDevice.receiveEvents(JSON.stringify(eventResp.events));
242
+ roomKeyCount += roomKeyInfos.length;
243
+ this.emit(CryptoEvent.RehydrationProgress, roomKeyCount, toDeviceCount);
244
+ }
245
+ } while (nextBatch !== undefined);
248
246
  this.logger.info(`dehydration: received ${roomKeyCount} room keys from ${toDeviceCount} to-device events`);
249
247
  this.emit(CryptoEvent.RehydrationCompleted);
250
248
  return true;