@learnorama/mozaik-sdk 0.1.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 (208) hide show
  1. package/README.md +94 -0
  2. package/dist/api/account.d.ts +75 -0
  3. package/dist/api/account.js +117 -0
  4. package/dist/api/account.js.map +1 -0
  5. package/dist/api/admin-catalogue.d.ts +68 -0
  6. package/dist/api/admin-catalogue.js +155 -0
  7. package/dist/api/admin-catalogue.js.map +1 -0
  8. package/dist/api/admin-consumption.d.ts +27 -0
  9. package/dist/api/admin-consumption.js +55 -0
  10. package/dist/api/admin-consumption.js.map +1 -0
  11. package/dist/api/admin-licenses.d.ts +21 -0
  12. package/dist/api/admin-licenses.js +34 -0
  13. package/dist/api/admin-licenses.js.map +1 -0
  14. package/dist/api/admin-patrons.d.ts +36 -0
  15. package/dist/api/admin-patrons.js +76 -0
  16. package/dist/api/admin-patrons.js.map +1 -0
  17. package/dist/api/admin-reviews.d.ts +30 -0
  18. package/dist/api/admin-reviews.js +63 -0
  19. package/dist/api/admin-reviews.js.map +1 -0
  20. package/dist/api/admin-roles.d.ts +34 -0
  21. package/dist/api/admin-roles.js +62 -0
  22. package/dist/api/admin-roles.js.map +1 -0
  23. package/dist/api/admin-support.d.ts +68 -0
  24. package/dist/api/admin-support.js +116 -0
  25. package/dist/api/admin-support.js.map +1 -0
  26. package/dist/api/admin-tenants.d.ts +33 -0
  27. package/dist/api/admin-tenants.js +68 -0
  28. package/dist/api/admin-tenants.js.map +1 -0
  29. package/dist/api/admin-tutoring.d.ts +159 -0
  30. package/dist/api/admin-tutoring.js +455 -0
  31. package/dist/api/admin-tutoring.js.map +1 -0
  32. package/dist/api/auth.d.ts +92 -0
  33. package/dist/api/auth.js +192 -0
  34. package/dist/api/auth.js.map +1 -0
  35. package/dist/api/biblio-catalogue.d.ts +122 -0
  36. package/dist/api/biblio-catalogue.js +223 -0
  37. package/dist/api/biblio-catalogue.js.map +1 -0
  38. package/dist/api/biblio-home.d.ts +18 -0
  39. package/dist/api/biblio-home.js +31 -0
  40. package/dist/api/biblio-home.js.map +1 -0
  41. package/dist/api/biblio-library.d.ts +94 -0
  42. package/dist/api/biblio-library.js +187 -0
  43. package/dist/api/biblio-library.js.map +1 -0
  44. package/dist/api/biblio-nextory.d.ts +43 -0
  45. package/dist/api/biblio-nextory.js +65 -0
  46. package/dist/api/biblio-nextory.js.map +1 -0
  47. package/dist/api/biblio-press.d.ts +38 -0
  48. package/dist/api/biblio-press.js +70 -0
  49. package/dist/api/biblio-press.js.map +1 -0
  50. package/dist/api/biblio-search.d.ts +17 -0
  51. package/dist/api/biblio-search.js +30 -0
  52. package/dist/api/biblio-search.js.map +1 -0
  53. package/dist/api/biblio-telemetry.d.ts +28 -0
  54. package/dist/api/biblio-telemetry.js +49 -0
  55. package/dist/api/biblio-telemetry.js.map +1 -0
  56. package/dist/api/consumption.d.ts +30 -0
  57. package/dist/api/consumption.js +45 -0
  58. package/dist/api/consumption.js.map +1 -0
  59. package/dist/api/cvs-app.d.ts +39 -0
  60. package/dist/api/cvs-app.js +72 -0
  61. package/dist/api/cvs-app.js.map +1 -0
  62. package/dist/api/cvs-documents.d.ts +106 -0
  63. package/dist/api/cvs-documents.js +208 -0
  64. package/dist/api/cvs-documents.js.map +1 -0
  65. package/dist/api/cvs-favorites.d.ts +53 -0
  66. package/dist/api/cvs-favorites.js +82 -0
  67. package/dist/api/cvs-favorites.js.map +1 -0
  68. package/dist/api/cvs-loans.d.ts +59 -0
  69. package/dist/api/cvs-loans.js +106 -0
  70. package/dist/api/cvs-loans.js.map +1 -0
  71. package/dist/api/cvs-streaming.d.ts +40 -0
  72. package/dist/api/cvs-streaming.js +68 -0
  73. package/dist/api/cvs-streaming.js.map +1 -0
  74. package/dist/api/index.d.ts +34 -0
  75. package/dist/api/index.js +34 -0
  76. package/dist/api/partner-catalogue.d.ts +77 -0
  77. package/dist/api/partner-catalogue.js +125 -0
  78. package/dist/api/partner-catalogue.js.map +1 -0
  79. package/dist/api/partner-reader.d.ts +56 -0
  80. package/dist/api/partner-reader.js +103 -0
  81. package/dist/api/partner-reader.js.map +1 -0
  82. package/dist/api/profiles.d.ts +64 -0
  83. package/dist/api/profiles.js +126 -0
  84. package/dist/api/profiles.js.map +1 -0
  85. package/dist/api/tutoring-catalogue.d.ts +32 -0
  86. package/dist/api/tutoring-catalogue.js +59 -0
  87. package/dist/api/tutoring-catalogue.js.map +1 -0
  88. package/dist/api/tutoring-chat.d.ts +31 -0
  89. package/dist/api/tutoring-chat.js +71 -0
  90. package/dist/api/tutoring-chat.js.map +1 -0
  91. package/dist/api/tutoring-dispatch.d.ts +37 -0
  92. package/dist/api/tutoring-dispatch.js +83 -0
  93. package/dist/api/tutoring-dispatch.js.map +1 -0
  94. package/dist/api/tutoring-practitioner.d.ts +55 -0
  95. package/dist/api/tutoring-practitioner.js +110 -0
  96. package/dist/api/tutoring-practitioner.js.map +1 -0
  97. package/dist/api/tutoring-requests.d.ts +86 -0
  98. package/dist/api/tutoring-requests.js +176 -0
  99. package/dist/api/tutoring-requests.js.map +1 -0
  100. package/dist/client-BDwBZYB0.d.ts +28 -0
  101. package/dist/client-D3kMOcIr.js +61 -0
  102. package/dist/client-D3kMOcIr.js.map +1 -0
  103. package/dist/index-wL_20vR8.d.ts +4566 -0
  104. package/dist/index.d.ts +9 -0
  105. package/dist/index.js +10 -0
  106. package/dist/index.js.map +1 -0
  107. package/dist/models.d.ts +3 -0
  108. package/dist/models.js +175 -0
  109. package/dist/models.js.map +1 -0
  110. package/dist/react/account.d.ts +163 -0
  111. package/dist/react/account.js +240 -0
  112. package/dist/react/account.js.map +1 -0
  113. package/dist/react/admin-catalogue.d.ts +196 -0
  114. package/dist/react/admin-catalogue.js +336 -0
  115. package/dist/react/admin-catalogue.js.map +1 -0
  116. package/dist/react/admin-consumption.d.ts +75 -0
  117. package/dist/react/admin-consumption.js +127 -0
  118. package/dist/react/admin-consumption.js.map +1 -0
  119. package/dist/react/admin-licenses.d.ts +50 -0
  120. package/dist/react/admin-licenses.js +78 -0
  121. package/dist/react/admin-licenses.js.map +1 -0
  122. package/dist/react/admin-patrons.d.ts +111 -0
  123. package/dist/react/admin-patrons.js +173 -0
  124. package/dist/react/admin-patrons.js.map +1 -0
  125. package/dist/react/admin-reviews.d.ts +78 -0
  126. package/dist/react/admin-reviews.js +135 -0
  127. package/dist/react/admin-reviews.js.map +1 -0
  128. package/dist/react/admin-roles.d.ts +82 -0
  129. package/dist/react/admin-roles.js +135 -0
  130. package/dist/react/admin-roles.js.map +1 -0
  131. package/dist/react/admin-support.d.ts +123 -0
  132. package/dist/react/admin-support.js +208 -0
  133. package/dist/react/admin-support.js.map +1 -0
  134. package/dist/react/admin-tenants.d.ts +108 -0
  135. package/dist/react/admin-tenants.js +165 -0
  136. package/dist/react/admin-tenants.js.map +1 -0
  137. package/dist/react/admin-tutoring.d.ts +556 -0
  138. package/dist/react/admin-tutoring.js +954 -0
  139. package/dist/react/admin-tutoring.js.map +1 -0
  140. package/dist/react/auth.d.ts +220 -0
  141. package/dist/react/auth.js +372 -0
  142. package/dist/react/auth.js.map +1 -0
  143. package/dist/react/biblio-catalogue.d.ts +374 -0
  144. package/dist/react/biblio-catalogue.js +498 -0
  145. package/dist/react/biblio-catalogue.js.map +1 -0
  146. package/dist/react/biblio-home.d.ts +47 -0
  147. package/dist/react/biblio-home.js +75 -0
  148. package/dist/react/biblio-home.js.map +1 -0
  149. package/dist/react/biblio-library.d.ts +285 -0
  150. package/dist/react/biblio-library.js +411 -0
  151. package/dist/react/biblio-library.js.map +1 -0
  152. package/dist/react/biblio-nextory.d.ts +100 -0
  153. package/dist/react/biblio-nextory.js +163 -0
  154. package/dist/react/biblio-nextory.js.map +1 -0
  155. package/dist/react/biblio-press.d.ts +121 -0
  156. package/dist/react/biblio-press.js +163 -0
  157. package/dist/react/biblio-press.js.map +1 -0
  158. package/dist/react/biblio-search.d.ts +46 -0
  159. package/dist/react/biblio-search.js +74 -0
  160. package/dist/react/biblio-search.js.map +1 -0
  161. package/dist/react/biblio-telemetry.d.ts +49 -0
  162. package/dist/react/biblio-telemetry.js +85 -0
  163. package/dist/react/biblio-telemetry.js.map +1 -0
  164. package/dist/react/consumption.d.ts +66 -0
  165. package/dist/react/consumption.js +109 -0
  166. package/dist/react/consumption.js.map +1 -0
  167. package/dist/react/cvs-app.d.ts +86 -0
  168. package/dist/react/cvs-app.js +144 -0
  169. package/dist/react/cvs-app.js.map +1 -0
  170. package/dist/react/cvs-documents.d.ts +254 -0
  171. package/dist/react/cvs-documents.js +418 -0
  172. package/dist/react/cvs-documents.js.map +1 -0
  173. package/dist/react/cvs-favorites.d.ts +143 -0
  174. package/dist/react/cvs-favorites.js +206 -0
  175. package/dist/react/cvs-favorites.js.map +1 -0
  176. package/dist/react/cvs-loans.d.ts +140 -0
  177. package/dist/react/cvs-loans.js +234 -0
  178. package/dist/react/cvs-loans.js.map +1 -0
  179. package/dist/react/cvs-streaming.d.ts +87 -0
  180. package/dist/react/cvs-streaming.js +141 -0
  181. package/dist/react/cvs-streaming.js.map +1 -0
  182. package/dist/react/index.d.ts +34 -0
  183. package/dist/react/index.js +34 -0
  184. package/dist/react/partner-catalogue.d.ts +223 -0
  185. package/dist/react/partner-catalogue.js +301 -0
  186. package/dist/react/partner-catalogue.js.map +1 -0
  187. package/dist/react/partner-reader.d.ts +159 -0
  188. package/dist/react/partner-reader.js +226 -0
  189. package/dist/react/partner-reader.js.map +1 -0
  190. package/dist/react/profiles.d.ts +174 -0
  191. package/dist/react/profiles.js +279 -0
  192. package/dist/react/profiles.js.map +1 -0
  193. package/dist/react/tutoring-catalogue.d.ts +115 -0
  194. package/dist/react/tutoring-catalogue.js +151 -0
  195. package/dist/react/tutoring-catalogue.js.map +1 -0
  196. package/dist/react/tutoring-chat.d.ts +96 -0
  197. package/dist/react/tutoring-chat.js +172 -0
  198. package/dist/react/tutoring-chat.js.map +1 -0
  199. package/dist/react/tutoring-dispatch.d.ts +102 -0
  200. package/dist/react/tutoring-dispatch.js +183 -0
  201. package/dist/react/tutoring-dispatch.js.map +1 -0
  202. package/dist/react/tutoring-practitioner.d.ts +129 -0
  203. package/dist/react/tutoring-practitioner.js +230 -0
  204. package/dist/react/tutoring-practitioner.js.map +1 -0
  205. package/dist/react/tutoring-requests.d.ts +233 -0
  206. package/dist/react/tutoring-requests.js +385 -0
  207. package/dist/react/tutoring-requests.js.map +1 -0
  208. package/package.json +58 -0
