oidc-spa 7.2.1 → 7.2.2

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 (197) hide show
  1. package/backend.js.map +1 -1
  2. package/core/AuthResponse.js.map +1 -1
  3. package/core/Oidc.js.map +1 -1
  4. package/core/OidcInitializationError.js.map +1 -1
  5. package/core/OidcMetadata.js.map +1 -1
  6. package/core/StateData.js.map +1 -1
  7. package/core/configId.js.map +1 -1
  8. package/core/createOidc.js +1 -1
  9. package/core/createOidc.js.map +1 -1
  10. package/core/diagnostic.js.map +1 -1
  11. package/core/evtIsUserActive.js.map +1 -1
  12. package/core/handleOidcCallback.js.map +1 -1
  13. package/core/iframeMessageProtection.js.map +1 -1
  14. package/core/index.js.map +1 -1
  15. package/core/initialLocationHref.js.map +1 -1
  16. package/core/isNewBrowserSession.js.map +1 -1
  17. package/core/loginOrGoToAuthServer.js.map +1 -1
  18. package/core/loginPropagationToOtherTabs.js.map +1 -1
  19. package/core/loginSilent.js.map +1 -1
  20. package/core/logoutPropagationToOtherTabs.js.map +1 -1
  21. package/core/oidcClientTsUserToTokens.js.map +1 -1
  22. package/core/ongoingLoginOrRefreshProcesses.js.map +1 -1
  23. package/core/persistedAuthState.js.map +1 -1
  24. package/entrypoint.js.map +1 -1
  25. package/esm/core/AuthResponse.js.map +1 -1
  26. package/esm/core/Oidc.js.map +1 -1
  27. package/esm/core/OidcInitializationError.js.map +1 -1
  28. package/esm/core/OidcMetadata.js.map +1 -1
  29. package/esm/core/StateData.js.map +1 -1
  30. package/esm/core/configId.js.map +1 -1
  31. package/esm/core/createOidc.js +1 -1
  32. package/esm/core/createOidc.js.map +1 -1
  33. package/esm/core/diagnostic.js.map +1 -1
  34. package/esm/core/evtIsUserActive.js.map +1 -1
  35. package/esm/core/handleOidcCallback.js.map +1 -1
  36. package/esm/core/iframeMessageProtection.js.map +1 -1
  37. package/esm/core/index.js.map +1 -1
  38. package/esm/core/initialLocationHref.js.map +1 -1
  39. package/esm/core/isNewBrowserSession.js.map +1 -1
  40. package/esm/core/loginOrGoToAuthServer.js.map +1 -1
  41. package/esm/core/loginPropagationToOtherTabs.js.map +1 -1
  42. package/esm/core/loginSilent.js.map +1 -1
  43. package/esm/core/logoutPropagationToOtherTabs.js.map +1 -1
  44. package/esm/core/oidcClientTsUserToTokens.js.map +1 -1
  45. package/esm/core/ongoingLoginOrRefreshProcesses.js.map +1 -1
  46. package/esm/core/persistedAuthState.js.map +1 -1
  47. package/esm/entrypoint.js.map +1 -1
  48. package/esm/index.js.map +1 -1
  49. package/esm/keycloak/index.js.map +1 -1
  50. package/esm/keycloak/isKeycloak.js.map +1 -1
  51. package/esm/keycloak/keycloak-js/Keycloak.js.map +1 -1
  52. package/esm/keycloak/keycloak-js/index.js.map +1 -1
  53. package/esm/keycloak/keycloak-js/types.js.map +1 -1
  54. package/esm/keycloak/keycloakIssuerUriParsed.js.map +1 -1
  55. package/esm/keycloak/keycloakUtils.js.map +1 -1
  56. package/esm/keycloak-js.js.map +1 -1
  57. package/esm/mock/index.js.map +1 -1
  58. package/esm/mock/oidc.js.map +1 -1
  59. package/esm/mock/react.js.map +1 -1
  60. package/esm/react/index.js.map +1 -1
  61. package/esm/react/react.js.map +1 -1
  62. package/esm/tools/Deferred.js.map +1 -1
  63. package/esm/tools/EphemeralSessionStorage.js.map +1 -1
  64. package/esm/tools/Evt.js.map +1 -1
  65. package/esm/tools/StatefulEvt.js.map +1 -1
  66. package/esm/tools/ValueOrAsyncGetter.js.map +1 -1
  67. package/esm/tools/asymmetricEncryption.js.map +1 -1
  68. package/esm/tools/base64.js.map +1 -1
  69. package/esm/tools/createObjectThatThrowsIfAccessed.js.map +1 -1
  70. package/esm/tools/decodeJwt.js.map +1 -1
  71. package/esm/tools/generateUrlSafeRandom.js.map +1 -1
  72. package/esm/tools/getDownlinkAndRtt.js.map +1 -1
  73. package/esm/tools/getIsOnline.js.map +1 -1
  74. package/esm/tools/getIsValidRemoteJson.js.map +1 -1
  75. package/esm/tools/getPrUserInteraction.js.map +1 -1
  76. package/esm/tools/getUserEnvironmentInfo.js.map +1 -1
  77. package/esm/tools/haveSharedParentDomain.js.map +1 -1
  78. package/esm/tools/isDev.js.map +1 -1
  79. package/esm/tools/parseKeycloakIssuerUri.js.map +1 -1
  80. package/esm/tools/readExpirationTimeInJwt.js.map +1 -1
  81. package/esm/tools/startCountdown.js.map +1 -1
  82. package/esm/tools/subscribeToUserInteraction.js.map +1 -1
  83. package/esm/tools/toFullyQualifiedUrl.js.map +1 -1
  84. package/esm/tools/toHumanReadableDuration.js.map +1 -1
  85. package/esm/tools/urlSearchParams.js.map +1 -1
  86. package/esm/tools/workerTimers.js.map +1 -1
  87. package/index.js.map +1 -1
  88. package/keycloak/index.js.map +1 -1
  89. package/keycloak/isKeycloak.js.map +1 -1
  90. package/keycloak/keycloak-js/Keycloak.js.map +1 -1
  91. package/keycloak/keycloak-js/index.js.map +1 -1
  92. package/keycloak/keycloak-js/types.js.map +1 -1
  93. package/keycloak/keycloakIssuerUriParsed.js.map +1 -1
  94. package/keycloak/keycloakUtils.js.map +1 -1
  95. package/keycloak-js.js.map +1 -1
  96. package/mock/index.js.map +1 -1
  97. package/mock/oidc.js.map +1 -1
  98. package/mock/react.js.map +1 -1
  99. package/package.json +1 -1
  100. package/react/index.js.map +1 -1
  101. package/react/react.js.map +1 -1
  102. package/src/backend.ts +391 -0
  103. package/src/core/AuthResponse.ts +26 -0
  104. package/src/core/Oidc.ts +140 -0
  105. package/src/core/OidcInitializationError.ts +19 -0
  106. package/src/core/OidcMetadata.ts +271 -0
  107. package/src/core/StateData.ts +118 -0
  108. package/src/core/configId.ts +3 -0
  109. package/src/core/createOidc.ts +1576 -0
  110. package/src/core/diagnostic.ts +267 -0
  111. package/src/core/evtIsUserActive.ts +108 -0
  112. package/src/core/handleOidcCallback.ts +321 -0
  113. package/src/core/iframeMessageProtection.ts +100 -0
  114. package/src/core/index.ts +4 -0
  115. package/src/core/initialLocationHref.ts +5 -0
  116. package/src/core/isNewBrowserSession.ts +37 -0
  117. package/src/core/loginOrGoToAuthServer.ts +324 -0
  118. package/src/core/loginPropagationToOtherTabs.ts +51 -0
  119. package/src/core/loginSilent.ts +242 -0
  120. package/src/core/logoutPropagationToOtherTabs.ts +53 -0
  121. package/src/core/oidcClientTsUserToTokens.ts +229 -0
  122. package/src/core/ongoingLoginOrRefreshProcesses.ts +47 -0
  123. package/src/core/persistedAuthState.ts +122 -0
  124. package/src/entrypoint.ts +69 -0
  125. package/src/index.ts +1 -0
  126. package/src/keycloak/index.ts +8 -0
  127. package/src/keycloak/isKeycloak.ts +23 -0
  128. package/src/keycloak/keycloak-js/Keycloak.ts +1097 -0
  129. package/src/keycloak/keycloak-js/index.ts +2 -0
  130. package/src/keycloak/keycloak-js/types.ts +442 -0
  131. package/src/keycloak/keycloakIssuerUriParsed.ts +29 -0
  132. package/src/keycloak/keycloakUtils.ts +90 -0
  133. package/src/keycloak-js.ts +1 -0
  134. package/src/mock/index.ts +1 -0
  135. package/src/mock/oidc.ts +211 -0
  136. package/src/mock/react.tsx +11 -0
  137. package/src/react/index.ts +1 -0
  138. package/src/react/react.tsx +476 -0
  139. package/src/tools/Deferred.ts +33 -0
  140. package/src/tools/EphemeralSessionStorage.ts +223 -0
  141. package/src/tools/Evt.ts +56 -0
  142. package/src/tools/StatefulEvt.ts +38 -0
  143. package/src/tools/ValueOrAsyncGetter.ts +1 -0
  144. package/src/tools/asymmetricEncryption.ts +184 -0
  145. package/src/tools/base64.ts +7 -0
  146. package/src/tools/createObjectThatThrowsIfAccessed.ts +40 -0
  147. package/src/tools/decodeJwt.ts +95 -0
  148. package/src/tools/generateUrlSafeRandom.ts +26 -0
  149. package/src/tools/getDownlinkAndRtt.ts +22 -0
  150. package/src/tools/getIsOnline.ts +20 -0
  151. package/src/tools/getIsValidRemoteJson.ts +18 -0
  152. package/src/tools/getPrUserInteraction.ts +27 -0
  153. package/src/tools/getUserEnvironmentInfo.ts +42 -0
  154. package/src/tools/haveSharedParentDomain.ts +13 -0
  155. package/src/tools/isDev.ts +30 -0
  156. package/src/tools/parseKeycloakIssuerUri.ts +49 -0
  157. package/src/tools/readExpirationTimeInJwt.ts +16 -0
  158. package/src/tools/startCountdown.ts +36 -0
  159. package/src/tools/subscribeToUserInteraction.ts +33 -0
  160. package/src/tools/toFullyQualifiedUrl.ts +58 -0
  161. package/src/tools/toHumanReadableDuration.ts +21 -0
  162. package/src/tools/urlSearchParams.ts +130 -0
  163. package/src/tools/workerTimers.ts +57 -0
  164. package/src/vendor/backend/evt.ts +2 -0
  165. package/src/vendor/backend/jsonwebtoken.ts +1 -0
  166. package/src/vendor/backend/node-fetch.ts +2 -0
  167. package/src/vendor/backend/node-jose.ts +1 -0
  168. package/src/vendor/backend/tsafe.ts +5 -0
  169. package/src/vendor/backend/zod.ts +1 -0
  170. package/src/vendor/frontend/oidc-client-ts.ts +1 -0
  171. package/src/vendor/frontend/tsafe.ts +6 -0
  172. package/src/vendor/frontend/worker-timers.ts +2 -0
  173. package/tools/Deferred.js.map +1 -1
  174. package/tools/EphemeralSessionStorage.js.map +1 -1
  175. package/tools/Evt.js.map +1 -1
  176. package/tools/StatefulEvt.js.map +1 -1
  177. package/tools/ValueOrAsyncGetter.js.map +1 -1
  178. package/tools/asymmetricEncryption.js.map +1 -1
  179. package/tools/base64.js.map +1 -1
  180. package/tools/createObjectThatThrowsIfAccessed.js.map +1 -1
  181. package/tools/decodeJwt.js.map +1 -1
  182. package/tools/generateUrlSafeRandom.js.map +1 -1
  183. package/tools/getDownlinkAndRtt.js.map +1 -1
  184. package/tools/getIsOnline.js.map +1 -1
  185. package/tools/getIsValidRemoteJson.js.map +1 -1
  186. package/tools/getPrUserInteraction.js.map +1 -1
  187. package/tools/getUserEnvironmentInfo.js.map +1 -1
  188. package/tools/haveSharedParentDomain.js.map +1 -1
  189. package/tools/isDev.js.map +1 -1
  190. package/tools/parseKeycloakIssuerUri.js.map +1 -1
  191. package/tools/readExpirationTimeInJwt.js.map +1 -1
  192. package/tools/startCountdown.js.map +1 -1
  193. package/tools/subscribeToUserInteraction.js.map +1 -1
  194. package/tools/toFullyQualifiedUrl.js.map +1 -1
  195. package/tools/toHumanReadableDuration.js.map +1 -1
  196. package/tools/urlSearchParams.js.map +1 -1
  197. package/tools/workerTimers.js.map +1 -1
