@molecule/app-http-axios 1.0.2 → 1.0.4

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.
package/LICENSE CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  Apache License
2
3
  Version 2.0, January 2004
3
4
  http://www.apache.org/licenses/
@@ -34,21 +35,33 @@
34
35
 
35
36
  "Work" shall mean the work of authorship, whether in Source or
36
37
  Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work.
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
38
40
 
39
41
  "Derivative Works" shall mean any work, whether in Source or Object
40
42
  form, that is based on (or derived from) the Work and for which the
41
43
  editorial revisions, annotations, elaborations, or other modifications
42
- represent, as a whole, an original work of authorship.
43
-
44
- "Contribution" shall mean any work of authorship, including the
45
- original version of the Work and any modifications or additions
46
- to that Work, that is intentionally submitted to the Licensor for
47
- inclusion in the Work by the copyright owner or by an individual or
48
- Legal Entity authorized to submit on behalf of the copyright owner.
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
49
62
 
50
63
  "Contributor" shall mean Licensor and any individual or Legal Entity
51
- on behalf of whom a Contribution has been received by the Licensor and
64
+ on behalf of whom a Contribution has been received by Licensor and
52
65
  subsequently incorporated within the Work.
53
66
 
54
67
  2. Grant of Copyright License. Subject to the terms and conditions of
@@ -61,8 +74,18 @@
61
74
  3. Grant of Patent License. Subject to the terms and conditions of
62
75
  this License, each Contributor hereby grants to You a perpetual,
63
76
  worldwide, non-exclusive, no-charge, royalty-free, irrevocable
64
- patent license to make, have made, use, offer to sell, sell, import,
65
- and otherwise transfer the Work.
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
66
89
 
67
90
  4. Redistribution. You may reproduce and distribute copies of the
68
91
  Work or Derivative Works thereof in any medium, with or without
@@ -84,23 +107,87 @@
84
107
  (d) If the Work includes a "NOTICE" text file as part of its
85
108
  distribution, then any Derivative Works that You distribute must
86
109
  include a readable copy of the attribution notices contained
87
- within such NOTICE file.
88
-
89
- 5. Submission of Contributions.
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
90
138
 
91
139
  6. Trademarks. This License does not grant permission to use the trade
92
- names, trademarks, service marks, or product names of the Licensor.
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
93
143
 
94
144
  7. Disclaimer of Warranty. Unless required by applicable law or
95
- agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
96
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
97
-
98
- 8. Limitation of Liability. In no event and under no legal theory shall
99
- any Contributor be liable to You for damages.
100
-
101
- 9. Accepting Warranty or Additional Liability.
102
-
103
- Copyright 2026 Molecule Dev, Inc.
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
104
191
 
105
192
  Licensed under the Apache License, Version 2.0 (the "License");
106
193
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -3,20 +3,20 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-08-04T01:50:59.135Z
6
+ Generated: 2026-10-17T00:20:54.724Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-http-axios
10
10
 
11
- > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
- > It is written to be read by coding agents as much as by people, and is generated from this
13
- > package's source — edit `src/index.ts` JSDoc, not this file.
14
-
15
11
  Axios HTTP client provider for `@molecule/app-http`.
16
12
 
17
13
  This package provides an Axios-based implementation of the molecule HttpClient interface,
18
14
  allowing you to use molecule's HTTP abstractions with Axios.
19
15
 
16
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
17
+ > It is written to be read by coding agents as much as by people, and is generated from this
18
+ > package's source — edit `src/index.ts` JSDoc, not this file.
19
+
20
20
  ## Quick Start
21
21
 
