fix: read the SDK's own discovery state instead of a marker of our own
Copilot review (#2287), two findings — and taken together they said the marker was the wrong mechanism, so this removes it rather than patching it again: - A transient failure in our CIMD preflight recorded no marker, so a *successful* SDK fallback discovery that advertised CIMD was still stored as `dcr`. - `existing` and `existingKind` could describe different registrations, because `clientInformation()` answers preregistered-first while `clientRegistrationKind()` prefers the issuer's dynamic slot. SDK v2 `auth()` persists the authorization-server metadata via `saveDiscoveryState` *before* it reads or writes client information, and it takes its URL-based-client-ID branch — rather than `registerClient` — exactly when that metadata advertises `client_id_metadata_document_supported` and a `clientMetadataUrl` is configured. So the branch is not inferred at all now: it is read back from the state the SDK itself just wrote. `resolveSdkRegistrationKind` becomes two cases. A save for an issuer that already has a registration under this `client_id` is a back-stamp, answered by that registration's recorded kind — so an existing DCR on the metadata URL stays `dcr`. A save for an issuer with none is a new registration, answered by the discovery state, guarded on the metadata describing that same issuer. This drops `cimdClientMetadataUrl` and its storage accessors entirely, and restores `ensureCimdClientRegistration` to a plain issuer-bound pre-registration. Invalid-client recovery, second-issuer CIMD, second-issuer DCR minting the metadata URL, and preflight failure are all consequences of the two cases rather than separate mechanisms. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lmj6X2epWpPE7ScdSKQmtA Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
abb6a47f7d
commit
6273790077
1 changed files with 183 additions and 306 deletions
|
|
@ -30,21 +30,6 @@ export interface IssuerBoundOAuthState {
|
|||
/** Set when {@link clientInformation} is saved — DCR vs CIMD. */
|
||||
clientRegistrationKind?: OAuthClientRegistrationKind;
|
||||
tokens?: OAuthTokens;
|
||||
/**
|
||||
* The CIMD client-metadata URL this AS was confirmed to accept as a `client_id`
|
||||
* — written by `ensureCimdClientRegistration` after reading
|
||||
* `client_id_metadata_document_supported` from *this* issuer's metadata, and
|
||||
* refreshed (or cleared) on every connect because that check now runs each time.
|
||||
*
|
||||
* Deliberately **not** a credential, and so deliberately **not** cleared by
|
||||
* {@link OAuthStorage.clearClientInformation}. It records a property of the
|
||||
* authorization server and our own configuration, which an `invalid_client`
|
||||
* response says nothing about: SDK v2 `auth()` answers that error by calling
|
||||
* `invalidateCredentials("client")` and retrying, and the retry's URL-based
|
||||
* client-ID save would otherwise land with no provenance and be recorded as
|
||||
* DCR (#2242, Copilot).
|
||||
*/
|
||||
cimdClientMetadataUrl?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue