Commit efe381f
authored
refactor(oauth): retire the producerless paste-code authorization presentation (#3399)
* refactor(oauth): retire the paste-code authorization presentation
Every OAuth provider that survives on main enrols through a device flow:
the Host opens the provider's page in a browser and the provider hands the
credential back. `request_authorization_code` — the presentation where the
user copies a code out of the browser and pastes it into Maka — had no
producer left. Nothing selected it, so its decoders, its pending-code state
machine, and the PKCE/loopback authorization builders behind it were reached
only by their own tests.
Removed, from the wire inward:
- `request_authorization_code` leaves `OAuthPresentationMethod`, and the
request/result unions collapse to the single shape the method carries. The
decoder still validates the arriving method, so a peer offering anything
else is refused rather than silently presented.
- The coordinator's `#present` overloads, its authorization-timeout bounds,
and `#exchangeCode` go with it. `#exchangeCodexCode` stays: the Codex
device flow exchanges a code the provider returns, not one the user pastes.
- Desktop drops the pending-code state machine and the paste branch of the
IPC surface. `complete-authorization` stays — device flows drive
`getAuthUrl -> openAuthUrl -> completeAuthorization`.
- `oauth-login.ts` loses `buildOAuthLoginAuthorization`,
`exchangeOAuthAuthorizationCode`, and the redirect/state/PKCE helpers only
they called. The token-endpoint transport stays; device flows use it.
- `@maka/core` loses `parsePastedAuthorization`, `constantTimeStringEqual`,
`PENDING_AUTHORIZATION_TTL_MS`, the PKCE challenge helpers, and the
`invalid_paste_code` / `authorization_expired` failure reasons. The Codex
device flow receives its verifier from the provider rather than deriving
one, so nothing computes a PKCE challenge any more.
The seven transport tests that reached the streaming and bounding behaviour
through `exchangeOAuthAuthorizationCode` now drive
`requestOAuthTokenEndpointJson` directly. That behaviour is still live for
device flows, so the coverage moves rather than disappears.
`RUNTIME_HOST_COMPATIBILITY_EPOCH` 31 -> 32: an older Client still offers the
removed presentation and an older Host still asks for it, and neither side can
carry the authorization code the other expects.
Closes #3219
Claude-Session: https://claude.ai/code/session_014ajaRxC4jydavY9nYUFj5J
* docs(desktop): drop the loopback PKCE mentions from the login-flow hook
The hook's header and its wait comment still described a loopback PKCE
alternative that no provider takes now that the paste-code presentation is
gone. Both paths through it are device-code polling.
Claude-Session: https://claude.ai/code/session_014ajaRxC4jydavY9nYUFj5J
* refactor(oauth): remove what the paste-code teardown orphaned
Self-review of the previous commit found code the removal left behind but
nothing reports: biome does not flag unused private functions, and the
compiler is happy to keep a field no one reads.
- `oauth-provider-contracts.ts` — the xAI contract still declared
`authorizationEndpoint`, `redirectUri`, `authorizationExtras` and
`presentation: 'loopback'`. The live enrolment reads `clientId`,
`deviceEndpoint`, `deviceGrant`, `scope`, `tokenEndpoint` and
`defaultTokenLifetimeSeconds` and nothing else. `presentation: 'loopback'`
was the worst of them: it asserted a flow xAI does not take, in the table a
reader consults to learn what it does take.
- `oauth-coordinator.ts` — `randomOpaqueValue` generated the verifier and
state for the removed authorization request; it and its `randomBytes`
import had no caller left.
- `oauth-login.ts` — `assertOpaqueValue` was called only from the deleted
exchange, and `OAuthLoginProvider` was only a parameter of the deleted
authorization input. No module imports either.
- `runtime-host-oauth-presentation.ts` — `OAuthExternalPresentation.method`
lost its only reader when the Desktop attempt record stopped storing the
presentation method. It was written as a constant and read by no one.
- `protocol/oauth.ts` — `safeInteger` decoded the quota window fields that
left with the account-usage operation in #3183. A drive-by on my own prior
PR, in the file this change already rewrites.
Test-side: the off-contract method in the protocol test is cast through
`unknown` and named, so it reads as a value arriving from an older peer
rather than as a claim that the string is `open_external`; two imports that
were already dead on main in `oauth-coordinator.test.ts` go with it.
Claude-Session: https://claude.ai/code/session_014ajaRxC4jydavY9nYUFj5J1 parent e955575 commit efe381f
18 files changed
Lines changed: 96 additions & 663 deletions
File tree
- apps/desktop/src
- main
- __tests__
- renderer
- locales
- settings
- packages
- core/src
- __tests__
- runtime-host/src
- __tests__
- client
- protocol
- server
- runtime/src
- __tests__
Lines changed: 5 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 24 | + | |
28 | 25 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 26 | + | |
45 | 27 | | |
46 | 28 | | |
47 | 29 | | |
| |||
86 | 68 | | |
87 | 69 | | |
88 | 70 | | |
89 | | - | |
90 | | - | |
91 | | - | |
| 71 | + | |
| 72 | + | |
92 | 73 | | |
93 | 74 | | |
94 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | 61 | | |
63 | 62 | | |
64 | 63 | | |
| |||
88 | 87 | | |
89 | 88 | | |
90 | 89 | | |
91 | | - | |
92 | 90 | | |
93 | 91 | | |
94 | 92 | | |
| |||
110 | 108 | | |
111 | 109 | | |
112 | 110 | | |
113 | | - | |
| 111 | + | |
114 | 112 | | |
115 | 113 | | |
116 | 114 | | |
117 | | - | |
118 | | - | |
| 115 | + | |
119 | 116 | | |
120 | 117 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | 118 | | |
130 | 119 | | |
131 | 120 | | |
| |||
295 | 284 | | |
296 | 285 | | |
297 | 286 | | |
298 | | - | |
299 | 287 | | |
300 | 288 | | |
301 | 289 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
| |||
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
26 | | - | |
27 | | - | |
28 | 25 | | |
29 | 26 | | |
30 | 27 | | |
| |||
43 | 40 | | |
44 | 41 | | |
45 | 42 | | |
46 | | - | |
47 | | - | |
48 | | - | |
| 43 | + | |
49 | 44 | | |
50 | 45 | | |
51 | 46 | | |
52 | 47 | | |
53 | 48 | | |
54 | 49 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | 50 | | |
71 | 51 | | |
72 | 52 | | |
| |||
91 | 71 | | |
92 | 72 | | |
93 | 73 | | |
94 | | - | |
| 74 | + | |
95 | 75 | | |
96 | 76 | | |
97 | 77 | | |
98 | 78 | | |
99 | 79 | | |
100 | 80 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | 81 | | |
123 | 82 | | |
124 | 83 | | |
| |||
128 | 87 | | |
129 | 88 | | |
130 | 89 | | |
131 | | - | |
132 | | - | |
133 | 90 | | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
| 173 | + | |
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
307 | | - | |
| 307 | + | |
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
| 41 | + | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
Lines changed: 4 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
| 9 | + | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
17 | | - | |
18 | | - | |
19 | | - | |
| 16 | + | |
| 17 | + | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
| |||
206 | 204 | | |
207 | 205 | | |
208 | 206 | | |
209 | | - | |
| 207 | + | |
210 | 208 | | |
211 | 209 | | |
212 | 210 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 4 | + | |
19 | 5 | | |
20 | 6 | | |
21 | 7 | | |
22 | 8 | | |
23 | 9 | | |
24 | 10 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | 11 | | |
0 commit comments