Commit 22494d9
feat(auth): support Bearer token alongside X-API-Key
Add an optional `authMethod` field to `SharpAPIConfig` accepting
`'x-api-key'` (default) or `'bearer'`. When `'bearer'` is selected the
HTTP client sends `Authorization: Bearer <apiKey>` on REST requests
instead of the historical `X-API-Key: <apiKey>` header.
Use cases:
- Customers fronting the API behind IAM / SSO layers that expect a
standard `Authorization` header.
- Corporate proxies and API gateways that strip non-standard
`X-*` headers but pass `Authorization` through untouched.
Back-compat: the `apiKey` constructor argument is unchanged and the
default auth method remains `'x-api-key'`, so existing callers see no
behavioural change.
SSE and WebSocket transports are intentionally unaffected — they
already pass the key as the `?api_key=` query parameter because
browsers cannot set custom headers on `EventSource` or `WebSocket`
connections.
Bumps version 0.2.4 → 0.2.5 (additive public API surface).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 63cb959 commit 22494d9
3 files changed
Lines changed: 63 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
30 | 48 | | |
31 | 49 | | |
32 | 50 | | |
33 | 51 | | |
34 | 52 | | |
35 | 53 | | |
36 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
37 | 64 | | |
38 | 65 | | |
39 | 66 | | |
40 | 67 | | |
41 | 68 | | |
| 69 | + | |
42 | 70 | | |
43 | 71 | | |
44 | 72 | | |
| |||
536 | 564 | | |
537 | 565 | | |
538 | 566 | | |
| 567 | + | |
539 | 568 | | |
540 | 569 | | |
541 | 570 | | |
542 | 571 | | |
543 | 572 | | |
| 573 | + | |
544 | 574 | | |
545 | 575 | | |
546 | 576 | | |
| |||
573 | 603 | | |
574 | 604 | | |
575 | 605 | | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
576 | 610 | | |
577 | 611 | | |
578 | 612 | | |
579 | | - | |
| 613 | + | |
580 | 614 | | |
581 | 615 | | |
582 | 616 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
309 | 336 | | |
310 | 337 | | |
311 | 338 | | |
| |||
0 commit comments