22
22
  ```ts
@@ -76,6 +76,17 @@ interface AxiosHttpClientConfig {
76
76
  */
77
77
  withCredentials?: boolean
78
78
 
79
+ /**
80
+ * The scheme of the `Authorization` header the auth token is sent with:
81
+ * `Bearer` (default), or what your API expects, e.g. `Token` for an API that
82
+ * reads `Authorization: Token <jwt>`. Pass it to this config, at construction —
83
+ * `setClient(createAxiosClient({ baseURL, authScheme: 'Token' }))` — never as a
84
+ * property of the client it returns. Same option as `@molecule/app-http`'s
85
+ * `HttpClientConfig.authScheme`, so the config reads the same whichever
86
+ * transport is bonded.
87
+ */
88
+ authScheme?: string
89
+
79
90
  /**
80
91
  * Existing Axios instance to wrap (optional).
81
92
  */
@@ -88,27 +99,6 @@ interface AxiosHttpClientConfig {
88
99
  }
89
100
  ```
90
101
 
91
- #### `FullRequestConfig`
92
-
93
- Full request configuration including method and URL.
94
-
95
- ```typescript
96
- interface FullRequestConfig extends RequestConfig {
97
- /**
98
- * HTTP method.
99
- */
100
- method: HttpMethod
101
- /**
102
- * Request URL (can be relative or absolute).
103
- */
104
- url: string
105
- /**
106
- * Request body data.
107
- */
108
- data?: unknown
109
- }
110
- ```
111
-
112
102
  #### `HttpClient`
113
103
 
114
104
  HTTP client interface.
@@ -203,35 +193,15 @@ interface HttpClientConfig {
203
193
  * Whether to include credentials by default.
204
194
  */
205
195
  withCredentials?: boolean
206
- }
207
- ```
208
-
209
- #### `HttpResponse`
210
-
211
- Parsed HTTP response with status code, headers, and typed body data.
212
-
213
- ```typescript
214
- interface HttpResponse<T = unknown> {
215
- /**
216
- * Response data.
217
- */
218
- data: T
219
196
  /**
220
- * HTTP status code.
197
+ * The scheme of the `Authorization` header the auth token is sent with:
198
+ * `Bearer` (default), or what your API expects, e.g. `Token` for an API that
199
+ * reads `Authorization: Token <jwt>`. It is an option of the client's
200
+ * CONSTRUCTOR (`createFetchClient({ baseURL, authScheme: 'Token' })`, or the
201
+ * bonded provider's `createAxiosClient({ … })`), never a property of the client
202
+ * it returns.
221
203
  */
222
- status: number
223
- /**
224
- * HTTP status text.
225
- */
226
- statusText: string
227
- /**
228
- * Response headers.
229
- */
230
- headers: Record<string, string>
231
- /**
232
- * Original request config.
233
- */
234
- config: FullRequestConfig
204
+ authScheme?: string
235
205
  }
