Commit be3e6e0
committed
feat: the transport takes a signal, a fetch of your own, and stops taking a refused credential for a result
Three requests older than 6.0, all of them the same shape: the client had no seam. `fetch` was reached as a global, a
request could not be cancelled, and a response's headers were read for one thing and thrown away. None of it was
visible from outside.
Every call takes an `AbortSignal` as an optional last argument — an operation with no parameters takes it in their
place — and the signal reaches `fetch` as well as cutting short a retry back-off that until now had no bound on total
wall time. The abort reason is rethrown untouched rather than wrapped, so `error.name === 'AbortError'` and
`error === signal.reason` both hold, and a `TimeoutError` from `AbortSignal.timeout()` stays one. Fixes #406.
The `fetch` the client calls is yours to replace. It receives the URL and the `RequestInit` the client built, headers
included, and returns a `Response` — logging, tracing, a corporate proxy, fixture recording. The OAuth 2.0 token and
cloud-id calls go through it too, so a proxy covers the whole flow rather than working until the first refresh. Its
type is `(url: string, init: RequestInit) => Promise<Response>` rather than `typeof globalThis.fetch`, so undici's
fetch fits without a cast. Fixes #404.
An expired API token is an error rather than an empty result, and this changes behaviour. Around a quarter of Jira's
operations can be reached anonymously, and there a dead token does not fail the request: Jira answers as the anonymous
user and reports the refusal only in `X-Seraph-LoginReason`. Measured against a live site, `GET
/rest/api/3/project/search` with a dead token answers 200 and `{"total":0,"isLast":true,"values":[]}`. The client reads
that header now and throws `AuthError` whatever the status, recording the status that actually arrived. Fixes #418.
Two smaller ones ride along. A header set to `undefined` is left out rather than sent, and falls through to the
client-wide value instead of erasing it. And two authentication strategies for a self-hosted instance arrive with the
core rather than with the surface they serve — `src/core` is generated whole and `createClient` branches on the
strategy, so separating them would mean hand-writing a core the generator does not produce.1 parent d9bad39 commit be3e6e0
163 files changed
Lines changed: 5856 additions & 1758 deletions
File tree
- src
- agile
- api
- cloud
- api
- models
- parameters
- core
- errors
- interfaces
- oauthServer
- oauth
- schemas
- serviceDesk
- api
- models
- parameters
- tests
- live/cloud
- unit/core
- oauthServer
- oauth
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
5 | 48 | | |
6 | 49 | | |
7 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
15 | 19 | | |
| 20 | + | |
16 | 21 | | |
17 | 22 | | |
18 | 23 | | |
| |||
26 | 31 | | |
27 | 32 | | |
28 | 33 | | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
| |||
36 | 42 | | |
37 | 43 | | |
38 | 44 | | |
| 45 | + | |
39 | 46 | | |
40 | 47 | | |
41 | 48 | | |
| |||
0 commit comments