22
23
async authenticate(params: AuthenticateParams, providers: Iterable<IAgent>): Promise<AuthenticateResult> {
25
>
const providerList = [...providers];
26
>
// Multiple providers may share the same protected resource (e.g.
27
>
// both Copilot CLI and Claude consume the GitHub Copilot token).
28
>
// Fan out to every matching provider in parallel; the request is
29
>
// considered authenticated if at least one accepts. Provider
30
>
// failures are isolated -- one provider rejecting (e.g. proxy
31
>
// server bind failure) MUST NOT prevent another provider from
32
>
// accepting the same token.
33
>
const matching = providerList.filter(
34
>
p => p.getProtectedResources().some(r => r.resource === params.resource),
35
>
);
36
>
const settled = await Promise.allSettled(
37
>
matching.map(p => p.authenticate(params.resource, params.token)),
38
>
);
39
>
let authenticated = false;
40
>
for (let i = 0; i < settled.length; i++) {
41
const result = settled[i];
42
if (result.status === 'fulfilled') {