Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { ServerConnection } from './plus/gk/serverConnection';
import { SubscriptionService } from './plus/gk/subscriptionService';
import { GraphStatusBarController } from './plus/graph/statusbar';
import type { CloudIntegrationService } from './plus/integrations/authentication/cloudIntegrationService';
import { ConfiguredIntegrationService } from './plus/integrations/authentication/configuredIntegrationService';
import { IntegrationAuthenticationService } from './plus/integrations/authentication/integrationAuthenticationService';
import { IntegrationService } from './plus/integrations/integrationService';
import type { GitHubApi } from './plus/integrations/providers/github/github';
Expand Down Expand Up @@ -532,8 +533,12 @@ export class Container {
private _integrations: IntegrationService | undefined;
get integrations(): IntegrationService {
if (this._integrations == null) {
const authService = new IntegrationAuthenticationService(this);
this._disposables.push(authService, (this._integrations = new IntegrationService(this, authService)));
const configuredIntegrationService = new ConfiguredIntegrationService(this);
const authService = new IntegrationAuthenticationService(this, configuredIntegrationService);
this._disposables.push(
authService,
(this._integrations = new IntegrationService(this, authService, configuredIntegrationService)),
);
}
return this._integrations;
}
Expand Down
4 changes: 2 additions & 2 deletions src/env/node/git/sub-providers/remotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class RemotesGitSubProvider extends RemotesGitProviderBase implements Git
async function load(this: RemotesGitSubProvider): Promise<GitRemote[]> {
const providers = loadRemoteProviders(
configuration.get('remotes', this.container.git.getRepository(repoPath!)?.folder?.uri ?? null),
this.container.integrations.getConfiguredIntegrationDescriptors(),
await this.container.integrations.getConfigured(),
);

try {
Expand All @@ -49,7 +49,7 @@ export class RemotesGitSubProvider extends RemotesGitProviderBase implements Git
this.container,
data,
repoPath!,
getRemoteProviderMatcher(this.container, providers),
await getRemoteProviderMatcher(this.container, providers),
);
return remotes;
} catch (ex) {
Expand Down
2 changes: 1 addition & 1 deletion src/git/parsers/remoteParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function parseGitRemotes(
container: Container,
data: string,
repoPath: string,
remoteProviderMatcher: ReturnType<typeof getRemoteProviderMatcher>,
remoteProviderMatcher: Awaited<ReturnType<typeof getRemoteProviderMatcher>>,
): GitRemote[] {
using sw = maybeStopWatch(`Git.parseRemotes(${repoPath})`, { log: false, logLevel: 'debug' });
if (!data) return [];
Expand Down
6 changes: 3 additions & 3 deletions src/git/remotes/remoteProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,14 @@ function getCustomProviderCreator(cfg: RemotesConfig) {
}
}

export function getRemoteProviderMatcher(
export async function getRemoteProviderMatcher(
container: Container,
providers?: RemoteProviders,
): (url: string, domain: string, path: string) => RemoteProvider | undefined {
): Promise<(url: string, domain: string, path: string) => RemoteProvider | undefined> {
if (providers == null) {
providers = loadRemoteProviders(
configuration.get('remotes', null),
container.integrations.getConfiguredIntegrationDescriptors(),
await container.integrations.getConfigured(),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/plus/drafts/draftsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ export class DraftService implements Disposable {
} else if (data.provider?.repoName != null) {
name = data.provider.repoName;
} else if (data.remote?.url != null && data.remote?.domain != null && data.remote?.path != null) {
const matcher = getRemoteProviderMatcher(this.container);
const matcher = await getRemoteProviderMatcher(this.container);
const provider = matcher(data.remote.url, data.remote.domain, data.remote.path);
name = provider?.repoName ?? data.remote.path;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const getBuiltInIntegrationSession = sequentialize(
return {
...session,
cloud: false,
domain: descriptor.domain,
};
},
),
Expand Down
29 changes: 10 additions & 19 deletions src/plus/integrations/authentication/azureDevOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export class AzureDevOpsAuthenticationProvider extends LocalIntegrationAuthentic
}

override async createSession(
descriptor?: IntegrationAuthenticationSessionDescriptor,
descriptor: IntegrationAuthenticationSessionDescriptor,
): Promise<ProviderAuthenticationSession | undefined> {
let azureOrganization: string | undefined = descriptor?.organization as string | undefined;
let azureOrganization: string | undefined = descriptor.organization as string | undefined;
if (!azureOrganization) {
const orgInput = window.createInputBox();
orgInput.ignoreFocusOut = true;
Expand All @@ -35,9 +35,7 @@ export class AzureDevOpsAuthenticationProvider extends LocalIntegrationAuthentic
}),
);

orgInput.title = `Azure DevOps Authentication${
descriptor?.domain ? ` \u2022 ${descriptor.domain}` : ''
}`;
orgInput.title = `Azure DevOps Authentication \u2022 ${descriptor.domain}`;
orgInput.placeholder = 'Organization';
orgInput.prompt = 'Enter your Azure DevOps organization';
orgInput.show();
Expand Down Expand Up @@ -78,24 +76,16 @@ export class AzureDevOpsAuthenticationProvider extends LocalIntegrationAuthentic
tokenInput.onDidTriggerButton(e => {
if (e === infoButton) {
void env.openExternal(
Uri.parse(
`https://${
descriptor?.domain ?? 'dev.azure.com'
}/${azureOrganization}/_usersSettings/tokens`,
),
Uri.parse(`https://${descriptor.domain}/${azureOrganization}/_usersSettings/tokens`),
);
}
}),
);

tokenInput.password = true;
tokenInput.title = `Azure DevOps Authentication${
descriptor?.domain ? ` \u2022 ${descriptor.domain}` : ''
}`;
tokenInput.placeholder = `Requires ${descriptor?.scopes.join(', ') ?? 'all'} scopes`;
tokenInput.prompt = `Paste your [Azure DevOps Personal Access Token](https://${
descriptor?.domain ?? 'dev.azure.com'
}/${azureOrganization}/_usersSettings/tokens "Get your Azure DevOps Access Token")`;
tokenInput.title = `Azure DevOps Authentication \u2022 ${descriptor.domain}`;
tokenInput.placeholder = `Requires ${descriptor.scopes.join(', ') ?? 'all'} scopes`;
tokenInput.prompt = `Paste your [Azure DevOps Personal Access Token](https://${descriptor.domain}/${azureOrganization}/_usersSettings/tokens "Get your Azure DevOps Access Token")`;
tokenInput.buttons = [infoButton];

tokenInput.show();
Expand All @@ -108,14 +98,15 @@ export class AzureDevOpsAuthenticationProvider extends LocalIntegrationAuthentic
if (!token) return undefined;

return {
id: this.getSessionId(descriptor),
id: this.configuredIntegrationService.getSessionId(descriptor),
accessToken: base64(`:${token}`),
scopes: descriptor?.scopes ?? [],
scopes: descriptor.scopes,
account: {
id: '',
label: '',
},
cloud: false,
domain: descriptor.domain,
};
}
}
35 changes: 12 additions & 23 deletions src/plus/integrations/authentication/bitbucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export class BitbucketAuthenticationProvider extends LocalIntegrationAuthenticat
}

