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
@@ -1 +0,0 @@
1
- {"version":3,"file":"authorize.js","names":[],"sources":["../../src/oidc/authorize.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport {\n type IdTokenClaims,\n Log,\n OidcClient,\n type SigninRequestCreateArgs,\n SigninResponse,\n SigninState,\n WebStorageStateStore,\n} from \"oidc-client-ts\";\n\nimport { logger } from \"../logger.ts\";\nimport { secureRandomString } from \"../randomstring.ts\";\nimport { OidcError } from \"./error.ts\";\nimport {\n type BearerTokenResponse,\n type UserState,\n validateBearerTokenResponse,\n type ValidatedAuthMetadata,\n validateIdToken,\n validateStoredUserState,\n} from \"./validate.ts\";\nimport { sha256 } from \"../digest.ts\";\nimport { encodeUnpaddedBase64Url } from \"../base64.ts\";\nimport { OAuthGrantType } from \"./register.ts\";\nimport { sleep } from \"../utils.ts\";\nimport { Method } from \"../http-api/index.ts\";\n\n// reexport for backwards compatibility\nexport type { BearerTokenResponse };\n\n/**\n * Authorization parameters which are used in the authentication request of an OIDC auth code flow.\n *\n * See https://openid.net/specs/openid-connect-basic-1_0.html#RequestParameters.\n */\nexport type AuthorizationParams = {\n state: string;\n scope: string;\n redirectUri: string;\n codeVerifier: string;\n nonce: string;\n};\n\n/**\n * @experimental\n * Generate the scope used in authorization request with OIDC OP\n * @returns scope\n */\nexport const generateScope = (deviceId?: string): string => {\n const safeDeviceId = deviceId ?? secureRandomString(10);\n return `openid urn:matrix:org.matrix.msc2967.client:api:* urn:matrix:org.matrix.msc2967.client:device:${safeDeviceId}`;\n};\n\n// https://www.rfc-editor.org/rfc/rfc7636\nconst generateCodeChallenge = async (codeVerifier: string): Promise<string> => {\n if (!globalThis.crypto.subtle) {\n // @TODO(kerrya) should this be allowed? configurable?\n logger.warn(\"A secure context is required to generate code challenge. Using plain text code challenge\");\n return codeVerifier;\n }\n\n const hashBuffer = await sha256(codeVerifier);\n return encodeUnpaddedBase64Url(hashBuffer);\n};\n\n/**\n * Generate authorization params to pass to {@link generateAuthorizationUrl}.\n *\n * Used as part of an authorization code OIDC flow: see https://openid.net/specs/openid-connect-basic-1_0.html#CodeFlow.\n *\n * @param redirectUri - absolute url for OP to redirect to after authorization\n * @returns AuthorizationParams\n */\nexport const generateAuthorizationParams = ({ redirectUri }: { redirectUri: string }): AuthorizationParams => ({\n scope: generateScope(),\n redirectUri,\n state: secureRandomString(8),\n nonce: secureRandomString(8),\n codeVerifier: secureRandomString(64), // https://tools.ietf.org/html/rfc7636#section-4.1 length needs to be 43-128 characters\n});\n\n/**\n * @deprecated use generateOidcAuthorizationUrl\n * Generate a URL to attempt authorization with the OP\n * See https://openid.net/specs/openid-connect-basic-1_0.html#CodeRequest\n * @param authorizationUrl - endpoint to attempt authorization with the OP\n * @param clientId - id of this client as registered with the OP\n * @param authorizationParams - params to be used in the url\n * @returns a Promise with the url as a string\n */\nexport const generateAuthorizationUrl = async (\n authorizationUrl: string,\n clientId: string,\n { scope, redirectUri, state, nonce, codeVerifier }: AuthorizationParams,\n): Promise<string> => {\n const url = new URL(authorizationUrl);\n url.searchParams.append(\"response_mode\", \"query\");\n url.searchParams.append(\"response_type\", \"code\");\n url.searchParams.append(\"redirect_uri\", redirectUri);\n url.searchParams.append(\"client_id\", clientId);\n url.searchParams.append(\"state\", state);\n url.searchParams.append(\"scope\", scope);\n url.searchParams.append(\"nonce\", nonce);\n\n url.searchParams.append(\"code_challenge_method\", \"S256\");\n url.searchParams.append(\"code_challenge\", await generateCodeChallenge(codeVerifier));\n\n return url.toString();\n};\n\n/**\n * @experimental\n * Generate a URL to attempt authorization with the OP\n * See https://openid.net/specs/openid-connect-basic-1_0.html#CodeRequest\n * @param metadata - validated metadata from OP discovery\n * @param clientId - this client's id as registered with the OP\n * @param homeserverUrl - used to establish the session on return from the OP\n * @param identityServerUrl - used to establish the session on return from the OP\n * @param nonce - state\n * @param prompt - indicates to the OP which flow the user should see - eg login or registration\n * See https://openid.net/specs/openid-connect-prompt-create-1_0.html#name-prompt-parameter\n * @param urlState - value to append to the opaque state identifier to uniquely identify the callback\n * @param loginHint - value to send as the `login_hint` to the OP, giving a hint about the login identifier the user might use to log in.\n * See {@link https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest OIDC core 3.1.2.1}.\n * @param responseMode - value to send as the `response_mode` to the OP, selecting how auth is passed back during redirect.\n * See {@link https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest OIDC core 3.1.2.1}.\n * @returns a Promise with the url as a string\n */\nexport const generateOidcAuthorizationUrl = async ({\n metadata,\n redirectUri,\n clientId,\n homeserverUrl,\n identityServerUrl,\n nonce,\n prompt,\n urlState,\n loginHint,\n responseMode = \"query\",\n}: {\n clientId: string;\n metadata: ValidatedAuthMetadata;\n homeserverUrl: string;\n identityServerUrl?: string;\n redirectUri: string;\n nonce: string;\n prompt?: string;\n urlState?: string;\n loginHint?: string;\n responseMode?: SigninRequestCreateArgs[\"response_mode\"];\n}): Promise<string> => {\n const scope = generateScope();\n const oidcClient = new OidcClient({\n ...metadata,\n client_id: clientId,\n redirect_uri: redirectUri,\n authority: metadata.issuer,\n response_mode: responseMode,\n response_type: \"code\",\n scope,\n stateStore: new WebStorageStateStore({ prefix: \"mx_oidc_\", store: window.sessionStorage }),\n });\n const userState: UserState = { homeserverUrl, nonce, identityServerUrl };\n const request = await oidcClient.createSigninRequest({\n state: userState,\n nonce,\n prompt,\n url_state: urlState,\n login_hint: loginHint,\n });\n\n return request.url;\n};\n\n/**\n * Normalize token_type to use capital case to make consuming the token response easier\n * token_type is case insensitive, and it is spec-compliant for OPs to return token_type: \"bearer\"\n * Later, when used in auth headers it is case sensitive and must be Bearer\n * See: https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.4\n *\n * @param response - validated token response\n * @returns response with token_type set to 'Bearer'\n */\nconst normalizeBearerTokenResponseTokenType = (response: SigninResponse): BearerTokenResponse =>\n ({\n id_token: response.id_token,\n scope: response.scope,\n expires_at: response.expires_at,\n refresh_token: response.refresh_token,\n access_token: response.access_token,\n token_type: \"Bearer\",\n }) as BearerTokenResponse;\n\n/**\n * @experimental\n * Attempt to exchange authorization code for bearer token.\n *\n * Takes the authorization code returned by the OpenID Provider via the authorization URL, and makes a\n * request to the Token Endpoint, to obtain the access token, refresh token, etc.\n *\n * @param code - authorization code as returned by OP during authorization\n * @param state - authorization state param as returned by OP during authorization\n * @param responseMode - the response mode used for authentication\n * @returns valid bearer token response\n * @throws An `Error` with `message` set to an entry in {@link OidcError},\n * when the request fails, or the returned token response is invalid.\n */\nexport const completeAuthorizationCodeGrant = async (\n code: string,\n state: string,\n responseMode: SigninRequestCreateArgs[\"response_mode\"] = \"query\",\n): Promise<{\n oidcClientSettings: { clientId: string; issuer: string };\n tokenResponse: BearerTokenResponse;\n homeserverUrl: string;\n idTokenClaims: IdTokenClaims;\n identityServerUrl?: string;\n}> => {\n /**\n * Element Web strips and changes the url on starting the app\n * Use the code and state from query params to rebuild a url\n * so that oidc-client can parse it\n */\n const reconstructedUrl = new URL(window.location.origin);\n\n const params = new URLSearchParams({ code, state });\n if (responseMode === \"query\") {\n reconstructedUrl.search = params.toString();\n } else {\n reconstructedUrl.hash = `#${params.toString()}`;\n }\n\n // set oidc-client to use our logger\n Log.setLogger(logger);\n try {\n const response = new SigninResponse(params);\n\n const stateStore = new WebStorageStateStore({ prefix: \"mx_oidc_\", store: window.sessionStorage });\n\n // retrieve the state we put in storage at the start of oidc auth flow\n const stateString = await stateStore.get(response.state!);\n if (!stateString) {\n throw new Error(OidcError.MissingOrInvalidStoredState);\n }\n\n // hydrate the sign in state and create a client\n // the stored sign in state includes oidc configuration we set at the start of the oidc login flow\n const signInState = await SigninState.fromStorageString(stateString);\n const client = new OidcClient({ ...signInState, stateStore });\n\n // validate the code and state, and attempt to swap the code for tokens\n const signinResponse = await client.processSigninResponse(reconstructedUrl.href);\n\n // extra values we stored at the start of the login flow\n // used to complete login in the client\n const userState = signinResponse.userState;\n validateStoredUserState(userState);\n\n // throws when response is invalid\n validateBearerTokenResponse(signinResponse);\n if (signinResponse.id_token) {\n // The token is not yet in the Matrix spec so consider it optional\n // throws when token is invalid\n validateIdToken(\n signinResponse.id_token,\n client.settings.authority,\n client.settings.client_id,\n userState.nonce,\n );\n }\n const normalizedTokenResponse = normalizeBearerTokenResponseTokenType(signinResponse);\n\n return {\n oidcClientSettings: {\n clientId: client.settings.client_id,\n issuer: client.settings.authority,\n },\n tokenResponse: normalizedTokenResponse,\n homeserverUrl: userState.homeserverUrl,\n identityServerUrl: userState.identityServerUrl,\n idTokenClaims: signinResponse.profile,\n };\n } catch (error) {\n logger.error(\"Oidc login failed\", error);\n const errorType = (error as Error).message;\n\n // rethrow errors that we recognise\n if (Object.values(OidcError).includes(errorType as any)) {\n throw error;\n }\n throw new Error(OidcError.CodeExchangeFailed);\n }\n};\n\n/**\n * Response from the OIDC token endpoint when exchanging a token for grant_type device_code.\n */\nexport interface DeviceAccessTokenResponse {\n id_token?: string;\n access_token: string;\n token_type: string;\n refresh_token?: string;\n scope?: string;\n expires_in?: number;\n session_state?: string;\n}\n\n/**\n * Error from the OIDC token endpoint when exchanging a token for grant_type device_code.\n */\nexport interface DeviceAccessTokenError {\n error: string;\n error_description?: string;\n error_uri?: string;\n session_state?: string;\n}\n\n/**\n * Response from the OIDC device authorization endpoint.\n */\nexport interface DeviceAuthorizationResponse {\n device_code: string;\n user_code: string;\n verification_uri: string;\n verification_uri_complete?: string;\n expires_in: number;\n interval?: number;\n}\n\n/**\n * Begin OIDC device authorization flow.\n * @param options - The device authorization parameters.\n * @param options.clientId - the client ID returned from client registration.\n * @param options.scope - the scope to request for authorization.\n * @param options.metadata - the validated OIDC metadata for the Identity Provider.\n * @returns a promise that resolves to a device access token response,\n * or an error response if the user denies authorization or the device code expires.\n */\nexport const startDeviceAuthorization = async ({\n clientId,\n scope,\n metadata,\n}: {\n clientId: string;\n scope: string;\n metadata: ValidatedAuthMetadata;\n}): Promise<DeviceAuthorizationResponse> => {\n const body = new URLSearchParams({ client_id: clientId, scope: scope }).toString();\n\n const url = metadata.device_authorization_endpoint;\n if (!url) {\n throw new Error(\"No device_authorization_endpoint given\");\n }\n\n const response = await fetch(url, {\n method: Method.Post,\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n body,\n });\n\n return (await response.json()) as DeviceAuthorizationResponse;\n};\n\n/**\n * Polls the OIDC token endpoint until we get a device access token response, or encounter an unrecoverable error.\n * @param options - The device authorization parameters.\n * @param options.session - The session returned from a previous call to {@link startDeviceAuthorization}.\n * @param options.metadata - The validated OIDC metadata for the Identity Provider.\n * @param options.clientId - The client ID returned from client registration.\n * @returns a promise that resolves to a device access token response,\n * or an error response if the user denies authorization or the device code expires.\n */\nexport const waitForDeviceAuthorization = async ({\n session,\n metadata,\n clientId,\n}: {\n session: DeviceAuthorizationResponse;\n metadata: ValidatedAuthMetadata;\n clientId: string;\n}): Promise<DeviceAccessTokenResponse | DeviceAccessTokenError> => {\n let interval = (session.interval ?? 5) * 1000; // poll interval\n const expiration = Date.now() + session.expires_in * 1000;\n do {\n const body = new URLSearchParams({\n device_code: session.device_code,\n grant_type: OAuthGrantType.DeviceAuthorization,\n client_id: clientId,\n }).toString();\n const response = await fetch(metadata.token_endpoint, {\n method: Method.Post,\n headers: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n body,\n });\n\n if (response.ok) {\n return (await response.json()) as DeviceAccessTokenResponse;\n }\n const errorResponse = (await response.json()) as DeviceAccessTokenError;\n switch (errorResponse.error) {\n case \"authorization_pending\":\n break;\n case \"slow_down\":\n interval += 5000;\n break;\n case \"access_denied\":\n case \"expired_token\":\n return errorResponse;\n }\n await sleep(interval);\n } while (Date.now() < expiration);\n return { error: \"expired\" };\n};\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAEI,GAAG,EACH,UAAU,EAEV,cAAc,EACd,WAAW,EACX,oBAAoB,QACjB,gBAAgB;AAEvB,SAAS,MAAM,QAAQ,cAAc;AACrC,SAAS,kBAAkB,QAAQ,oBAAoB;AACvD,SAAS,SAAS,QAAQ,YAAY;AACtC,SAGI,2BAA2B,EAE3B,eAAe,EACf,uBAAuB,QACpB,eAAe;AACtB,SAAS,MAAM,QAAQ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AC/C,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI;EACzD,GAAG;IACC,MAAM,IAAI,GAAG,IAAI,eAAe,CAAC;MAC7B,WAAW,EAAE,OAAO,CAAC,WAAW;MAChC,UAAU,EAAE,cAAc,CAAC,mBAAmB;MAC9C,SAAS,EAAE;IACf,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IACb,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,cAAc,EAAE;MAClD,MAAM,EAAE,MAAM,CAAC,IAAI;MACnB,OAAO,EAAE;QAAE,cAAc,EAAE;MAAoC,CAAC;MAChE;IACJ,CAAC,CAAC;IAEF,IAAI,QAAQ,CAAC,EAAE,EAAE;MACb,OAAQ,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjC;IACA,MAAM,aAAa,GAAI,MAAM,QAAQ,CAAC,IAAI,CAAC,CAA4B;IACvE,QAAQ,aAAa,CAAC,KAAK;MACvB,KAAK,uBAAuB;QACxB;MACJ,KAAK,WAAW;QACZ,QAAQ,IAAI,IAAI;QAChB;MACJ,KAAK,eAAe;MACpB,KAAK,eAAe;QAChB,OAAO,aAAa;IAC5B;IACA,MAAM,KAAK,CAAC,QAAQ,CAAC;EACzB,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU;EAChC,OAAO;IAAE,KAAK,EAAE;EAAU,CAAC;AAC/B,CAAC","ignoreList":[]}
@@ -1,22 +0,0 @@
1
- import { type OidcClientConfig } from "./index.ts";
2
- /**
3
- * @experimental
4
- * Discover and validate delegated auth configuration
5
- * - delegated auth issuer openid-configuration is reachable
6
- * - delegated auth issuer openid-configuration is configured correctly for us
7
- * Fetches https://oidc-issuer.example.com/.well-known/openid-configuration and other files linked therein.
8
- * When successful, validated metadata is returned
9
- * @param issuer - the OIDC issuer as returned by the /auth_issuer API
10
- * @returns validated authentication metadata and optionally signing keys
11
- * @throws when delegated auth config is invalid or unreachable
12
- * @deprecated in favour of {@link MatrixClient#getAuthMetadata}
13
- */
14
- export declare const discoverAndValidateOIDCIssuerWellKnown: (issuer: string) => Promise<OidcClientConfig>;
15
- /**
16
- * @experimental
17
- * Validate the authentication metadata and fetch the signing keys from the jwks_uri in the metadata
18
- * @param authMetadata - the authentication metadata to validate
19
- * @returns validated authentication metadata and signing keys
20
- */
21
- export declare const validateAuthMetadataAndKeys: (authMetadata: unknown) => Promise<OidcClientConfig>;
22
- //# sourceMappingURL=discovery.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/oidc/discovery.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sCAAsC,GAAU,QAAQ,MAAM,KAAG,OAAO,CAAC,gBAAgB,CAQrG,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,GAAU,cAAc,OAAO,KAAG,OAAO,CAAC,gBAAgB,CAgBjG,CAAC"}
@@ -1,65 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/objectSpread2";
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 { MetadataService, OidcClientSettingsStore } from "oidc-client-ts";
19
- import { validateAuthMetadata } from "./validate.js";
20
- import { Method, timeoutSignal } from "../http-api/index.js";
21
- /**
22
- * @experimental
23
- * Discover and validate delegated auth configuration
24
- * - delegated auth issuer openid-configuration is reachable
25
- * - delegated auth issuer openid-configuration is configured correctly for us
26
- * Fetches https://oidc-issuer.example.com/.well-known/openid-configuration and other files linked therein.
27
- * When successful, validated metadata is returned
28
- * @param issuer - the OIDC issuer as returned by the /auth_issuer API
29
- * @returns validated authentication metadata and optionally signing keys
30
- * @throws when delegated auth config is invalid or unreachable
31
- * @deprecated in favour of {@link MatrixClient#getAuthMetadata}
32
- */
33
- export const discoverAndValidateOIDCIssuerWellKnown = async issuer => {
34
- const issuerOpenIdConfigUrl = new URL(".well-known/openid-configuration", issuer);
35
- const issuerWellKnownResponse = await fetch(issuerOpenIdConfigUrl, {
36
- method: Method.Get,
37
- signal: timeoutSignal(5000)
38
- });
39
- const issuerWellKnown = await issuerWellKnownResponse.json();
40
- return validateAuthMetadataAndKeys(issuerWellKnown);
41
- };
42
-
43
- /**
44
- * @experimental
45
- * Validate the authentication metadata and fetch the signing keys from the jwks_uri in the metadata
46
- * @param authMetadata - the authentication metadata to validate
47
- * @returns validated authentication metadata and signing keys
48
- */
49
- export const validateAuthMetadataAndKeys = async authMetadata => {
50
- const validatedIssuerConfig = validateAuthMetadata(authMetadata);
51
-
52
- // create a temporary settings store, so we can use metadata service for discovery
53
- const settings = new OidcClientSettingsStore({
54
- authority: validatedIssuerConfig.issuer,
55
- metadata: validatedIssuerConfig,
56
- redirect_uri: "",
57
- // Not known yet, this is here to make the type checker happy
58
- client_id: "" // Not known yet, this is here to make the type checker happy
59
- });
60
- const metadataService = new MetadataService(settings);
61
- return _objectSpread(_objectSpread({}, validatedIssuerConfig), {}, {
62
- signingKeys: validatedIssuerConfig.jwks_uri ? await metadataService.getSigningKeys() : null
63
- });
64
- };
65
- //# sourceMappingURL=discovery.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"discovery.js","names":[],"sources":["../../src/oidc/discovery.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 { MetadataService, OidcClientSettingsStore } from \"oidc-client-ts\";\n\nimport { validateAuthMetadata } from \"./validate.ts\";\nimport { Method, timeoutSignal } from \"../http-api/index.ts\";\nimport { type OidcClientConfig } from \"./index.ts\";\n\n/**\n * @experimental\n * Discover and validate delegated auth configuration\n * - delegated auth issuer openid-configuration is reachable\n * - delegated auth issuer openid-configuration is configured correctly for us\n * Fetches https://oidc-issuer.example.com/.well-known/openid-configuration and other files linked therein.\n * When successful, validated metadata is returned\n * @param issuer - the OIDC issuer as returned by the /auth_issuer API\n * @returns validated authentication metadata and optionally signing keys\n * @throws when delegated auth config is invalid or unreachable\n * @deprecated in favour of {@link MatrixClient#getAuthMetadata}\n */\nexport const discoverAndValidateOIDCIssuerWellKnown = async (issuer: string): Promise<OidcClientConfig> => {\n const issuerOpenIdConfigUrl = new URL(\".well-known/openid-configuration\", issuer);\n const issuerWellKnownResponse = await fetch(issuerOpenIdConfigUrl, {\n method: Method.Get,\n signal: timeoutSignal(5000),\n });\n const issuerWellKnown = await issuerWellKnownResponse.json();\n return validateAuthMetadataAndKeys(issuerWellKnown);\n};\n\n/**\n * @experimental\n * Validate the authentication metadata and fetch the signing keys from the jwks_uri in the metadata\n * @param authMetadata - the authentication metadata to validate\n * @returns validated authentication metadata and signing keys\n */\nexport const validateAuthMetadataAndKeys = async (authMetadata: unknown): Promise<OidcClientConfig> => {\n const validatedIssuerConfig = validateAuthMetadata(authMetadata);\n\n // create a temporary settings store, so we can use metadata service for discovery\n const settings = new OidcClientSettingsStore({\n authority: validatedIssuerConfig.issuer,\n metadata: validatedIssuerConfig,\n redirect_uri: \"\", // Not known yet, this is here to make the type checker happy\n client_id: \"\", // Not known yet, this is here to make the type checker happy\n });\n const metadataService = new MetadataService(settings);\n\n return {\n ...validatedIssuerConfig,\n signingKeys: validatedIssuerConfig.jwks_uri ? await metadataService.getSigningKeys() : null,\n };\n};\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAS,eAAe,EAAE,uBAAuB,QAAQ,gBAAgB;AAEzE,SAAS,oBAAoB,QAAQ,eAAe;AACpD,SAAS,MAAM,EAAE,aAAa,QAAQ,sBAAsB;AAG5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM,sCAAsC,GAAG,MAAO,MAAc,IAAgC;EACvG,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,kCAAkC,EAAE,MAAM,CAAC;EACjF,MAAM,uBAAuB,GAAG,MAAM,KAAK,CAAC,qBAAqB,EAAE;IAC/D,MAAM,EAAE,MAAM,CAAC,GAAG;IAClB,MAAM,EAAE,aAAa,CAAC,IAAI;EAC9B,CAAC,CAAC;EACF,MAAM,eAAe,GAAG,MAAM,uBAAuB,CAAC,IAAI,CAAC,CAAC;EAC5D,OAAO,2BAA2B,CAAC,eAAe,CAAC;AACvD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM,2BAA2B,GAAG,MAAO,YAAqB,IAAgC;EACnG,MAAM,qBAAqB,GAAG,oBAAoB,CAAC,YAAY,CAAC;;EAEhE;EACA,MAAM,QAAQ,GAAG,IAAI,uBAAuB,CAAC;IACzC,SAAS,EAAE,qBAAqB,CAAC,MAAM;IACvC,QAAQ,EAAE,qBAAqB;IAC/B,YAAY,EAAE,EAAE;IAAE;IAClB,SAAS,EAAE,EAAE,CAAE;EACnB,CAAC,CAAC;EACF,MAAM,eAAe,GAAG,IAAI,eAAe,CAAC,QAAQ,CAAC;EAErD,uCACO,qBAAqB;IACxB,WAAW,EAAE,qBAAqB,CAAC,QAAQ,GAAG,MAAM,eAAe,CAAC,cAAc,CAAC,CAAC,GAAG;EAAI;AAEnG,CAAC","ignoreList":[]}
@@ -1,18 +0,0 @@
1
- /**
2
- * Errors expected to be encountered during OIDC discovery, client registration, and authentication.
3
- * Not intended to be displayed directly to the user.
4
- */
5
- export declare enum OidcError {
6
- NotSupported = "OIDC authentication not supported",
7
- Misconfigured = "OIDC is misconfigured",
8
- General = "Something went wrong with OIDC discovery",
9
- OpSupport = "Configured OIDC OP does not support required functions",
10
- DynamicRegistrationNotSupported = "Dynamic registration not supported",
11
- DynamicRegistrationFailed = "Dynamic registration failed",
12
- DynamicRegistrationInvalid = "Dynamic registration invalid response",
13
- CodeExchangeFailed = "Failed to exchange code for token",
14
- InvalidBearerTokenResponse = "Invalid bearer token response",
15
- InvalidIdToken = "Invalid ID token",
16
- MissingOrInvalidStoredState = "State required to finish logging in is not found in storage."
17
- }
18
- //# sourceMappingURL=error.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/oidc/error.ts"],"names":[],"mappings":"AAgBA;;;GAGG;AACH,oBAAY,SAAS;IACjB,YAAY,sCAAsC;IAClD,aAAa,0BAA0B;IACvC,OAAO,6CAA6C;IACpD,SAAS,2DAA2D;IACpE,+BAA+B,uCAAuC;IACtE,yBAAyB,gCAAgC;IACzD,0BAA0B,0CAA0C;IACpE,kBAAkB,sCAAsC;IACxD,0BAA0B,kCAAkC;IAC5D,cAAc,qBAAqB;IACnC,2BAA2B,iEAAiE;CAC/F"}
package/lib/oidc/error.js DELETED
@@ -1,35 +0,0 @@
1
- /*
2
- Copyright 2023 The Matrix.org Foundation C.I.C.
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- /**
18
- * Errors expected to be encountered during OIDC discovery, client registration, and authentication.
19
- * Not intended to be displayed directly to the user.
20
- */
21
- export let OidcError = /*#__PURE__*/function (OidcError) {
22
- OidcError["NotSupported"] = "OIDC authentication not supported";
23
- OidcError["Misconfigured"] = "OIDC is misconfigured";
24
- OidcError["General"] = "Something went wrong with OIDC discovery";
25
- OidcError["OpSupport"] = "Configured OIDC OP does not support required functions";
26
- OidcError["DynamicRegistrationNotSupported"] = "Dynamic registration not supported";
27
- OidcError["DynamicRegistrationFailed"] = "Dynamic registration failed";
28
- OidcError["DynamicRegistrationInvalid"] = "Dynamic registration invalid response";
29
- OidcError["CodeExchangeFailed"] = "Failed to exchange code for token";
30
- OidcError["InvalidBearerTokenResponse"] = "Invalid bearer token response";
31
- OidcError["InvalidIdToken"] = "Invalid ID token";
32
- OidcError["MissingOrInvalidStoredState"] = "State required to finish logging in is not found in storage.";
33
- return OidcError;
34
- }({});
35
- //# sourceMappingURL=error.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error.js","names":[],"sources":["../../src/oidc/error.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\n/**\n * Errors expected to be encountered during OIDC discovery, client registration, and authentication.\n * Not intended to be displayed directly to the user.\n */\nexport enum OidcError {\n NotSupported = \"OIDC authentication not supported\",\n Misconfigured = \"OIDC is misconfigured\",\n General = \"Something went wrong with OIDC discovery\",\n OpSupport = \"Configured OIDC OP does not support required functions\",\n DynamicRegistrationNotSupported = \"Dynamic registration not supported\",\n DynamicRegistrationFailed = \"Dynamic registration failed\",\n DynamicRegistrationInvalid = \"Dynamic registration invalid response\",\n CodeExchangeFailed = \"Failed to exchange code for token\",\n InvalidBearerTokenResponse = \"Invalid bearer token response\",\n InvalidIdToken = \"Invalid ID token\",\n MissingOrInvalidStoredState = \"State required to finish logging in is not found in storage.\",\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAY,SAAS,0BAAT,SAAS;EAAT,SAAS;EAAT,SAAS;EAAT,SAAS;EAAT,SAAS;EAAT,SAAS;EAAT,SAAS;EAAT,SAAS;EAAT,SAAS;EAAT,SAAS;EAAT,SAAS;EAAT,SAAS;EAAA,OAAT,SAAS;AAAA","ignoreList":[]}
@@ -1,16 +0,0 @@
1
- import type { SigningKey } from "oidc-client-ts";
2
- import { type ValidatedAuthMetadata } from "./validate.ts";
3
- export * from "./authorize.ts";
4
- export * from "./discovery.ts";
5
- export * from "./error.ts";
6
- export * from "./register.ts";
7
- export * from "./tokenRefresher.ts";
8
- export * from "./validate.ts";
9
- /**
10
- * Validated config for native OIDC authentication, as returned by {@link discoverAndValidateOIDCIssuerWellKnown}.
11
- * Contains metadata and signing keys from the issuer's well-known (https://oidc-issuer.example.com/.well-known/openid-configuration).
12
- */
13
- export interface OidcClientConfig extends ValidatedAuthMetadata {
14
- signingKeys: SigningKey[] | null;
15
- }
16
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/oidc/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAE9B;;;GAGG;AACH,MAAM,WAAW,gBAAiB,SAAQ,qBAAqB;IAC3D,WAAW,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;CACpC"}
package/lib/oidc/index.js DELETED
@@ -1,30 +0,0 @@
1
- /*
2
- Copyright 2023 The Matrix.org Foundation C.I.C.
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- export * from "./authorize.js";
18
- export * from "./discovery.js";
19
- export * from "./error.js";
20
- export * from "./register.js";
21
- export * from "./tokenRefresher.js";
22
- export * from "./validate.js";
23
-
24
- /**
25
- * Validated config for native OIDC authentication, as returned by {@link discoverAndValidateOIDCIssuerWellKnown}.
26
- * Contains metadata and signing keys from the issuer's well-known (https://oidc-issuer.example.com/.well-known/openid-configuration).
27
- */
28
- export {};
29
- export {};
30
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/oidc/index.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport type { SigningKey } from \"oidc-client-ts\";\nimport { type ValidatedAuthMetadata } from \"./validate.ts\";\n\nexport * from \"./authorize.ts\";\nexport * from \"./discovery.ts\";\nexport * from \"./error.ts\";\nexport * from \"./register.ts\";\nexport * from \"./tokenRefresher.ts\";\nexport * from \"./validate.ts\";\n\n/**\n * Validated config for native OIDC authentication, as returned by {@link discoverAndValidateOIDCIssuerWellKnown}.\n * Contains metadata and signing keys from the issuer's well-known (https://oidc-issuer.example.com/.well-known/openid-configuration).\n */\nexport interface OidcClientConfig extends ValidatedAuthMetadata {\n signingKeys: SigningKey[] | null;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,qBAAqB;AACnC,cAAc,eAAe;;AAE7B;AACA;AACA;AACA;AAHA;AAAA","ignoreList":[]}
@@ -1,70 +0,0 @@
1
- import { type OidcClientConfig } from "./index.ts";
2
- import { type NonEmptyArray } from "../@types/common.ts";
3
- /**
4
- * Client metadata passed to registration endpoint
5
- */
6
- export type OidcRegistrationClientMetadata = {
7
- clientName: OidcRegistrationRequestBody["client_name"];
8
- clientUri: OidcRegistrationRequestBody["client_uri"];
9
- logoUri?: OidcRegistrationRequestBody["logo_uri"];
10
- applicationType: OidcRegistrationRequestBody["application_type"];
11
- redirectUris: OidcRegistrationRequestBody["redirect_uris"];
12
- contacts: OidcRegistrationRequestBody["contacts"];
13
- tosUri: OidcRegistrationRequestBody["tos_uri"];
14
- policyUri: OidcRegistrationRequestBody["policy_uri"];
15
- };
16
- /**
17
- * Request body for dynamic registration as defined by https://github.com/matrix-org/matrix-spec-proposals/pull/2966
18
- */
19
- interface OidcRegistrationRequestBody {
20
- client_name?: string;
21
- client_uri: string;
22
- logo_uri?: string;
23
- contacts?: string[];
24
- tos_uri?: string;
25
- policy_uri?: string;
26
- redirect_uris?: NonEmptyArray<string>;
27
- response_types?: NonEmptyArray<string>;
28
- grant_types?: NonEmptyArray<string>;
29
- id_token_signed_response_alg?: string;
30
- token_endpoint_auth_method: string;
31
- application_type: "web" | "native";
32
- }
33
- /**
34
- * The OAuth 2.0 grant types that are defined for Matrix in https://spec.matrix.org/v1.17/client-server-api/#grant-types
35
- */
36
- export declare enum OAuthGrantType {
37
- /**
38
- * See https://spec.matrix.org/v1.17/client-server-api/#authorization-code-grant
39
- */
40
- AuthorizationCode = "authorization_code",
41
- /**
42
- * https://spec.matrix.org/v1.17/client-server-api/#refresh-token-grant
43
- */
44
- RefreshToken = "refresh_token",
45
- /**
46
- * The OAuth 2.0 Device Authorization Grant type identifier as per
47
- * https://www.rfc-editor.org/rfc/rfc8628.html#section-7.2 from
48
- * [MSC4341](https://github.com/matrix-org/matrix-spec-proposals/pull/4341).
49
- *
50
- * @experimental Note that this is UNSTABLE and may have breaking changes without notice.
51
- */
52
- DeviceAuthorization = "urn:ietf:params:oauth:grant-type:device_code"
53
- }
54
- /**
55
- * The name "scope" is a misnomer here as it is actually a "grant type".
56
- *
57
- * @deprecated use `OAuthGrantType.DeviceAuthorization` instead
58
- */
59
- export declare const DEVICE_CODE_SCOPE: string;
60
- /**
61
- * Attempts dynamic registration against the configured registration endpoint.
62
- * Will ignore any URIs that do not use client_uri as a common base as per the spec.
63
- * @param delegatedAuthConfig - Auth config from {@link discoverAndValidateOIDCIssuerWellKnown}
64
- * @param clientMetadata - The metadata for the client which to register
65
- * @returns Promise<string> resolved with registered clientId
66
- * @throws when registration is not supported, on failed request or invalid response
67
- */
68
- export declare const registerOidcClient: (delegatedAuthConfig: OidcClientConfig, clientMetadata: OidcRegistrationClientMetadata) => Promise<string>;
69
- export {};
70
- //# sourceMappingURL=register.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../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IACH,YAAY,kBAAkB;IAC9B;;;;;;OAMG;IACH,mBAAmB,iDAAiD;CACvE;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAA2C,CAAC;AAW5E;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAC3B,qBAAqB,gBAAgB,EACrC,gBAAgB,8BAA8B,KAC/C,OAAO,CAAC,MAAM,CAgEhB,CAAC"}
@@ -1,134 +0,0 @@
1
- /*
2
- Copyright 2023 The Matrix.org Foundation C.I.C.
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import { OidcError } from "./error.js";
18
- import { Method } from "../http-api/index.js";
19
- import { logger } from "../logger.js";
20
-
21
- /**
22
- * Client metadata passed to registration endpoint
23
- */
24
-
25
- /**
26
- * Request body for dynamic registration as defined by https://github.com/matrix-org/matrix-spec-proposals/pull/2966
27
- */
28
-
29
- /**
30
- * The OAuth 2.0 grant types that are defined for Matrix in https://spec.matrix.org/v1.17/client-server-api/#grant-types
31
- */
32
- export let OAuthGrantType = /*#__PURE__*/function (OAuthGrantType) {
33
- /**
34
- * See https://spec.matrix.org/v1.17/client-server-api/#authorization-code-grant
35
- */
36
- OAuthGrantType["AuthorizationCode"] = "authorization_code";
37
- /**
38
- * https://spec.matrix.org/v1.17/client-server-api/#refresh-token-grant
39
- */
40
- OAuthGrantType["RefreshToken"] = "refresh_token";
41
- /**
42
- * The OAuth 2.0 Device Authorization Grant type identifier as per
43
- * https://www.rfc-editor.org/rfc/rfc8628.html#section-7.2 from
44
- * [MSC4341](https://github.com/matrix-org/matrix-spec-proposals/pull/4341).
45
- *
46
- * @experimental Note that this is UNSTABLE and may have breaking changes without notice.
47
- */
48
- OAuthGrantType["DeviceAuthorization"] = "urn:ietf:params:oauth:grant-type:device_code";
49
- return OAuthGrantType;
50
- }({});
51
-
52
- /**
53
- * The name "scope" is a misnomer here as it is actually a "grant type".
54
- *
55
- * @deprecated use `OAuthGrantType.DeviceAuthorization` instead
56
- */
57
- export const DEVICE_CODE_SCOPE = OAuthGrantType.DeviceAuthorization;
58
-
59
- // Check that URIs have a common base, as per the MSC2966 definition
60
- const urlHasCommonBase = (base, urlStr) => {
61
- if (!urlStr) return false;
62
- const url = new URL(urlStr);
63
- if (url.protocol !== base.protocol) return false;
64
- if (url.hostname !== base.hostname && !url.hostname.endsWith(`.${base.hostname}`)) return false;
65
- return true;
66
- };
67
-
68
- /**
69
- * Attempts dynamic registration against the configured registration endpoint.
70
- * Will ignore any URIs that do not use client_uri as a common base as per the spec.
71
- * @param delegatedAuthConfig - Auth config from {@link discoverAndValidateOIDCIssuerWellKnown}
72
- * @param clientMetadata - The metadata for the client which to register
73
- * @returns Promise<string> resolved with registered clientId
74
- * @throws when registration is not supported, on failed request or invalid response
75
- */
76
- export const registerOidcClient = async (delegatedAuthConfig, clientMetadata) => {
77
- if (!delegatedAuthConfig.registration_endpoint) {
78
- throw new Error(OidcError.DynamicRegistrationNotSupported);
79
- }
80
- const grantTypes = [OAuthGrantType.AuthorizationCode, OAuthGrantType.RefreshToken];
81
- if (grantTypes.some(scope => !delegatedAuthConfig.grant_types_supported.includes(scope))) {
82
- throw new Error(OidcError.DynamicRegistrationNotSupported);
83
- }
84
-
85
- // ask for device authorization grant if supported
86
- if (delegatedAuthConfig.grant_types_supported.includes(OAuthGrantType.DeviceAuthorization)) {
87
- grantTypes.push(OAuthGrantType.DeviceAuthorization);
88
- }
89
- const commonBase = new URL(clientMetadata.clientUri);
90
-
91
- // https://openid.net/specs/openid-connect-registration-1_0.html
92
- const metadata = {
93
- client_name: clientMetadata.clientName,
94
- client_uri: clientMetadata.clientUri,
95
- response_types: ["code"],
96
- grant_types: grantTypes,
97
- redirect_uris: clientMetadata.redirectUris,
98
- id_token_signed_response_alg: "RS256",
99
- token_endpoint_auth_method: "none",
100
- application_type: clientMetadata.applicationType,
101
- contacts: clientMetadata.contacts,
102
- logo_uri: urlHasCommonBase(commonBase, clientMetadata.logoUri) ? clientMetadata.logoUri : undefined,
103
- policy_uri: urlHasCommonBase(commonBase, clientMetadata.policyUri) ? clientMetadata.policyUri : undefined,
104
- tos_uri: urlHasCommonBase(commonBase, clientMetadata.tosUri) ? clientMetadata.tosUri : undefined
105
- };
106
- const headers = {
107
- "Accept": "application/json",
108
- "Content-Type": "application/json"
109
- };
110
- try {
111
- const response = await fetch(delegatedAuthConfig.registration_endpoint, {
112
- method: Method.Post,
113
- headers,
114
- body: JSON.stringify(metadata)
115
- });
116
- if (response.status >= 400) {
117
- throw new Error(OidcError.DynamicRegistrationFailed);
118
- }
119
- const body = await response.json();
120
- const clientId = body["client_id"];
121
- if (!clientId || typeof clientId !== "string") {
122
- throw new Error(OidcError.DynamicRegistrationInvalid);
123
- }
124
- return clientId;
125
- } catch (error) {
126
- if (Object.values(OidcError).includes(error.message)) {
127
- throw error;
128
- } else {
129
- logger.error("Dynamic registration request failed", error);
130
- throw new Error(OidcError.DynamicRegistrationFailed);
131
- }
132
- }
133
- };
134
- //# sourceMappingURL=register.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register.js","names":[],"sources":["../../src/oidc/register.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 OidcClientConfig } from \"./index.ts\";\nimport { OidcError } from \"./error.ts\";\nimport { Method } from \"../http-api/index.ts\";\nimport { logger } from \"../logger.ts\";\nimport { type NonEmptyArray } from \"../@types/common.ts\";\n\n/**\n * Client metadata passed to registration endpoint\n */\nexport type OidcRegistrationClientMetadata = {\n clientName: OidcRegistrationRequestBody[\"client_name\"];\n clientUri: OidcRegistrationRequestBody[\"client_uri\"];\n logoUri?: OidcRegistrationRequestBody[\"logo_uri\"];\n applicationType: OidcRegistrationRequestBody[\"application_type\"];\n redirectUris: OidcRegistrationRequestBody[\"redirect_uris\"];\n contacts: OidcRegistrationRequestBody[\"contacts\"];\n tosUri: OidcRegistrationRequestBody[\"tos_uri\"];\n policyUri: OidcRegistrationRequestBody[\"policy_uri\"];\n};\n\n/**\n * Request body for dynamic registration as defined by https://github.com/matrix-org/matrix-spec-proposals/pull/2966\n */\ninterface OidcRegistrationRequestBody {\n client_name?: string;\n client_uri: string;\n logo_uri?: string;\n contacts?: string[];\n tos_uri?: string;\n policy_uri?: string;\n redirect_uris?: NonEmptyArray<string>;\n response_types?: NonEmptyArray<string>;\n grant_types?: NonEmptyArray<string>;\n id_token_signed_response_alg?: string;\n token_endpoint_auth_method: string;\n application_type: \"web\" | \"native\";\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 * See https://spec.matrix.org/v1.17/client-server-api/#authorization-code-grant\n */\n AuthorizationCode = \"authorization_code\",\n /**\n * https://spec.matrix.org/v1.17/client-server-api/#refresh-token-grant\n */\n RefreshToken = \"refresh_token\",\n /**\n * The OAuth 2.0 Device Authorization Grant type identifier as per\n * https://www.rfc-editor.org/rfc/rfc8628.html#section-7.2 from\n * [MSC4341](https://github.com/matrix-org/matrix-spec-proposals/pull/4341).\n *\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\n DeviceAuthorization = \"urn:ietf:params:oauth:grant-type:device_code\",\n}\n\n/**\n * The name \"scope\" is a misnomer here as it is actually a \"grant type\".\n *\n * @deprecated use `OAuthGrantType.DeviceAuthorization` instead\n */\nexport const DEVICE_CODE_SCOPE: string = OAuthGrantType.DeviceAuthorization;\n\n// Check that URIs have a common base, as per the MSC2966 definition\nconst 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 * Attempts dynamic registration against the configured registration endpoint.\n * Will ignore any URIs that do not use client_uri as a common base as per the spec.\n * @param delegatedAuthConfig - Auth config from {@link discoverAndValidateOIDCIssuerWellKnown}\n * @param clientMetadata - The metadata for the client which to register\n * @returns Promise<string> resolved with registered clientId\n * @throws when registration is not supported, on failed request or invalid response\n */\nexport const registerOidcClient = async (\n delegatedAuthConfig: OidcClientConfig,\n clientMetadata: OidcRegistrationClientMetadata,\n): Promise<string> => {\n if (!delegatedAuthConfig.registration_endpoint) {\n throw new Error(OidcError.DynamicRegistrationNotSupported);\n }\n\n const grantTypes: NonEmptyArray<string> = [OAuthGrantType.AuthorizationCode, OAuthGrantType.RefreshToken];\n if (grantTypes.some((scope) => !delegatedAuthConfig.grant_types_supported.includes(scope))) {\n throw new Error(OidcError.DynamicRegistrationNotSupported);\n }\n\n // ask for device authorization grant if supported\n if (delegatedAuthConfig.grant_types_supported.includes(OAuthGrantType.DeviceAuthorization)) {\n grantTypes.push(OAuthGrantType.DeviceAuthorization);\n }\n\n const commonBase = new URL(clientMetadata.clientUri);\n\n // https://openid.net/specs/openid-connect-registration-1_0.html\n const metadata: OidcRegistrationRequestBody = {\n client_name: clientMetadata.clientName,\n client_uri: clientMetadata.clientUri,\n response_types: [\"code\"],\n grant_types: grantTypes,\n redirect_uris: clientMetadata.redirectUris,\n id_token_signed_response_alg: \"RS256\",\n token_endpoint_auth_method: \"none\",\n application_type: clientMetadata.applicationType,\n contacts: clientMetadata.contacts,\n logo_uri: urlHasCommonBase(commonBase, clientMetadata.logoUri) ? clientMetadata.logoUri : undefined,\n policy_uri: urlHasCommonBase(commonBase, clientMetadata.policyUri) ? clientMetadata.policyUri : undefined,\n tos_uri: urlHasCommonBase(commonBase, clientMetadata.tosUri) ? clientMetadata.tosUri : undefined,\n };\n\n const headers = {\n \"Accept\": \"application/json\",\n \"Content-Type\": \"application/json\",\n };\n\n try {\n const response = await fetch(delegatedAuthConfig.registration_endpoint, {\n method: Method.Post,\n headers,\n body: JSON.stringify(metadata),\n });\n\n if (response.status >= 400) {\n throw new Error(OidcError.DynamicRegistrationFailed);\n }\n\n const body = await response.json();\n const clientId = body[\"client_id\"];\n if (!clientId || typeof clientId !== \"string\") {\n throw new Error(OidcError.DynamicRegistrationInvalid);\n }\n\n return clientId;\n } catch (error) {\n if (Object.values(OidcError).includes((error as Error).message as OidcError)) {\n throw error;\n } else {\n logger.error(\"Dynamic registration request failed\", error);\n throw new Error(OidcError.DynamicRegistrationFailed);\n }\n }\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAAS,SAAS,QAAQ,YAAY;AACtC,SAAS,MAAM,QAAQ,sBAAsB;AAC7C,SAAS,MAAM,QAAQ,cAAc;;AAGrC;AACA;AACA;;AAYA;AACA;AACA;;AAgBA;AACA;AACA;AACA,WAAY,cAAc,0BAAd,cAAc;EACtB;AACJ;AACA;EAHY,cAAc;EAKtB;AACJ;AACA;EAPY,cAAc;EAStB;AACJ;AACA;AACA;AACA;AACA;AACA;EAfY,cAAc;EAAA,OAAd,cAAc;AAAA;;AAmB1B;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM,iBAAyB,GAAG,cAAc,CAAC,mBAAmB;;AAE3E;AACA,MAAM,gBAAgB,GAAG,CAAC,IAAS,EAAE,MAAe,KAAc;EAC9D,IAAI,CAAC,MAAM,EAAE,OAAO,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C,EAAE;MAC1E,MAAM,KAAK;IACf,CAAC,MAAM;MACH,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC;MAC1D,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,yBAAyB,CAAC;IACxD;EACJ;AACJ,CAAC","ignoreList":[]}
@@ -1,91 +0,0 @@
1
- import { type IdTokenClaims } from "oidc-client-ts";
2
- import { type AccessTokens } from "../http-api/index.ts";
3
- /**
4
- * @experimental
5
- * Class responsible for refreshing OIDC access tokens
6
- *
7
- * Client implementations will likely want to override {@link persistTokens} to persist tokens after successful refresh
8
- *
9
- */
10
- export declare class OidcTokenRefresher {
11
- /**
12
- * The OIDC issuer as returned by the /auth_issuer API
13
- */
14
- private issuer;
15
- /**
16
- * id of this client as registered with the OP
17
- */
18
- private clientId;
19
- /**
20
- * redirectUri as registered with OP
21
- */
22
- private redirectUri;
23
- /**
24
- * Device ID of current session
25
- */
26
- protected deviceId: string;
27
- /**
28
- * idTokenClaims as returned from authorization grant
29
- * used to validate tokens
30
- */
31
- private readonly idTokenClaims;
32
- /**
33
- * This is now just a resolved promise and will be removed in a future version.
34
- * Initialisation is done lazily at token refresh time.
35
- * @deprecated Consumers no longer need to wait for this promise.
36
- */
37
- readonly oidcClientReady: Promise<void>;
38
- private initPromise?;
39
- private oidcClient;
40
- private inflightRefreshRequest?;
41
- constructor(
42
- /**
43
- * The OIDC issuer as returned by the /auth_issuer API
44
- */
45
- issuer: string,
46
- /**
47
- * id of this client as registered with the OP
48
- */
49
- clientId: string,
50
- /**
51
- * redirectUri as registered with OP
52
- */
53
- redirectUri: string,
54
- /**
55
- * Device ID of current session
56
- */
57
- deviceId: string,
58
- /**
59
- * idTokenClaims as returned from authorization grant
60
- * used to validate tokens
61
- */
62
- idTokenClaims: IdTokenClaims);
63
- /**
64
- * Ensures that the client is initialised.
65
- * @returns Promise that resolves when initialisation is complete
66
- * @throws if initialisation fails
67
- */
68
- private ensureInit;
69
- private initialiseOidcClient;
70
- /**
71
- * Attempt token refresh using given refresh token
72
- * @param refreshToken - refresh token to use in request with token issuer
73
- * @returns tokens - Promise that resolves with new access and refresh tokens
74
- * @throws when token refresh fails
75
- */
76
- doRefreshAccessToken(refreshToken: string): Promise<AccessTokens>;
77
- /**
78
- * Persist the new tokens, called after tokens are successfully refreshed.
79
- *
80
- * This function is intended to be overriden by the consumer when persistence is necessary.
81
- *
82
- * @param tokens.accessToken - new access token
83
- * @param tokens.refreshToken - OPTIONAL new refresh token
84
- */
85
- protected persistTokens(tokens: {
86
- accessToken: string;
87
- refreshToken?: string;
88
- }): Promise<void>;
89
- private getNewTokens;
90
- }
91
- //# sourceMappingURL=tokenRefresher.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tokenRefresher.d.ts","sourceRoot":"","sources":["../../src/oidc/tokenRefresher.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,aAAa,EAAmD,MAAM,gBAAgB,CAAC;AAErG,OAAO,EAAE,KAAK,YAAY,EAA2B,MAAM,sBAAsB,CAAC;AAKlF;;;;;;GAMG;AACH,qBAAa,kBAAkB;IAevB;;OAEG;IACH,OAAO,CAAC,MAAM;IACd;;OAEG;IACH,OAAO,CAAC,QAAQ;IAChB;;OAEG;IACH,OAAO,CAAC,WAAW;IACnB;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM;IAC1B;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa;IAlClC;;;;OAIG;IACH,SAAgB,eAAe,EAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAGhD,OAAO,CAAC,WAAW,CAAC,CAAgB;IAEpC,OAAO,CAAC,UAAU,CAAc;IAChC,OAAO,CAAC,sBAAsB,CAAC,CAAwB;;IAGnD;;OAEG;IACK,MAAM,EAAE,MAAM;IACtB;;OAEG;IACK,QAAQ,EAAE,MAAM;IACxB;;OAEG;IACK,WAAW,EAAE,MAAM;IAC3B;;OAEG;IACO,QAAQ,EAAE,MAAM;IAC1B;;;OAGG;IACc,aAAa,EAAE,aAAa;IAKjD;;;;OAIG;YACW,UAAU;YAeV,oBAAoB;IA0BlC;;;;;OAKG;IACU,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAoB9E;;;;;;;OAOG;cACa,aAAa,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;YAItF,YAAY;CA6B7B"}