236
206
  ```
237
207
 
@@ -239,7 +209,7 @@ interface HttpResponse<T = unknown> {
239
209
 
240
210
  HTTP request options (headers, query params, timeout, credentials, response type, abort signal).
241
211
 
242
- ```typescript
212
+ ````typescript
243
213
  interface RequestConfig {
244
214
  /**
245
215
  * Request headers.
@@ -257,6 +227,25 @@ interface RequestConfig {
257
227
  * Whether to include credentials (cookies).
258
228
  */
259
229
  withCredentials?: boolean
230
+ /**
231
+ * Send this request WITHOUT waiting for the session restore (the auth gate).
232
+ *
233
+ * A request the gate itself depends on must set this. A gate registered with
234
+ * `setAuthGate` that waits for a session restore whose own request goes through this
235
+ * client otherwise waits on itself: the gate holds the restore's request, the restore's
236
+ * promise never settles, and every request on the page stalls until the gate times out —
237
+ * so pass `skipAuthGate: true` on the restore's own request:
238
+ *
239
+ * ```typescript
240
+ * // the request the gate's restore makes, through the same client the gate holds back
241
+ * await http.get(currentUserEndpoint, { skipAuthGate: true })
242
+ * ```
243
+ *
244
+ * `@molecule/app-auth`'s own restore does not need it — it sends its request with
245
+ * `fetch`, not through this client. An app with its own session store that registers a
246
+ * gate with `setAuthGate` does.
247
+ */
248
+ skipAuthGate?: boolean
260
249
  /**
261
250
  * Response type.
262
251
  */
@@ -274,27 +263,60 @@ interface RequestConfig {
274
263
  */
275
264
  options?: Record<string, unknown>
276
265
  }
277
- ```
266
+ ````
278
267
 
279
- ### Types
280
-
281
- #### `ErrorInterceptor`
268
+ #### `FullRequestConfig`
282
269
 
283
- Intercepts HTTP errors to transform, retry, or rethrow them.
284
- Throwing from this interceptor propagates the error to the caller.
270
+ Full request configuration including method and URL.
285
271
 
286
272
  ```typescript
287
- type ErrorInterceptor = (error: HttpError) => HttpError | Promise<HttpError> | never
273
+ interface FullRequestConfig extends RequestConfig {
274
+ /**
275
+ * HTTP method.
276
+ */
277
+ method: HttpMethod
278
+ /**
279
+ * Request URL (can be relative or absolute).
280
+ */
281
+ url: string
282
+ /**
283
+ * Request body data.
284
+ */
285
+ data?: unknown
286
+ }
288
287
  ```
289
288
 
290
- #### `HttpMethod`
289
+ #### `HttpResponse`
291
290
 
292
- HTTP request method.
291
+ Parsed HTTP response with status code, headers, and typed body data.
293
292
 
294
293
  ```typescript
295
- type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS'
294
+ interface HttpResponse<T = unknown> {
295
+ /**
296
+ * Response data.
297
+ */
298
+ data: T
299
+ /**
300
+ * HTTP status code.
301
+ */
302
+ status: number
303
+ /**
304
+ * HTTP status text.
305
+ */
306
+ statusText: string
307
+ /**
308
+ * Response headers.
309
+ */
310
+ headers: Record<string, string>
311
+ /**
312
+ * Original request config.
313
+ */
314
+ config: FullRequestConfig
315
+ }
296
316
  ```
297
317
 
318
+ ### Types
319
+
298
320
  #### `RequestInterceptor`
299
321
 
300
322
  Intercepts outgoing requests to modify headers, URL, or body
@@ -306,6 +328,8 @@ type RequestInterceptor = (
306
328
  ) => FullRequestConfig | Promise<FullRequestConfig>
307
329
  ```
308
330
 
331
+ - `config` — The full request configuration to transform.
332
+
309
333
  #### `ResponseInterceptor`
310
334
 
311
335
  Intercepts incoming responses to transform data, check status,
@@ -317,12 +341,45 @@ type ResponseInterceptor<T = unknown> = (
317
341
  ) => HttpResponse<T> | Promise<HttpResponse<T>>
318
342
  ```
319
343
 
344
+ #### `ErrorInterceptor`
345
+
346
+ Intercepts HTTP errors to transform, retry, or rethrow them.
347
+ Throwing from this interceptor propagates the error to the caller.
348
+
349
+ ```typescript
350
+ type ErrorInterceptor = (error: HttpError) => HttpError | Promise<HttpError> | never
351
+ ```
352
+
353
+ #### `HttpMethod`
354
+
355
+ HTTP request method.
356
+
357
+ ```typescript
358
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS'
359
+ ```
360
+
320
361
  ### Classes
321
362
 
322
363
  #### `HttpError`
323
364
 
324
365
  HTTP error with response details.
325
366
 
367
+ ```typescript
368
+ declare class HttpError extends Error {
369
+ status: number
370
+ response?: HttpResponse | undefined
371
+ config?: FullRequestConfig | undefined
372
+ errorKey?: string | undefined
373
+ constructor(
374
+ message: string,
375
+ status: number,
376
+ response?: HttpResponse | undefined,
377
+ config?: FullRequestConfig | undefined,
378
+ errorKey?: string | undefined,
379
+ )
380
+ }
381
+ ```
382
+
326
383
  ### Functions
327
384
 
328
385
  #### `createAxiosClient(config)`
@@ -334,7 +391,7 @@ Supports request/response/error interceptors, auth token management, and 401 err
334
391
  function createAxiosClient(config?: AxiosHttpClientConfig): HttpClient
335
392
  ```
336
393
 
337
- - `config` — Axios client configuration (base URL, headers, timeout, credentials, or an existing Axios instance).
394
+ - `config` — Axios client configuration (base URL, headers, timeout, credentials, auth scheme, or an existing Axios instance).
338
395
 
339
396
  **Returns:** An `HttpClient` backed by Axios with interceptor and auth token support.
340
397
 
@@ -388,6 +445,14 @@ Peer dependencies:
388
445
  - The exported `provider` constant is a pre-built default client (no baseURL,
389
446
  30 s timeout); prefer `createAxiosClient({...})` so baseURL/credentials are
390
447
  explicit.
448
+ - An API whose scheme is not `Bearer` (`Authorization: Token <jwt>`) passes
449
+ `authScheme: 'Token'` to THIS package's constructor —
450
+ `setClient(createAxiosClient({ baseURL, authScheme: 'Token' }))` — and the auth
451
+ token is then sent with that scheme. It is NOT a property of the client
452
+ `setClient()`/`getClient()` hands around: that is a built `HttpClient`, and
453
+ `client.authScheme = 'Token'` is a type error that changes no header. The option
454
+ name is the same one `@molecule/app-http`'s `HttpClientConfig` declares, so the
455
+ config reads the same whichever transport is bonded.
391
456
  - `instance`/`axiosConfig` accept raw Axios options — anything the app sets
392
457
  there couples it to Axios; keep app code on the `@molecule/app-http`
393
458
  interface so the bond stays swappable.
package/dist/index.d.ts CHANGED
@@ -34,6 +34,14 @@
34
34
  * - The exported `provider` constant is a pre-built default client (no baseURL,
35
35
  * 30 s timeout); prefer `createAxiosClient({...})` so baseURL/credentials are
36
36
  * explicit.
37
+ * - An API whose scheme is not `Bearer` (`Authorization: Token <jwt>`) passes
38
+ * `authScheme: 'Token'` to THIS package's constructor —
39
+ * `setClient(createAxiosClient({ baseURL, authScheme: 'Token' }))` — and the auth
40
+ * token is then sent with that scheme. It is NOT a property of the client
41
+ * `setClient()`/`getClient()` hands around: that is a built `HttpClient`, and
42
+ * `client.authScheme = 'Token'` is a type error that changes no header. The option
43
+ * name is the same one `@molecule/app-http`'s `HttpClientConfig` declares, so the
44
+ * config reads the same whichever transport is bonded.
37
45
  * - `instance`/`axiosConfig` accept raw Axios options — anything the app sets
38
46
  * there couples it to Axios; keep app code on the `@molecule/app-http`
39
47
  * interface so the bond stays swappable.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -34,6 +34,14 @@
34
34
  * - The exported `provider` constant is a pre-built default client (no baseURL,
35
35
  * 30 s timeout); prefer `createAxiosClient({...})` so baseURL/credentials are
36
36
  * explicit.
37
+ * - An API whose scheme is not `Bearer` (`Authorization: Token <jwt>`) passes
38
+ * `authScheme: 'Token'` to THIS package's constructor —
39
+ * `setClient(createAxiosClient({ baseURL, authScheme: 'Token' }))` — and the auth
40
+ * token is then sent with that scheme. It is NOT a property of the client
41
+ * `setClient()`/`getClient()` hands around: that is a built `HttpClient`, and
42
+ * `client.authScheme = 'Token'` is a type error that changes no header. The option
43
+ * name is the same one `@molecule/app-http`'s `HttpClientConfig` declares, so the
44
+ * config reads the same whichever transport is bonded.
37
45
  * - `instance`/`axiosConfig` accept raw Axios options — anything the app sets
38
46
  * there couples it to Axios; keep app code on the `@molecule/app-http`
39
47
  * interface so the bond stays swappable.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA"}
@@ -22,7 +22,13 @@ import type { AxiosHttpClientConfig, HttpClient } from './types.js';
22
22
  * const response = await client.get('/users')
23
23
  * ```
24
24
  *
25
- * @param config - Axios client configuration (base URL, headers, timeout, credentials, or an existing Axios instance).
25
+ * An API that reads another scheme than `Bearer` (`Authorization: Token <jwt>`) passes
26
+ * `authScheme: 'Token'` HERE, in this constructor —
27
+ * `setClient(createAxiosClient({ baseURL, authScheme: 'Token' }))` — and the auth token is
28
+ * then sent with that scheme. It is the same option `@molecule/app-http`'s own client
29
+ * takes, and not a property of the client you pass to `setClient()`.
30
+ *
31
+ * @param config - Axios client configuration (base URL, headers, timeout, credentials, auth scheme, or an existing Axios instance).
26
32
  * @returns An `HttpClient` backed by Axios with interceptor and auth token support.
27
33
  */
28
34
  export declare function createAxiosClient(config?: AxiosHttpClientConfig): HttpClient;
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,KAAK,EACV,qBAAqB,EAGrB,UAAU,EAKX,MAAM,YAAY,CAAA;AAmDnB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,qBAA0B,GAAG,UAAU,CAkQhF;AAED,+FAA+F;AAC/F,eAAO,MAAM,QAAQ,YAAsB,CAAA"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,OAAO,KAAK,EACV,qBAAqB,EAGrB,UAAU,EAKX,MAAM,YAAY,CAAA;AA8DnB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,qBAA0B,GAAG,UAAU,CA2QhF;AAED,+FAA+F;AAC/F,eAAO,MAAM,QAAQ,YAAsB,CAAA"}
package/dist/provider.js CHANGED
@@ -4,6 +4,7 @@
4
4
  * @module
5
5
  */
6
6
  import axios from 'axios';
7
+ import { awaitAuthGate } from '@molecule/app-http';
7
8
  import { HttpError } from './types.js';
8
9
  /**
9
10
  * Converts a molecule `RequestConfig` to an Axios-compatible `AxiosRequestConfig`.
@@ -20,6 +21,8 @@ function toAxiosConfig(config) {
20
21
  signal: config.signal,
21
22
  data: config.data,
22
23
  ...config.options,
24
+ // After `config.options`, so the documented option wins over an implementation-specific one.
25
+ skipAuthGate: config.skipAuthGate,
23
26
  };
24
27
  }
25
28
  /**
@@ -68,11 +71,17 @@ function toHttpResponse(response, config) {
68
71
  * const response = await client.get('/users')
69
72
  * ```
70
73
  *
71
- * @param config - Axios client configuration (base URL, headers, timeout, credentials, or an existing Axios instance).
74
+ * An API that reads another scheme than `Bearer` (`Authorization: Token <jwt>`) passes
75
+ * `authScheme: 'Token'` HERE, in this constructor —
76
+ * `setClient(createAxiosClient({ baseURL, authScheme: 'Token' }))` — and the auth token is
77
+ * then sent with that scheme. It is the same option `@molecule/app-http`'s own client
78
+ * takes, and not a property of the client you pass to `setClient()`.
79
+ *
80
+ * @param config - Axios client configuration (base URL, headers, timeout, credentials, auth scheme, or an existing Axios instance).
72
81
  * @returns An `HttpClient` backed by Axios with interceptor and auth token support.
73
82
  */
74
83
  export function createAxiosClient(config = {}) {
75
- const { baseURL = '', defaultHeaders = {}, timeout = 30000, withCredentials = false, instance: existingInstance, axiosConfig = {}, } = config;
84
+ const { baseURL = '', defaultHeaders = {}, timeout = 30000, withCredentials = false, authScheme = 'Bearer', instance: existingInstance, axiosConfig = {}, } = config;
76
85
  // Create or use existing Axios instance
77
86
  const axiosInstance = existingInstance ??
78
87
  axios.create({
@@ -99,7 +108,14 @@ export function createAxiosClient(config = {}) {
99
108
  timeout: axiosConfig.timeout,
100
109
  withCredentials: axiosConfig.withCredentials,
101
110
  data: axiosConfig.data,
111
+ skipAuthGate: axiosConfig.skipAuthGate,
102
112
  };
113
+ // Wait for the session restore first — every method on this client goes through
114
+ // here, so a request fired by a page effect before the restore settled cannot
115
+ // leave unauthenticated (see `@molecule/app-http` `auth-gate.ts`). The config goes with
116
+ // it so a request the gate itself depends on can opt out (`skipAuthGate`) and a stalled
117
+ // gate can name what it held.
118
+ await awaitAuthGate(config);
103
119
  // Run request interceptors
104
120
  for (const interceptor of requestInterceptors) {
105
121
  config = await interceptor(config);
@@ -256,8 +272,8 @@ export function createAxiosClient(config = {}) {
256
272
  setAuthToken(token) {
257
273
  authToken = token;
258
274
  if (token) {
259
- axiosInstance.defaults.headers.common['Authorization'] = `Bearer ${token}`;
260
- currentDefaultHeaders['Authorization'] = `Bearer ${token}`;
275
+ axiosInstance.defaults.headers.common['Authorization'] = `${authScheme} ${token}`;
276
+ currentDefaultHeaders['Authorization'] = `${authScheme} ${token}`;
261
277
  }
262
278
  else {
263
279
  delete axiosInstance.defaults.headers.common['Authorization'];
@@ -1 +1 @@
1
- {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAMN,MAAM,OAAO,CAAA;AAYd,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtC;;;;GAIG;AACH,SAAS,aAAa,CAAC,MAAqB;IAC1C,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,GAAG,MAAM,CAAC,OAAO;KAClB,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAS,cAAc,CAAI,QAA0B,EAAE,MAAyB;IAC9E,MAAM,OAAO,GAA2B,EAAE,CAAA;IAE1C,uCAAuC;IACvC,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5D,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;YACtB,CAAC;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBAChC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC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AAA"}
package/dist/types.d.ts CHANGED
@@ -26,6 +26,16 @@ export interface AxiosHttpClientConfig {
26
26
  * Whether to include credentials by default.
27
27
  */
28
28
  withCredentials?: boolean;
29
+ /**
30
+ * The scheme of the `Authorization` header the auth token is sent with:
31
+ * `Bearer` (default), or what your API expects, e.g. `Token` for an API that
32
+ * reads `Authorization: Token <jwt>`. Pass it to this config, at construction —
33
+ * `setClient(createAxiosClient({ baseURL, authScheme: 'Token' }))` — never as a
34
+ * property of the client it returns. Same option as `@molecule/app-http`'s
35
+ * `HttpClientConfig.authScheme`, so the config reads the same whichever
36
+ * transport is bonded.
37
+ */
38
+ authScheme?: string;
29
39
  /**
30
40
  * Existing Axios instance to wrap (optional).
31
41
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAA;AAG9D,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEvC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,aAAa,CAAA;IAExB;;OAEG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAA;CACjC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAA;AAG9D,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEvC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IAEzB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,aAAa,CAAA;IAExB;;OAEG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAA;CACjC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-http-axios",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Axios HTTP client provider for @molecule/app-http",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "26.1.2",
29
- "axios": "1.19.0",
29
+ "axios": "1.20.0",
30
30
  "typescript": "6.0.3",
31
31
  "vitest": "4.1.11"
32
32
  },