override async createSession(
descriptor?: IntegrationAuthenticationSessionDescriptor,
descriptor: IntegrationAuthenticationSessionDescriptor,
): Promise<ProviderAuthenticationSession | undefined> {
let bitbucketUsername: string | undefined = descriptor?.username as string | undefined;
let bitbucketUsername: string | undefined = descriptor.username as string | undefined;
if (!bitbucketUsername) {
const infoButton: QuickInputButton = {
iconPath: new ThemeIcon(`link-external`),
Expand All @@ -40,20 +40,14 @@ export class BitbucketAuthenticationProvider extends LocalIntegrationAuthenticat
}),
usernameInput.onDidTriggerButton(e => {
if (e === infoButton) {
void env.openExternal(
Uri.parse(`https://${descriptor?.domain ?? 'bitbucket.org'}/account/settings/`),
);
void env.openExternal(Uri.parse(`https://${descriptor.domain}/account/settings/`));
}
}),
);

usernameInput.title = `Bitbucket Authentication${
descriptor?.domain ? ` \u2022 ${descriptor.domain}` : ''
}`;
usernameInput.title = `Bitbucket Authentication \u2022 ${descriptor.domain}`;
usernameInput.placeholder = 'Username';
usernameInput.prompt = `Enter your [Bitbucket Username](https://${
descriptor?.domain ?? 'bitbucket.org'
}/account/settings/ "Get your Bitbucket App Password")`;
usernameInput.prompt = `Enter your [Bitbucket Username](https://${descriptor.domain}/account/settings/ "Get your Bitbucket App Password")`;
usernameInput.show();
});
} finally {
Expand Down Expand Up @@ -92,22 +86,16 @@ export class BitbucketAuthenticationProvider extends LocalIntegrationAuthenticat
appPasswordInput.onDidTriggerButton(e => {
if (e === infoButton) {
void env.openExternal(
Uri.parse(
`https://${descriptor?.domain ?? 'bitbucket.org'}/account/settings/app-passwords/`,
),
Uri.parse(`https://${descriptor.domain}/account/settings/app-passwords/`),
);
}
}),
);

appPasswordInput.password = true;
appPasswordInput.title = `Bitbucket Authentication${
descriptor?.domain ? ` \u2022 ${descriptor.domain}` : ''
}`;
appPasswordInput.placeholder = `Requires ${descriptor?.scopes.join(', ') ?? 'all'} scopes`;
appPasswordInput.prompt = `Paste your [Bitbucket App Password](https://${
descriptor?.domain ?? 'bitbucket.org'
}/account/settings/app-passwords/ "Get your Bitbucket App Password")`;
appPasswordInput.title = `Bitbucket Authentication \u2022 ${descriptor.domain}`;
appPasswordInput.placeholder = `Requires ${descriptor.scopes.join(', ')} scopes`;
appPasswordInput.prompt = `Paste your [Bitbucket App Password](https://${descriptor.domain}/account/settings/app-passwords/ "Get your Bitbucket App Password")`;
appPasswordInput.buttons = [infoButton];

appPasswordInput.show();
Expand All @@ -120,14 +108,15 @@ export class BitbucketAuthenticationProvider extends LocalIntegrationAuthenticat
if (!appPassword) return undefined;

return {
id: this.getSessionId(descriptor),
id: this.configuredIntegrationService.getSessionId(descriptor),
accessToken: base64(`${bitbucketUsername}:${appPassword}`),
scopes: descriptor?.scopes ?? [],
scopes: descriptor.scopes,
account: {
id: '',
label: '',
},
cloud: false,
domain: descriptor.domain,
};
}
}
Loading
Loading