|
1 | 1 | import type { Disposable, QuickInputButton } from 'vscode'; |
2 | 2 | import { authentication, env, ThemeIcon, Uri, window } from 'vscode'; |
3 | | -import { wrapForForcedInsecureSSL } from '@env/fetch'; |
4 | 3 | import { HostingIntegrationId, SelfHostedIntegrationId } from '../../../constants.integrations'; |
5 | 4 | import type { Sources } from '../../../constants.telemetry'; |
6 | 5 | import type { Container } from '../../../container'; |
| 6 | +import { getBuiltInIntegrationSession } from '../../gk/utils/-webview/integrationAuthentication.utils'; |
7 | 7 | import type { ConfiguredIntegrationService } from './configuredIntegrationService'; |
8 | 8 | import type { IntegrationAuthenticationSessionDescriptor } from './integrationAuthenticationProvider'; |
9 | 9 | import { |
@@ -33,38 +33,20 @@ export class GitHubAuthenticationProvider extends CloudIntegrationAuthentication |
33 | 33 | return HostingIntegrationId.GitHub; |
34 | 34 | } |
35 | 35 |
|
36 | | - private async getBuiltInExistingSession( |
37 | | - descriptor: IntegrationAuthenticationSessionDescriptor, |
38 | | - forceNewSession?: boolean, |
39 | | - ): Promise<ProviderAuthenticationSession | undefined> { |
40 | | - return wrapForForcedInsecureSSL( |
41 | | - this.container.integrations.ignoreSSLErrors({ id: this.authProviderId, domain: descriptor?.domain }), |
42 | | - async () => { |
43 | | - const session = await authentication.getSession(this.authProviderId, descriptor.scopes, { |
44 | | - forceNewSession: forceNewSession ? true : undefined, |
45 | | - silent: forceNewSession ? undefined : true, |
46 | | - }); |
47 | | - if (session == null) return undefined; |
48 | | - return { |
49 | | - ...session, |
50 | | - cloud: false, |
51 | | - domain: descriptor.domain, |
52 | | - }; |
53 | | - }, |
54 | | - ); |
55 | | - } |
56 | | - |
57 | 36 | public override async getSession( |
58 | 37 | descriptor: IntegrationAuthenticationSessionDescriptor, |
59 | 38 | options?: { createIfNeeded?: boolean; forceNewSession?: boolean; source?: Sources }, |
60 | 39 | ): Promise<ProviderAuthenticationSession | undefined> { |
61 | | - let vscodeSession = await this.getBuiltInExistingSession(descriptor); |
62 | | - |
63 | | - if (vscodeSession != null && options?.forceNewSession) { |
64 | | - vscodeSession = await this.getBuiltInExistingSession(descriptor, true); |
| 40 | + let session = await getBuiltInIntegrationSession(this.container, this.authProviderId, descriptor, { |
| 41 | + silent: true, |
| 42 | + }); |
| 43 | + if (session != null && options?.forceNewSession) { |
| 44 | + session = await getBuiltInIntegrationSession(this.container, this.authProviderId, descriptor, { |
| 45 | + forceNewSession: true, |
| 46 | + }); |
65 | 47 | } |
66 | 48 |
|
67 | | - if (vscodeSession != null) return vscodeSession; |
| 49 | + if (session != null) return session; |
68 | 50 |
|
69 | 51 | return super.getSession(descriptor, options); |
70 | 52 | } |
|
0 commit comments