@@ -41,17 +41,20 @@ const standardOidcIdentityScopes = ["openid", "email", "profile"] as const;
4141
4242const identityScopesForPreset = (
4343 identityScopes : OAuth2Preset [ "identityScopes" ] ,
44+ advertisedScopes : ReadonlySet < string > ,
4445) : readonly string [ ] => {
4546 if ( identityScopes === false ) return [ ] ;
46- return identityScopes === "auto" ? standardOidcIdentityScopes : identityScopes ;
47+ return identityScopes === "auto"
48+ ? standardOidcIdentityScopes . filter ( ( scope ) => advertisedScopes . has ( scope ) )
49+ : identityScopes ;
4750} ;
4851
4952export const resolvedOAuthScopes = (
5053 apiScopes : Iterable < string > ,
5154 identityScopes : OAuth2Preset [ "identityScopes" ] ,
5255) : string [ ] => {
5356 const merged = new Set ( apiScopes ) ;
54- for ( const scope of identityScopesForPreset ( identityScopes ) ) merged . add ( scope ) ;
57+ for ( const scope of identityScopesForPreset ( identityScopes , merged ) ) merged . add ( scope ) ;
5558 return [ ...merged ] ;
5659} ;
5760
@@ -141,9 +144,10 @@ const oauthTemplateFromPreset = (
141144// ---------------------------------------------------------------------------
142145// All spec-detected auth methods → the union of stored `Authentication`
143146// templates. Header presets become apiKey templates; each oauth2 preset becomes
144- // an oauth template (with its declared API scopes plus, for auth-code flows,
145- // the standard identity scopes). Slugs stay deterministic per method so the
146- // stored template is stable across previews of the same spec.
147+ // an oauth template with its declared scopes. Auto identity detection only
148+ // preserves standard OIDC scopes the provider advertised; it never invents
149+ // scopes unsupported by a plain OAuth provider. Slugs stay deterministic per
150+ // method so the stored template is stable across previews of the same spec.
147151// ---------------------------------------------------------------------------
148152
149153export const detectedAuthenticationTemplates = (
0 commit comments