@@ -0,0 +1,271 @@
1
+ import { type OidcMetadata as OidcClientTsOidcMetadata } from "../vendor/frontend/oidc-client-ts";
2
+ import { assert, type Equals } from "../vendor/frontend/tsafe";
3
+
4
+ /**
5
+ * OpenID Providers have metadata describing their configuration.
6
+ *
7
+ * @public
8
+ */
9
+ export type OidcMetadata = {
10
+ /**
11
+ * REQUIRED. URL using the `https` scheme with no query or fragment component that the OP asserts as its Issuer
12
+ * Identifier. If Issuer discovery is supported
13
+ * (see [Section 2](https://openid.net/specs/openid-connect-discovery-1_0.html#IssuerDiscovery)),
14
+ * this value MUST be identical to the issuer value
15
+ * returned by WebFinger. This also MUST be identical to the `iss` Claim value in ID Tokens issued from this Issuer.
16
+ *
17
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
18
+ */
19
+ issuer: string;
20
+ /**
21
+ * REQUIRED. URL of the OP's OAuth 2.0 Authorization Endpoint
22
+ * [[OpenID.Core](https://openid.net/specs/openid-connect-discovery-1_0.html#OpenID.Core)].
23
+ * This URL MUST use the `https` scheme and MAY contain port, path, and query parameter components.
24
+ *
25
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
26
+ */
27
+ authorization_endpoint: string;
28
+ /**
29
+ * URL of the OP's OAuth 2.0 Token Endpoint
30
+ * [[OpenID.Core](https://openid.net/specs/openid-connect-discovery-1_0.html#OpenID.Core)].
31
+ * This is REQUIRED unless only the Implicit Flow is used. This URL MUST use the `https` scheme and MAY contain
32
+ * port, path, and query parameter components.
33
+ *
34
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
35
+ */
36
+ token_endpoint: string;
37
+ /**
38
+ * OPTIONAL. JSON array containing a list of Client Authentication methods supported by this Token Endpoint.
39
+ * The options are `client_secret_post`, `client_secret_basic`, `client_secret_jwt`, and `private_key_jwt`, as
40
+ * described in Section 9 of
41
+ * [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html#OpenID.Core)
42
+ * [OpenID.Core]. Other authentication methods MAY be defined by extensions. If omitted, the default is
43
+ * `client_secret_basic` -- the HTTP Basic Authentication Scheme specified in Section 2.3.1 of
44
+ * [OAuth 2.0](https://openid.net/specs/openid-connect-discovery-1_0.html#RFC6749) [RFC6749].
45
+ *
46
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
47
+ */
48
+ token_endpoint_auth_methods_supported: string[];
49
+ /**
50
+ * OPTIONAL. JSON array containing a list of the JWS signing algorithms (`alg` values) supported by the
51
+ * Token Endpoint for the signature on the JWT
52
+ * [[JWT](https://openid.net/specs/openid-connect-discovery-1_0.html#JWT)]
53
+ * used to authenticate the Client at the Token Endpoint for the `private_key_jwt` and `client_secret_jwt`
54
+ * authentication methods. Servers SHOULD support RS256. The value none MUST NOT be used.
55
+ *
56
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
57
+ */
58
+ token_endpoint_auth_signing_alg_values_supported: string[];
59
+ /**
60
+ * RECOMMENDED. URL of the OP's UserInfo Endpoint
61
+ * [[OpenID.Core](https://openid.net/specs/openid-connect-discovery-1_0.html#OpenID.Core)].
62
+ * This URL MUST use the https scheme and MAY contain port, path, and query parameter components.
63
+ *
64
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
65
+ */
66
+ userinfo_endpoint: string;
67
+ /**
68
+ * REQUIRED. URL of an OP iframe that supports cross-origin communications for session state information with the
69
+ * RP Client, using the HTML5 postMessage API. This URL MUST use the `https` scheme and MAY contain port, path, and
70
+ * query parameter components. The page is loaded from an invisible iframe embedded in an RP page so that it can run
71
+ * in the OP's security context. It accepts postMessage requests from the relevant RP iframe and uses postMessage to
72
+ * post back the login status of the End-User at the OP.
73
+ *
74
+ * @see https://openid.net/specs/openid-connect-session-1_0.html#OPMetadata
75
+ */
76
+ check_session_iframe: string;
77
+ /**
78
+ * REQUIRED. URL at the OP to which an RP can perform a redirect to request that the End-User be logged out at the OP.
79
+ *
80
+ * @see https://openid.net/specs/openid-connect-session-1_0-17.html#OPMetadata
81
+ */
82
+ end_session_endpoint: string;
83
+ /**
84
+ * REQUIRED. URL of the OP's JWK Set
85
+ * [[JWK](https://openid.net/specs/openid-connect-discovery-1_0.html#JWK)]
86
+ * document, which MUST use the `https` scheme. This contains the signing key(s) the RP uses to validate signatures from
87
+ * the OP. The JWK Set MAY also contain the Server's encryption key(s), which are used by RPs to encrypt requests to the Server.
88
+ * When both signing and encryption keys are made available, a `use` (public key use) parameter value is REQUIRED for all keys
89
+ * in the referenced JWK Set to indicate each key's intended usage. Although some algorithms allow the same key to be used for
90
+ * both signatures and encryption, doing so is NOT RECOMMENDED, as it is less secure. The JWK `x5c` parameter MAY be used to provide
91
+ * X.509 representations of keys provided. When used, the bare key values MUST still be present and MUST match those in the
92
+ * certificate. The JWK Set MUST NOT contain private or symmetric key values.
93
+ *
94
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
95
+ */
96
+ jwks_uri: string;
97
+ /**
98
+ * RECOMMENDED. URL of the OP's Dynamic Client Registration Endpoint
99
+ * [[OpenID.Registration](https://openid.net/specs/openid-connect-discovery-1_0.html#OpenID.Registration)],
100
+ * which MUST use the `https` scheme.
101
+ *
102
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
103
+ */
104
+ registration_endpoint: string;
105
+ /**
106
+ * RECOMMENDED. JSON array containing a list of the
107
+ * [OAuth 2.0](https://openid.net/specs/openid-connect-discovery-1_0.html#RFC6749)
108
+ * [RFC6749] scope values that this server supports. The server MUST support the openid scope value. Servers MAY choose not
109
+ * to advertise some supported scope values even when this parameter is used, although those defined in
110
+ * [[OpenID.Core](https://openid.net/specs/openid-connect-discovery-1_0.html#OpenID.Core)]
111
+ * SHOULD be listed, if supported.
112
+ *
113
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
114
+ */
115
+ scopes_supported: string[];
116
+ /**
117
+ * REQUIRED. JSON array containing a list of the OAuth 2.0 `response_type` values that this OP supports. Dynamic OpenID
118
+ * Providers MUST support the `code`, `id_token`, and the `id_token token` Response Type values.
119
+ *
120
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
121
+ */
122
+ response_types_supported: string[];
123
+ /**
124
+ * OPTIONAL. JSON array containing a list of the Authentication Context Class References that this OP supports.
125
+ *
126
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
127
+ */
128
+ acr_values_supported: string[];
129
+ /**
130
+ * REQUIRED. JSON array containing a list of the Subject Identifier types that this OP supports. Valid types include `pairwise`
131
+ * and `public`.
132
+ *
133
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
134
+ */
135
+ subject_types_supported: string[];
136
+ /**
137
+ * OPTIONAL. JSON array containing a list of the JWS signing algorithms (`alg` values) supported by the OP for Request Objects,
138
+ * which are described in Section 6.1 of
139
+ * [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html#OpenID.Core)
140
+ * [OpenID.Core]. These algorithms are used both when the Request Object is passed by value (using the `request` parameter) and
141
+ * when it is passed by reference (using the `request_uri` parameter). Servers SHOULD support `none` and `RS256`.
142
+ *
143
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
144
+ */
145
+ request_object_signing_alg_values_supported: string[];
146
+ /**
147
+ * OPTIONAL. JSON array containing a list of the `display` parameter values that the OpenID Provider supports. These values are
148
+ * described in Section 3.1.2.1 of
149
+ * [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html#OpenID.Core)
150
+ * [OpenID.Core].
151
+ *
152
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
153
+ */
154
+ display_values_supported: string[];
155
+ /**
156
+ * OPTIONAL. JSON array containing a list of the Claim Types that the OpenID Provider supports. These Claim Types are described
157
+ * in Section 5.6 of
158
+ * [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html#OpenID.Core)
159
+ * [OpenID.Core]. Values defined by this specification are `normal`, `aggregated`, and `distributed`. If omitted, the
160
+ * implementation supports only normal Claims.
161
+ *
162
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
163
+ */
164
+ claim_types_supported: string[];
165
+ /**
166
+ * RECOMMENDED. JSON array containing a list of the Claim Names of the Claims that the OpenID Provider MAY be able to supply
167
+ * values for. Note that for privacy or other reasons, this might not be an exhaustive list.
168
+ *
169
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
170
+ */
171
+ claims_supported: string[];
172
+ /**
173
+ * OPTIONAL. Boolean value specifying whether the OP supports use of the `claims` parameter, with `true` indicating support. If
174
+ * omitted, the default value is `false`.
175
+ *
176
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
177
+ */
178
+ claims_parameter_supported: boolean;
179
+ /**
180
+ * OPTIONAL. URL of a page containing human-readable information that developers might want or need to know when using the
181
+ * OpenID Provider. In particular, if the OpenID Provider does not support Dynamic Client Registration, then information on
182
+ * how to register Clients needs to be provided in this documentation.
183
+ *
184
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
185
+ */
186
+ service_documentation: string;
187
+ /**
188
+ * OPTIONAL. Languages and scripts supported for the user interface, represented as a JSON array of
189
+ * [BCP47](https://openid.net/specs/openid-connect-discovery-1_0.html#RFC5646)
190
+ * [RFC5646] language tag values.
191
+ *
192
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
193
+ */
194
+ ui_locales_supported: string[];
195
+ /**
196
+ * The fully qualified URL of the server's revocation endpoint defined by
197
+ * [OAuth 2.0 Token Revocation](https://openid.net/specs/openid-heart-oauth2-2015-12-07.html#RFC7009)
198
+ * [RFC7009].
199
+ *
200
+ * @see https://openid.net/specs/openid-heart-oauth2-2015-12-07.html#rfc.section.4.1
201
+ */
202
+ revocation_endpoint: string;
203
+ /**
204
+ * The fully qualified URL of the server's introspection endpoint defined by
205
+ * [OAuth Token Introspection](https://openid.net/specs/openid-heart-oauth2-2015-12-07.html#RFC7662)
206
+ * [RFC7662].
207
+ *
208
+ * @see https://openid.net/specs/openid-heart-oauth2-2015-12-07.html#rfc.section.4.1
209
+ */
210
+ introspection_endpoint: string;
211
+ /**
212
+ * OPTIONAL. Boolean value specifying whether the OP supports HTTP-based logout, with `true` indicating support. If omitted,
213
+ * the default value is `false`.
214
+ *
215
+ * @see https://openid.net/specs/openid-connect-frontchannel-1_0.html#OPLogout
216
+ */
217
+ frontchannel_logout_supported: boolean;
218
+ /**
219
+ * OPTIONAL. Boolean value specifying whether the OP can pass iss (issuer) and `sid` (session ID) query parameters to identify
220
+ * the RP session with the OP when the `frontchannel_logout_uri` is used. If supported, the `sid` Claim is also included in
221
+ * ID Tokens issued by the OP. If omitted, the default value is `false`.
222
+ *
223
+ * @see https://openid.net/specs/openid-connect-frontchannel-1_0.html#OPLogout
224
+ */
225
+ frontchannel_logout_session_supported: boolean;
226
+ /**
227
+ * OPTIONAL. Boolean value specifying whether the OP supports back-channel logout, with `true` indicating support. If omitted,
228
+ * the default value is `false`.
229
+ *
230
+ * @see https://openid.net/specs/openid-connect-backchannel-1_0.html#BCSupport
231
+ */
232
+ backchannel_logout_supported: boolean;
233
+ /**
234
+ * OPTIONAL. Boolean value specifying whether the OP can pass a `sid` (session ID) Claim in the Logout Token to identify the
235
+ * RP session with the OP. If supported, the `sid` Claim is also included in ID Tokens issued by the OP. If omitted, the default
236
+ * value is `false`.
237
+ *
238
+ * @see https://openid.net/specs/openid-connect-backchannel-1_0.html#BCSupport
239
+ */
240
+ backchannel_logout_session_supported: boolean;
241
+ /**
242
+ * OPTIONAL. JSON array containing a list of the OAuth 2.0 Grant Type values that this OP supports. Dynamic OpenID Providers
243
+ * MUST support the `authorization_code` and `implicit` Grant Type values and MAY support other Grant Types. If omitted, the
244
+ * default value is [`"authorization_code"`, `"implicit"`].
245
+ *
246
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
247
+ */
248
+ grant_types_supported: string[];
249
+ /**
250
+ * OPTIONAL. JSON array containing a list of the OAuth 2.0 response_mode values that this OP supports, as specified in
251
+ * [OAuth 2.0 Multiple Response Type Encoding Practices](https://openid.net/specs/openid-connect-discovery-1_0.html#OAuth.Responses)
252
+ * [OAuth.Responses]. If omitted, the default for Dynamic OpenID Providers is [`"query"`, `"fragment"`].
253
+ *
254
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
255
+ */
256
+ response_modes_supported: string[];
257
+ /**
258
+ * OPTIONAL. JSON array containing a list of
259
+ * [Proof Key for Code Exchange (PKCE)](https://datatracker.ietf.org/doc/html/rfc7636)
260
+ * [RFC7636] code challenge methods supported by this authorization server. Code challenge method values are used in
261
+ * the "code_challenge_method" parameter defined in Section 4.3 of [RFC7636]. The valid code challenge method values are
262
+ * those registered in the
263
+ * [IANA "PKCE Code Challenge Methods" registry](https://datatracker.ietf.org/doc/html/rfc8414#ref-IANA.OAuth.Parameters)
264
+ * [IANA.OAuth.Parameters]. If omitted, the authorization server does not support PKCE.
265
+ *
266
+ * @see https://datatracker.ietf.org/doc/html/rfc8414
267
+ */
268
+ code_challenge_methods_supported: string[];
269
+ };
270
+
271
+ assert<Equals<OidcMetadata, OidcClientTsOidcMetadata>>;
@@ -0,0 +1,118 @@
1
+ import { typeGuard, assert } from "../vendor/frontend/tsafe";
2
+ import { generateUrlSafeRandom } from "../tools/generateUrlSafeRandom";
3
+
4
+ export type StateData = StateData.IFrame | StateData.Redirect;
5
+
6
+ export namespace StateData {
7
+ type Common = {
8
+ configId: string;
9
+ };
10
+
11
+ export type IFrame = Common & {
12
+ context: "iframe";
13
+ };
14
+
15
+ export type Redirect = Redirect.Login | Redirect.Logout;
16
+ export namespace Redirect {
17
+ type Common_Redirect = Common & {
18
+ context: "redirect";
19
+ redirectUrl: string;
20
+ hasBeenProcessedByCallback: boolean;
21
+ };
22
+
23
+ export type Login = Common_Redirect & {
24
+ action: "login";
25
+ redirectUrl_consentRequiredCase: string;
26
+ extraQueryParams: Record<string, string>;
27
+ };
28
+
29
+ export type Logout = Common_Redirect & {
30
+ action: "logout";
31
+ sessionId: string | undefined;
32
+ };
33
+ }
34
+ }
35
+
36
+ const STATE_QUERY_PARAM_VALUE_IDENTIFIER_PREFIX = "b2lkYy1zcGEu";
37
+ const RANDOM_STRING_LENGTH = 32 - STATE_QUERY_PARAM_VALUE_IDENTIFIER_PREFIX.length;
38
+
39
+ export function generateStateUrlParamValue(): string {
40
+ return `${STATE_QUERY_PARAM_VALUE_IDENTIFIER_PREFIX}${generateUrlSafeRandom({
41
+ length: RANDOM_STRING_LENGTH
42
+ })}`;
43
+ }
44
+
45
+ export function getIsStatQueryParamValue(params: { maybeStateUrlParamValue: string }): boolean {
46
+ const { maybeStateUrlParamValue } = params;
47
+
48
+ return (
49
+ maybeStateUrlParamValue.startsWith(STATE_QUERY_PARAM_VALUE_IDENTIFIER_PREFIX) &&
50
+ maybeStateUrlParamValue.length ===
51
+ STATE_QUERY_PARAM_VALUE_IDENTIFIER_PREFIX.length + RANDOM_STRING_LENGTH
52
+ );
53
+ }
54
+
55
+ export const STATE_STORE_KEY_PREFIX = "oidc.";
56
+
57
+ function getKey(params: { stateUrlParamValue: string }) {
58
+ const { stateUrlParamValue } = params;
59
+
60
+ return `${STATE_STORE_KEY_PREFIX}${stateUrlParamValue}`;
61
+ }
62
+
63
+ function getStateStore(params: { stateUrlParamValue: string }): { data: StateData } | undefined {
64
+ const { stateUrlParamValue } = params;
65
+
66
+ const item = localStorage.getItem(getKey({ stateUrlParamValue }));
67
+
68
+ if (item === null) {
69
+ return undefined;
70
+ }
71
+
72
+ const obj = JSON.parse(item);
73
+
74
+ assert(
75
+ typeGuard<{ data: StateData }>(
76
+ obj,
77
+ obj instanceof Object && obj.data instanceof Object && typeof obj.data.context === "string"
78
+ )
79
+ );
80
+
81
+ return obj;
82
+ }
83
+
84
+ function setStateStore(params: { stateUrlParamValue: string; obj: { data: StateData } }) {
85
+ const { stateUrlParamValue, obj } = params;
86
+
87
+ localStorage.setItem(getKey({ stateUrlParamValue }), JSON.stringify(obj));
88
+ }
89
+
90
+ export function clearStateStore(params: { stateUrlParamValue: string }) {
91
+ const { stateUrlParamValue } = params;
92
+ localStorage.removeItem(getKey({ stateUrlParamValue }));
93
+ }
94
+
95
+ export function getStateData(params: { stateUrlParamValue: string }): StateData | undefined {
96
+ const { stateUrlParamValue } = params;
97
+
98
+ const stateStore = getStateStore({ stateUrlParamValue });
99
+
100
+ if (stateStore === undefined) {
101
+ return undefined;
102
+ }
103
+
104
+ return stateStore.data;
105
+ }
106
+
107
+ export function markStateDataAsProcessedByCallback(params: { stateUrlParamValue: string }) {
108
+ const { stateUrlParamValue } = params;
109
+
110
+ const obj = getStateStore({ stateUrlParamValue });
111
+
112
+ assert(obj !== undefined, "180465");
113
+ assert(obj.data.context === "redirect", "649531");
114
+
115
+ obj.data.hasBeenProcessedByCallback = true;
116
+
117
+ setStateStore({ stateUrlParamValue, obj });
118
+ }
@@ -0,0 +1,3 @@
1
+ export function getConfigId(params: { issuerUri: string; clientId: string }) {
2
+ return `${params.issuerUri}:${params.clientId}`;
3
+ }