@@ -0,0 +1,372 @@
1
+ "use client";
2
+ import { r as request } from "../client-D3kMOcIr.js";
3
+ import { useMutation, useQuery } from "@tanstack/react-query";
4
+ //#region src/react/auth/auth.ts
5
+ /**
6
+ * Generated by orval 🍺
7
+ * Do not edit manually.
8
+ * Mozaik backend
9
+ * Four products behind one API — Biblio, Médiathèques, the partner catalogues (Nextory and YouScribe) and Prof Express. Authentication is Keycloak SSO only, once, for all of them: see the **auth** section below for the browser flow and the three failure modes.
10
+ * OpenAPI spec version: 0.1.0
11
+ */
12
+ const withQueryKey = (query, queryKey) => {
13
+ const result = { queryKey };
14
+ for (const key of Object.keys(query)) {
15
+ if (key === "queryKey") continue;
16
+ Object.defineProperty(result, key, {
17
+ enumerable: true,
18
+ configurable: true,
19
+ get: () => query[key]
20
+ });
21
+ }
22
+ return result;
23
+ };
24
+ const getAuthorizationUrl = (params) => {
25
+ const normalizedParams = new URLSearchParams();
26
+ Object.entries(params || {}).forEach(([key, value]) => {
27
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
28
+ });
29
+ const stringifiedParams = normalizedParams.toString();
30
+ return stringifiedParams.length > 0 ? `/auth/authorization?${stringifiedParams}` : `/auth/authorization`;
31
+ };
32
+ /**
33
+ * Build the Keycloak authorization URL for this client and this tenant.
34
+ *
35
+ * Everything cryptographic belongs to the caller: it generates ``state``, the
36
+ * PKCE verifier and the ``nonce``, and only ever sends the challenge. This
37
+ * endpoint contributes the one thing the caller cannot know — which identity
38
+ * provider to route to — and refuses an unsafe ``redirect_uri``.
39
+ *
40
+ * ``S256`` is hardcoded. ``plain`` is a valid PKCE method and provides no
41
+ * protection, so making it selectable would only ever be used by mistake.
42
+ *
43
+ * A resolved provider is passed as ``kc_idp_hint``. Aliases are case-sensitive
44
+ * at the broker and an unknown one silently falls back to the login form, which
45
+ * is why :func:`_resolve_provider_alias` validates against the registry instead
46
+ * of forwarding whatever arrived.
47
+ * @summary Authorization
48
+ */
49
+ const authorization = async (params, options) => {
50
+ return request(getAuthorizationUrl(params), {
51
+ ...options,
52
+ method: "GET"
53
+ });
54
+ };
55
+ const getAuthorizationQueryKey = (params) => {
56
+ return [`/auth/authorization`, ...params ? [params] : []];
57
+ };
58
+ const getAuthorizationQueryOptions = (params, options) => {
59
+ const { query: queryOptions, request: requestOptions } = options ?? {};
60
+ const queryKey = queryOptions?.queryKey ?? getAuthorizationQueryKey(params);
61
+ const queryFn = ({ signal }) => authorization(params, {
62
+ signal,
63
+ ...requestOptions
64
+ });
65
+ return {
66
+ queryKey,
67
+ queryFn,
68
+ ...queryOptions
69
+ };
70
+ };
71
+ /**
72
+ * @summary Authorization
73
+ */
74
+ function useAuthorization(params, options, queryClient) {
75
+ const queryOptions = getAuthorizationQueryOptions(params, options);
76
+ const query = useQuery(queryOptions, queryClient);
77
+ return withQueryKey(query, queryOptions.queryKey);
78
+ }
79
+ const getReadMeUrl = () => {
80
+ return `/auth/me`;
81
+ };
82
+ /**
83
+ * Who the bearer of this token is, and what the session may do.
84
+ *
85
+ * No tokens in the response — this endpoint reissues nothing, and a shape with
86
+ * empty token fields would invite a client to store them. It is also the
87
+ * cheapest liveness check a client has: it exercises verification,
88
+ * tenant resolution and the account link in one call, so a 200 here means the
89
+ * whole chain is intact.
90
+ * @summary Read Me
91
+ */
92
+ const readMe = async (options) => {
93
+ return request(getReadMeUrl(), {
94
+ ...options,
95
+ method: "GET"
96
+ });
97
+ };
98
+ const getReadMeQueryKey = () => {
99
+ return [`/auth/me`];
100
+ };
101
+ const getReadMeQueryOptions = (options) => {
102
+ const { query: queryOptions, request: requestOptions } = options ?? {};
103
+ const queryKey = queryOptions?.queryKey ?? getReadMeQueryKey();
104
+ const queryFn = ({ signal }) => readMe({
105
+ signal,
106
+ ...requestOptions
107
+ });
108
+ return {
109
+ queryKey,
110
+ queryFn,
111
+ ...queryOptions
112
+ };
113
+ };
114
+ /**
115
+ * @summary Read Me
116
+ */
117
+ function useReadMe(options, queryClient) {
118
+ const queryOptions = getReadMeQueryOptions(options);
119
+ const query = useQuery(queryOptions, queryClient);
120
+ return withQueryKey(query, queryOptions.queryKey);
121
+ }
122
+ const getDeleteSessionUrl = () => {
123
+ return `/auth/sessions`;
124
+ };
125
+ /**
126
+ * Sign out, revoking the refresh token at the broker.
127
+ *
128
+ * Always 204. A logout that can fail is a logout users do not trust, and there
129
+ * is nothing useful for the caller to do about an unreachable broker — it is
130
+ * discarding its tokens either way. The failure is logged, not returned.
131
+ *
132
+ * The access token stays valid until it expires. That is inherent to verifying
133
+ * tokens offline, and it is why the realm keeps access-token lifetimes short
134
+ * rather than why this endpoint should pretend otherwise.
135
+ * @summary Delete Session
136
+ */
137
+ const deleteSession = async (logoutWrite, options) => {
138
+ const getHeaders = (h) => {
139
+ if (!h) return {};
140
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
141
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
142
+ const headers = {};
143
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
144
+ return headers;
145
+ };
146
+ return request(getDeleteSessionUrl(), {
147
+ ...options,
148
+ method: "DELETE",
149
+ headers: {
150
+ "Content-Type": "application/json",
151
+ ...getHeaders(options?.headers)
152
+ },
153
+ body: JSON.stringify(logoutWrite)
154
+ });
155
+ };
156
+ const getDeleteSessionMutationKey = () => ["deleteSession"];
157
+ const getDeleteSessionMutationOptions = (options) => {
158
+ const mutationKey = getDeleteSessionMutationKey();
159
+ const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
160
+ ...options,
161
+ mutation: {
162
+ ...options.mutation,
163
+ mutationKey
164
+ }
165
+ } : {
166
+ mutation: { mutationKey },
167
+ request: void 0
168
+ };
169
+ const mutationFn = (props) => {
170
+ const { data } = props ?? {};
171
+ return deleteSession(data, requestOptions);
172
+ };
173
+ return {
174
+ mutationFn,
175
+ ...mutationOptions
176
+ };
177
+ };
178
+ /**
179
+ * @summary Delete Session
180
+ */
181
+ const useDeleteSession = (options, queryClient) => {
182
+ return useMutation(getDeleteSessionMutationOptions(options), queryClient);
183
+ };
184
+ const getCreateSessionFromCredentialsUrl = () => {
185
+ return `/auth/sessions`;
186
+ };
187
+ /**
188
+ * Log in with a username and password, via the broker's direct grant.
189
+ *
190
+ * Off unless ``AUTH_ALLOW_PASSWORD_GRANT`` says otherwise, and it should stay
191
+ * off wherever the client fleet allows: the grant defeats MFA, cannot reach a
192
+ * brokered partner, and puts the password through this process. It exists for
193
+ * the native apps already in the field.
194
+ *
195
+ * Rate limited on both the submitted username and the client address. Keyed on
196
+ * the lower-cased username so that case variation is not a way around the
197
+ * counter, and on the address so that spraying many usernames is bounded too.
198
+ * @summary Create Session From Credentials
199
+ */
200
+ const createSessionFromCredentials = async (credentialsWrite, options) => {
201
+ const getHeaders = (h) => {
202
+ if (!h) return {};
203
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
204
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
205
+ const headers = {};
206
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
207
+ return headers;
208
+ };
209
+ return request(getCreateSessionFromCredentialsUrl(), {
210
+ ...options,
211
+ method: "POST",
212
+ headers: {
213
+ "Content-Type": "application/json",
214
+ ...getHeaders(options?.headers)
215
+ },
216
+ body: JSON.stringify(credentialsWrite)
217
+ });
218
+ };
219
+ const getCreateSessionFromCredentialsMutationKey = () => ["createSessionFromCredentials"];
220
+ const getCreateSessionFromCredentialsMutationOptions = (options) => {
221
+ const mutationKey = getCreateSessionFromCredentialsMutationKey();
222
+ const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
223
+ ...options,
224
+ mutation: {
225
+ ...options.mutation,
226
+ mutationKey
227
+ }
228
+ } : {
229
+ mutation: { mutationKey },
230
+ request: void 0
231
+ };
232
+ const mutationFn = (props) => {
233
+ const { data } = props ?? {};
234
+ return createSessionFromCredentials(data, requestOptions);
235
+ };
236
+ return {
237
+ mutationFn,
238
+ ...mutationOptions
239
+ };
240
+ };
241
+ /**
242
+ * @summary Create Session From Credentials
243
+ */
244
+ const useCreateSessionFromCredentials = (options, queryClient) => {
245
+ return useMutation(getCreateSessionFromCredentialsMutationOptions(options), queryClient);
246
+ };
247
+ const getRefreshSessionUrl = () => {
248
+ return `/auth/sessions`;
249
+ };
250
+ /**
251
+ * Exchange a refresh token for a new pair.
252
+ *
253
+ * Public: the refresh token *is* the credential, so requiring a valid access
254
+ * token as well would make the endpoint useless at the moment it is needed.
255
+ * Rotation happens at the broker, so the presented token stops working as the
256
+ * new one is issued.
257
+ *
258
+ * Returns the account as well as the tokens. That costs one indexed lookup and
259
+ * means a client resuming from cold storage does not need a second call to
260
+ * discover whether the account is still active — which it checks, because
261
+ * deactivation is a local decision Keycloak knows nothing about.
262
+ * @summary Refresh Session
263
+ */
264
+ const refreshSession = async (refreshWrite, options) => {
265
+ const getHeaders = (h) => {
266
+ if (!h) return {};
267
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
268
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
269
+ const headers = {};
270
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
271
+ return headers;
272
+ };
273
+ return request(getRefreshSessionUrl(), {
274
+ ...options,
275
+ method: "PUT",
276
+ headers: {
277
+ "Content-Type": "application/json",
278
+ ...getHeaders(options?.headers)
279
+ },
280
+ body: JSON.stringify(refreshWrite)
281
+ });
282
+ };
283
+ const getRefreshSessionMutationKey = () => ["refreshSession"];
284
+ const getRefreshSessionMutationOptions = (options) => {
285
+ const mutationKey = getRefreshSessionMutationKey();
286
+ const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
287
+ ...options,
288
+ mutation: {
289
+ ...options.mutation,
290
+ mutationKey
291
+ }
292
+ } : {
293
+ mutation: { mutationKey },
294
+ request: void 0
295
+ };
296
+ const mutationFn = (props) => {
297
+ const { data } = props ?? {};
298
+ return refreshSession(data, requestOptions);
299
+ };
300
+ return {
301
+ mutationFn,
302
+ ...mutationOptions
303
+ };
304
+ };
305
+ /**
306
+ * @summary Refresh Session
307
+ */
308
+ const useRefreshSession = (options, queryClient) => {
309
+ return useMutation(getRefreshSessionMutationOptions(options), queryClient);
310
+ };
311
+ const getCreateSessionFromCodeUrl = () => {
312
+ return `/auth/sessions/code`;
313
+ };
314
+ /**
315
+ * Finish a brokered login: code plus verifier in, session out.
316
+ *
317
+ * Rate limited on the client address rather than on a user, because at this
318
+ * point there is no user — the code has not been exchanged yet. The limit is
319
+ * what stops a stolen code being brute-forced alongside a guessed verifier.
320
+ * @summary Create Session From Code
321
+ */
322
+ const createSessionFromCode = async (codeExchangeWrite, options) => {
323
+ const getHeaders = (h) => {
324
+ if (!h) return {};
325
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
326
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
327
+ const headers = {};
328
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
329
+ return headers;
330
+ };
331
+ return request(getCreateSessionFromCodeUrl(), {
332
+ ...options,
333
+ method: "POST",
334
+ headers: {
335
+ "Content-Type": "application/json",
336
+ ...getHeaders(options?.headers)
337
+ },
338
+ body: JSON.stringify(codeExchangeWrite)
339
+ });
340
+ };
341
+ const getCreateSessionFromCodeMutationKey = () => ["createSessionFromCode"];
342
+ const getCreateSessionFromCodeMutationOptions = (options) => {
343
+ const mutationKey = getCreateSessionFromCodeMutationKey();
344
+ const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
345
+ ...options,
346
+ mutation: {
347
+ ...options.mutation,
348
+ mutationKey
349
+ }
350
+ } : {
351
+ mutation: { mutationKey },
352
+ request: void 0
353
+ };
354
+ const mutationFn = (props) => {
355
+ const { data } = props ?? {};
356
+ return createSessionFromCode(data, requestOptions);
357
+ };
358
+ return {
359
+ mutationFn,
360
+ ...mutationOptions
361
+ };
362
+ };
363
+ /**
364
+ * @summary Create Session From Code
365
+ */
366
+ const useCreateSessionFromCode = (options, queryClient) => {
367
+ return useMutation(getCreateSessionFromCodeMutationOptions(options), queryClient);
368
+ };
369
+ //#endregion
370
+ export { authorization, createSessionFromCode, createSessionFromCredentials, deleteSession, getAuthorizationQueryKey, getAuthorizationQueryOptions, getAuthorizationUrl, getCreateSessionFromCodeMutationKey, getCreateSessionFromCodeMutationOptions, getCreateSessionFromCodeUrl, getCreateSessionFromCredentialsMutationKey, getCreateSessionFromCredentialsMutationOptions, getCreateSessionFromCredentialsUrl, getDeleteSessionMutationKey, getDeleteSessionMutationOptions, getDeleteSessionUrl, getReadMeQueryKey, getReadMeQueryOptions, getReadMeUrl, getRefreshSessionMutationKey, getRefreshSessionMutationOptions, getRefreshSessionUrl, readMe, refreshSession, useAuthorization, useCreateSessionFromCode, useCreateSessionFromCredentials, useDeleteSession, useReadMe, useRefreshSession };
371
+
372
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","names":[],"sources":["../../src/react/auth/auth.ts"],"sourcesContent":["/**\n * Generated by orval 🍺\n * Do not edit manually.\n * Mozaik backend\n * Four products behind one API — Biblio, Médiathèques, the partner catalogues (Nextory and YouScribe) and Prof Express. Authentication is Keycloak SSO only, once, for all of them: see the **auth** section below for the browser flow and the three failure modes.\n * OpenAPI spec version: 0.1.0\n */\nimport {\n useMutation,\n useQuery\n} from '@tanstack/react-query';\nimport type {\n DataTag,\n DefinedInitialDataOptions,\n DefinedUseQueryResult,\n MutationFunction,\n QueryClient,\n QueryFunction,\n QueryKey,\n UndefinedInitialDataOptions,\n UseMutationOptions,\n UseMutationResult,\n UseQueryOptions,\n UseQueryResult\n} from '@tanstack/react-query';\n\nimport type {\n AuthorizationParams,\n AuthorizationRead,\n CodeExchangeWrite,\n CredentialsWrite,\n HTTPExceptionResponse,\n LogoutWrite,\n MeRead,\n RefreshWrite,\n SessionRead,\n ValidationErrorResponse\n} from '../../models';\n\nimport { request } from '../../client';\nimport type { ErrorType , BodyType } from '../../client';\n\n\ntype SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];\n\n\n\nconst withQueryKey = <T extends object, K>(query: T, queryKey: K): T & { queryKey: K } => {\n const result = { queryKey } as T & { queryKey: K };\n for (const key of Object.keys(query)) {\n // The explicit queryKey always wins, matching the previous\n // `{ ...query, queryKey }` spread where it was set last.\n if (key === 'queryKey') continue;\n Object.defineProperty(result, key, {\n enumerable: true,\n configurable: true,\n get: () => (query as Record<string, unknown>)[key],\n });\n }\n return result;\n};\n\nexport const getAuthorizationUrl = (params: AuthorizationParams,) => {\n const normalizedParams = new URLSearchParams();\n\n Object.entries(params || {}).forEach(([key, value]) => {\n\n if (value !== undefined) {\n normalizedParams.append(key, value === null ? 'null' : String(value))\n }\n });\n\n const stringifiedParams = normalizedParams.toString();\n\n return stringifiedParams.length > 0 ? `/auth/authorization?${stringifiedParams}` : `/auth/authorization`\n}\n\n/**\n * Build the Keycloak authorization URL for this client and this tenant.\n *\n * Everything cryptographic belongs to the caller: it generates ``state``, the\n * PKCE verifier and the ``nonce``, and only ever sends the challenge. This\n * endpoint contributes the one thing the caller cannot know — which identity\n * provider to route to — and refuses an unsafe ``redirect_uri``.\n *\n * ``S256`` is hardcoded. ``plain`` is a valid PKCE method and provides no\n * protection, so making it selectable would only ever be used by mistake.\n *\n * A resolved provider is passed as ``kc_idp_hint``. Aliases are case-sensitive\n * at the broker and an unknown one silently falls back to the login form, which\n * is why :func:`_resolve_provider_alias` validates against the registry instead\n * of forwarding whatever arrived.\n * @summary Authorization\n */\nexport const authorization = async (params: AuthorizationParams, options?: Parameters<typeof request>[1]): Promise<AuthorizationRead> => {\n\n return request<AuthorizationRead>(getAuthorizationUrl(params),\n {\n ...options,\n method: 'GET'\n\n\n }\n);}\n\n\n\n\n\nexport const getAuthorizationQueryKey = (params?: AuthorizationParams,) => {\n return [\n `/auth/authorization`, ...(params ? [params] : [])\n ] as const;\n }\n\n\nexport const getAuthorizationQueryOptions = <TData = Awaited<ReturnType<typeof authorization>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(params: AuthorizationParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof authorization>>, TError, TData>>, request?: SecondParameter<typeof request>}\n) => {\n\nconst {query: queryOptions, request: requestOptions} = options ?? {};\n\n const queryKey = queryOptions?.queryKey ?? getAuthorizationQueryKey(params);\n\n\n\n const queryFn: QueryFunction<Awaited<ReturnType<typeof authorization>>> = ({ signal }) => authorization(params, { signal, ...requestOptions });\n\n\n\n\n\n return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof authorization>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }\n}\n\nexport type AuthorizationQueryResult = NonNullable<Awaited<ReturnType<typeof authorization>>>\nexport type AuthorizationQueryError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n\n\nexport function useAuthorization<TData = Awaited<ReturnType<typeof authorization>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params: AuthorizationParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof authorization>>, TError, TData>> & Pick<\n DefinedInitialDataOptions<\n Awaited<ReturnType<typeof authorization>>,\n TError,\n Awaited<ReturnType<typeof authorization>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useAuthorization<TData = Awaited<ReturnType<typeof authorization>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params: AuthorizationParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof authorization>>, TError, TData>> & Pick<\n UndefinedInitialDataOptions<\n Awaited<ReturnType<typeof authorization>>,\n TError,\n Awaited<ReturnType<typeof authorization>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useAuthorization<TData = Awaited<ReturnType<typeof authorization>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params: AuthorizationParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof authorization>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\n/**\n * @summary Authorization\n */\n\nexport function useAuthorization<TData = Awaited<ReturnType<typeof authorization>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params: AuthorizationParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof authorization>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {\n\n const queryOptions = getAuthorizationQueryOptions(params,options)\n\n const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };\n\n return withQueryKey(query, queryOptions.queryKey);\n}\n\n\n\n\n\n\nexport const getReadMeUrl = () => {\n\n\n\n\n return `/auth/me`\n}\n\n/**\n * Who the bearer of this token is, and what the session may do.\n *\n * No tokens in the response — this endpoint reissues nothing, and a shape with\n * empty token fields would invite a client to store them. It is also the\n * cheapest liveness check a client has: it exercises verification,\n * tenant resolution and the account link in one call, so a 200 here means the\n * whole chain is intact.\n * @summary Read Me\n */\nexport const readMe = async ( options?: Parameters<typeof request>[1]): Promise<MeRead> => {\n\n return request<MeRead>(getReadMeUrl(),\n {\n ...options,\n method: 'GET'\n\n\n }\n);}\n\n\n\n\n\nexport const getReadMeQueryKey = () => {\n return [\n `/auth/me`\n ] as const;\n }\n\n\nexport const getReadMeQueryOptions = <TData = Awaited<ReturnType<typeof readMe>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>( options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof readMe>>, TError, TData>>, request?: SecondParameter<typeof request>}\n) => {\n\nconst {query: queryOptions, request: requestOptions} = options ?? {};\n\n const queryKey = queryOptions?.queryKey ?? getReadMeQueryKey();\n\n\n\n const queryFn: QueryFunction<Awaited<ReturnType<typeof readMe>>> = ({ signal }) => readMe({ signal, ...requestOptions });\n\n\n\n\n\n return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof readMe>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }\n}\n\nexport type ReadMeQueryResult = NonNullable<Awaited<ReturnType<typeof readMe>>>\nexport type ReadMeQueryError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n\n\nexport function useReadMe<TData = Awaited<ReturnType<typeof readMe>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof readMe>>, TError, TData>> & Pick<\n DefinedInitialDataOptions<\n Awaited<ReturnType<typeof readMe>>,\n TError,\n Awaited<ReturnType<typeof readMe>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useReadMe<TData = Awaited<ReturnType<typeof readMe>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof readMe>>, TError, TData>> & Pick<\n UndefinedInitialDataOptions<\n Awaited<ReturnType<typeof readMe>>,\n TError,\n Awaited<ReturnType<typeof readMe>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useReadMe<TData = Awaited<ReturnType<typeof readMe>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof readMe>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\n/**\n * @summary Read Me\n */\n\nexport function useReadMe<TData = Awaited<ReturnType<typeof readMe>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof readMe>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {\n\n const queryOptions = getReadMeQueryOptions(options)\n\n const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };\n\n return withQueryKey(query, queryOptions.queryKey);\n}\n\n\n\n\n\n\nexport const getDeleteSessionUrl = () => {\n\n\n\n\n return `/auth/sessions`\n}\n\n/**\n * Sign out, revoking the refresh token at the broker.\n *\n * Always 204. A logout that can fail is a logout users do not trust, and there\n * is nothing useful for the caller to do about an unreachable broker — it is\n * discarding its tokens either way. The failure is logged, not returned.\n *\n * The access token stays valid until it expires. That is inherent to verifying\n * tokens offline, and it is why the realm keeps access-token lifetimes short\n * rather than why this endpoint should pretend otherwise.\n * @summary Delete Session\n */\nexport const deleteSession = async (logoutWrite: LogoutWrite, options?: Parameters<typeof request>[1]): Promise<void> => {\n\n const getHeaders = (h?: NonNullable<RequestInit['headers']>): Record<string, string | readonly string[]> => {\n if (!h) return {};\n if (h instanceof Headers) return Object.fromEntries(h.entries());\n if (Symbol.iterator in h) {\n return Object.fromEntries(\n Array.from(h as Iterable<Iterable<string>>, (entry) => Array.from(entry) as [string, string]),\n );\n }\n const headers: Record<string, string | readonly string[]> = {};\n for (const [name, value] of Object.entries<string | readonly string[] | undefined>(h)) {\n if (value !== undefined) headers[name] = value;\n }\n return headers;\n };\nreturn request<void>(getDeleteSessionUrl(),\n {\n ...options,\n method: 'DELETE',\n headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },\n body: JSON.stringify(logoutWrite)\n }\n);}\n\n\n\n\n\nexport const getDeleteSessionMutationKey = () => ['deleteSession'] as const;\n\nexport const getDeleteSessionMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteSession>>, TError,DeleteSessionMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof deleteSession>>, TError,DeleteSessionMutationVariables, TContext> => {\n\nconst mutationKey = getDeleteSessionMutationKey();\nconst {mutation: mutationOptions, request: requestOptions} = options ?\n options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?\n options\n : {...options, mutation: {...options.mutation, mutationKey}}\n : {mutation: { mutationKey, }, request: undefined};\n\n\n\n\n const mutationFn: MutationFunction<Awaited<ReturnType<typeof deleteSession>>, DeleteSessionMutationVariables> = (props) => {\n const {data} = props ?? {};\n\n return deleteSession(data,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type DeleteSessionMutationResult = NonNullable<Awaited<ReturnType<typeof deleteSession>>>\n export type DeleteSessionMutationBody = BodyType<LogoutWrite>\n export type DeleteSessionMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type DeleteSessionMutationVariables = {data: BodyType<LogoutWrite>}\n\n /**\n * @summary Delete Session\n */\nexport const useDeleteSession = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteSession>>, TError,DeleteSessionMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof deleteSession>>,\n TError,\n DeleteSessionMutationVariables,\n TContext\n > => {\n return useMutation(getDeleteSessionMutationOptions(options), queryClient);\n }\n export const getCreateSessionFromCredentialsUrl = () => {\n\n\n\n\n return `/auth/sessions`\n}\n\n/**\n * Log in with a username and password, via the broker's direct grant.\n *\n * Off unless ``AUTH_ALLOW_PASSWORD_GRANT`` says otherwise, and it should stay\n * off wherever the client fleet allows: the grant defeats MFA, cannot reach a\n * brokered partner, and puts the password through this process. It exists for\n * the native apps already in the field.\n *\n * Rate limited on both the submitted username and the client address. Keyed on\n * the lower-cased username so that case variation is not a way around the\n * counter, and on the address so that spraying many usernames is bounded too.\n * @summary Create Session From Credentials\n */\nexport const createSessionFromCredentials = async (credentialsWrite: CredentialsWrite, options?: Parameters<typeof request>[1]): Promise<SessionRead> => {\n\n const getHeaders = (h?: NonNullable<RequestInit['headers']>): Record<string, string | readonly string[]> => {\n if (!h) return {};\n if (h instanceof Headers) return Object.fromEntries(h.entries());\n if (Symbol.iterator in h) {\n return Object.fromEntries(\n Array.from(h as Iterable<Iterable<string>>, (entry) => Array.from(entry) as [string, string]),\n );\n }\n const headers: Record<string, string | readonly string[]> = {};\n for (const [name, value] of Object.entries<string | readonly string[] | undefined>(h)) {\n if (value !== undefined) headers[name] = value;\n }\n return headers;\n };\nreturn request<SessionRead>(getCreateSessionFromCredentialsUrl(),\n {\n ...options,\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },\n body: JSON.stringify(credentialsWrite)\n }\n);}\n\n\n\n\n\nexport const getCreateSessionFromCredentialsMutationKey = () => ['createSessionFromCredentials'] as const;\n\nexport const getCreateSessionFromCredentialsMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createSessionFromCredentials>>, TError,CreateSessionFromCredentialsMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof createSessionFromCredentials>>, TError,CreateSessionFromCredentialsMutationVariables, TContext> => {\n\nconst mutationKey = getCreateSessionFromCredentialsMutationKey();\nconst {mutation: mutationOptions, request: requestOptions} = options ?\n options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?\n options\n : {...options, mutation: {...options.mutation, mutationKey}}\n : {mutation: { mutationKey, }, request: undefined};\n\n\n\n\n const mutationFn: MutationFunction<Awaited<ReturnType<typeof createSessionFromCredentials>>, CreateSessionFromCredentialsMutationVariables> = (props) => {\n const {data} = props ?? {};\n\n return createSessionFromCredentials(data,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type CreateSessionFromCredentialsMutationResult = NonNullable<Awaited<ReturnType<typeof createSessionFromCredentials>>>\n export type CreateSessionFromCredentialsMutationBody = BodyType<CredentialsWrite>\n export type CreateSessionFromCredentialsMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type CreateSessionFromCredentialsMutationVariables = {data: BodyType<CredentialsWrite>}\n\n /**\n * @summary Create Session From Credentials\n */\nexport const useCreateSessionFromCredentials = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createSessionFromCredentials>>, TError,CreateSessionFromCredentialsMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof createSessionFromCredentials>>,\n TError,\n CreateSessionFromCredentialsMutationVariables,\n TContext\n > => {\n return useMutation(getCreateSessionFromCredentialsMutationOptions(options), queryClient);\n }\n export const getRefreshSessionUrl = () => {\n\n\n\n\n return `/auth/sessions`\n}\n\n/**\n * Exchange a refresh token for a new pair.\n *\n * Public: the refresh token *is* the credential, so requiring a valid access\n * token as well would make the endpoint useless at the moment it is needed.\n * Rotation happens at the broker, so the presented token stops working as the\n * new one is issued.\n *\n * Returns the account as well as the tokens. That costs one indexed lookup and\n * means a client resuming from cold storage does not need a second call to\n * discover whether the account is still active — which it checks, because\n * deactivation is a local decision Keycloak knows nothing about.\n * @summary Refresh Session\n */\nexport const refreshSession = async (refreshWrite: RefreshWrite, options?: Parameters<typeof request>[1]): Promise<SessionRead> => {\n\n const getHeaders = (h?: NonNullable<RequestInit['headers']>): Record<string, string | readonly string[]> => {\n if (!h) return {};\n if (h instanceof Headers) return Object.fromEntries(h.entries());\n if (Symbol.iterator in h) {\n return Object.fromEntries(\n Array.from(h as Iterable<Iterable<string>>, (entry) => Array.from(entry) as [string, string]),\n );\n }\n const headers: Record<string, string | readonly string[]> = {};\n for (const [name, value] of Object.entries<string | readonly string[] | undefined>(h)) {\n if (value !== undefined) headers[name] = value;\n }\n return headers;\n };\nreturn request<SessionRead>(getRefreshSessionUrl(),\n {\n ...options,\n method: 'PUT',\n headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },\n body: JSON.stringify(refreshWrite)\n }\n);}\n\n\n\n\n\nexport const getRefreshSessionMutationKey = () => ['refreshSession'] as const;\n\nexport const getRefreshSessionMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof refreshSession>>, TError,RefreshSessionMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof refreshSession>>, TError,RefreshSessionMutationVariables, TContext> => {\n\nconst mutationKey = getRefreshSessionMutationKey();\nconst {mutation: mutationOptions, request: requestOptions} = options ?\n options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?\n options\n : {...options, mutation: {...options.mutation, mutationKey}}\n : {mutation: { mutationKey, }, request: undefined};\n\n\n\n\n const mutationFn: MutationFunction<Awaited<ReturnType<typeof refreshSession>>, RefreshSessionMutationVariables> = (props) => {\n const {data} = props ?? {};\n\n return refreshSession(data,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type RefreshSessionMutationResult = NonNullable<Awaited<ReturnType<typeof refreshSession>>>\n export type RefreshSessionMutationBody = BodyType<RefreshWrite>\n export type RefreshSessionMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type RefreshSessionMutationVariables = {data: BodyType<RefreshWrite>}\n\n /**\n * @summary Refresh Session\n */\nexport const useRefreshSession = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof refreshSession>>, TError,RefreshSessionMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof refreshSession>>,\n TError,\n RefreshSessionMutationVariables,\n TContext\n > => {\n return useMutation(getRefreshSessionMutationOptions(options), queryClient);\n }\n export const getCreateSessionFromCodeUrl = () => {\n\n\n\n\n return `/auth/sessions/code`\n}\n\n/**\n * Finish a brokered login: code plus verifier in, session out.\n *\n * Rate limited on the client address rather than on a user, because at this\n * point there is no user — the code has not been exchanged yet. The limit is\n * what stops a stolen code being brute-forced alongside a guessed verifier.\n * @summary Create Session From Code\n */\nexport const createSessionFromCode = async (codeExchangeWrite: CodeExchangeWrite, options?: Parameters<typeof request>[1]): Promise<SessionRead> => {\n\n const getHeaders = (h?: NonNullable<RequestInit['headers']>): Record<string, string | readonly string[]> => {\n if (!h) return {};\n if (h instanceof Headers) return Object.fromEntries(h.entries());\n if (Symbol.iterator in h) {\n return Object.fromEntries(\n Array.from(h as Iterable<Iterable<string>>, (entry) => Array.from(entry) as [string, string]),\n );\n }\n const headers: Record<string, string | readonly string[]> = {};\n for (const [name, value] of Object.entries<string | readonly string[] | undefined>(h)) {\n if (value !== undefined) headers[name] = value;\n }\n return headers;\n };\nreturn request<SessionRead>(getCreateSessionFromCodeUrl(),\n {\n ...options,\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },\n body: JSON.stringify(codeExchangeWrite)\n }\n);}\n\n\n\n\n\nexport const getCreateSessionFromCodeMutationKey = () => ['createSessionFromCode'] as const;\n\nexport const getCreateSessionFromCodeMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createSessionFromCode>>, TError,CreateSessionFromCodeMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof createSessionFromCode>>, TError,CreateSessionFromCodeMutationVariables, TContext> => {\n\nconst mutationKey = getCreateSessionFromCodeMutationKey();\nconst {mutation: mutationOptions, request: requestOptions} = options ?\n options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?\n options\n : {...options, mutation: {...options.mutation, mutationKey}}\n : {mutation: { mutationKey, }, request: undefined};\n\n\n\n\n const mutationFn: MutationFunction<Awaited<ReturnType<typeof createSessionFromCode>>, CreateSessionFromCodeMutationVariables> = (props) => {\n const {data} = props ?? {};\n\n return createSessionFromCode(data,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type CreateSessionFromCodeMutationResult = NonNullable<Awaited<ReturnType<typeof createSessionFromCode>>>\n export type CreateSessionFromCodeMutationBody = BodyType<CodeExchangeWrite>\n export type CreateSessionFromCodeMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type CreateSessionFromCodeMutationVariables = {data: BodyType<CodeExchangeWrite>}\n\n /**\n * @summary Create Session From Code\n */\nexport const useCreateSessionFromCode = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createSessionFromCode>>, TError,CreateSessionFromCodeMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof createSessionFromCode>>,\n TError,\n CreateSessionFromCodeMutationVariables,\n TContext\n > => {\n return useMutation(getCreateSessionFromCodeMutationOptions(options), queryClient);\n }\n"],"mappings":";;;;;;;;;;;AA+CA,MAAM,gBAAqC,OAAU,aAAqC;CACxF,MAAM,SAAS,EAAE,SAAS;CAC1B,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG;EAGpC,IAAI,QAAQ,YAAY;EACxB,OAAO,eAAe,QAAQ,KAAK;GACjC,YAAY;GACZ,cAAc;GACd,WAAY,MAAkC;EAChD,CAAC;CACH;CACA,OAAO;AACT;AAEA,MAAa,uBAAuB,WAAiC;CACnE,MAAM,mBAAmB,IAAI,gBAAgB;CAE7C,OAAO,QAAQ,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW;EAErD,IAAI,UAAU,KAAA,GACZ,iBAAiB,OAAO,KAAK,UAAU,OAAO,SAAS,OAAO,KAAK,CAAC;CAExE,CAAC;CAED,MAAM,oBAAoB,iBAAiB,SAAS;CAEpD,OAAO,kBAAkB,SAAS,IAAI,uBAAuB,sBAAsB;AACrF;;;;;;;;;;;;;;;;;;AAmBA,MAAa,gBAAgB,OAAO,QAA6B,YAAwE;CAEvI,OAAO,QAA2B,oBAAoB,MAAM,GAC5D;EACE,GAAG;EACH,QAAQ;CAGV,CACF;AAAE;AAMF,MAAa,4BAA4B,WAAkC;CACvE,OAAO,CACP,uBAAuB,GAAI,SAAS,CAAC,MAAM,IAAI,CAAC,CAChD;AACA;AAGJ,MAAa,gCAAwJ,QAA6B,YAC7L;CAEL,MAAM,EAAC,OAAO,cAAc,SAAS,mBAAkB,WAAW,CAAC;CAEjE,MAAM,WAAY,cAAc,YAAY,yBAAyB,MAAM;CAIzE,MAAM,WAAqE,EAAE,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