feat(core): add OAuth authorization-code + PKCE auth mode - #1162
Conversation
|
Claude finished @joshuaellis's task in 2m 33s —— View job Answer: CodeQL
|
📦 Bundle Stats —
|
| Metric | Value | vs main (4b976d5) | vs v3.1.0 |
|---|---|---|---|
| Internal (raw) | 306.5 KB | +14.8 KB, +5.1% | +14.8 KB, +5.1% |
| Internal (gzip) | 75.2 KB | +3.4 KB, +4.7% | +3.4 KB, +4.7% |
| Bundled (raw) | 1.15 MB | +14.8 KB, +1.3% | +8.8 KB, +0.8% |
| Bundled (gzip) | 266.3 KB | +3.4 KB, +1.3% | +2.2 KB, +0.9% |
| Import time | 252ms | +2ms, +1.0% | +13ms, +5.6% |
@sanity/sdk/_internal
| Metric | Value | vs main (4b976d5) | vs v3.1.0 |
|---|---|---|---|
| Internal (raw) | 132.6 KB | +4.0 KB, +3.1% | +4.0 KB, +3.1% |
| Internal (gzip) | 34.5 KB | +813 B, +2.4% | +813 B, +2.4% |
| Bundled (raw) | 674.1 KB | +4.0 KB, +0.6% | -2.1 KB, -0.3% |
| Bundled (gzip) | 152.0 KB | +814 B, +0.5% | -363 B, -0.2% |
| Import time | 203ms | -2ms, -1.0% | +11ms, +5.6% |
@sanity/sdk/agent
| Metric | Value | vs main (4b976d5) | vs v3.1.0 |
|---|---|---|---|
| Internal (raw) | 62.5 KB | +4.0 KB, +6.9% | +4.0 KB, +6.9% |
| Internal (gzip) | 16.1 KB | +835 B, +5.3% | +835 B, +5.3% |
| Bundled (raw) | 416.6 KB | +4.0 KB, +1.0% | +1.2 KB, +0.3% |
| Bundled (gzip) | 93.1 KB | +822 B, +0.9% | +497 B, +0.5% |
| Import time | 166ms | +0ms, +0.2% | +8ms, +5.2% |
@sanity/sdk/comlink
| Metric | Value | vs main (4b976d5) | vs v3.1.0 |
|---|---|---|---|
| Internal (raw) | 21.4 KB | - | - |
| Internal (gzip) | 6.2 KB | - | - |
| Bundled (raw) | 248.1 KB | - | -3.3 KB, -1.3% |
| Bundled (gzip) | 59.6 KB | - | -769 B, -1.2% |
| Import time | 179ms | +1ms, +0.4% | +8ms, +4.5% |
🗺️ . · ./_internal · ./agent · ./comlink · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
📦 Bundle Stats — @sanity/sdk-react
Compared against main (4b976d56) · v3.1.0 (npm)
@sanity/sdk-react
| Metric | Value | vs main (4b976d5) | vs v3.1.0 |
|---|---|---|---|
| Internal (raw) | 173.5 KB | - | - |
| Internal (gzip) | 45.6 KB | - | - |
| Bundled (raw) | 1.43 MB | +14.9 KB, +1.0% | +8.8 KB, +0.6% |
| Bundled (gzip) | 340.8 KB | +3.4 KB, +1.0% | +2.2 KB, +0.7% |
| Import time | 295ms | +2ms, +0.7% | +15ms, +5.5% |
@sanity/sdk-react/dashboard
| Metric | Value | vs main (4b976d5) | vs v3.1.0 |
|---|---|---|---|
| Internal (raw) | 23.5 KB | - | - |
| Internal (gzip) | 7.2 KB | - | - |
| Bundled (raw) | 1.14 MB | +4.3 KB, +0.4% | -1.8 KB, -0.2% |
| Bundled (gzip) | 265.2 KB | +913 B, +0.3% | -265 B, -0.1% |
| Import time | 260ms | -1ms, -0.4% | +14ms, +5.7% |
🗺️ . · ./dashboard · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
📚 TypeDoc Generation Result✅ TypeDoc generated successfully!
The package TypeDoc JSON files and combined HTML site have been generated successfully. |
4f9397e to
778417e
Compare
|
i think the refresh logic will go away and the client will handle it but to be safe and because code is cheap, its added here. Although if I do delete it, it'll be a BC to the SDK right? so maybe I should just mark it as |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
778417e to
0a7dbc5
Compare
Bundle StatsWarning 2 significant changes. @sanity/sdk🔴 @sanity/sdk-react🔴 All scenario measurements (8)🗺️
Significant means at least 1.0 KB and 1% gzip, or at least 5 ms and 10% import time. |
0a7dbc5 to
c35a60e
Compare
c35a60e to
d1638d4
Compare
| ) | ||
|
|
||
| // Single-flight refresh shared across concurrent callers. Safe as a module | ||
| // singleton because `authStore` is a global store (one shared state). |
There was a problem hiding this comment.
Heads up, this is really one shared state per tab, so it could be possible (although unlikely) for two tabs with the same app loaded to race for a token refresh.
There was a problem hiding this comment.
🤔 good point. I wonder how other oauth clients handle this.
7b19a1b to
74a6db6
Compare
Description
Adds
oauthas a fourth auth mode inpackages/core, alongside studio, dashboard, and standalone. Configured viaauth.oauth(clientId,redirectUri,organizationId), it uses the OAuth 2.0 authorization-code + PKCE flow and scopes tokens to an organisation via RFC 8707 resource indicators.Core handles PKCE generation, the authorize redirect, code exchange, token refresh, revocation, and cross-tab token persistence, exposed as bound actions (
startOAuthAuthorization,handleOAuthCallback,refreshOAuthTokens,revokeOAuthTokens) and agetOAuthTokensStateaccessor.handleOAuthCallbackis single-flight so a repeated or StrictMode-double-invoked call does not attempt a second exchange of a single-use code.Fun Gif