diff --git a/src/atlclients/authStore.ts b/src/atlclients/authStore.ts index aadaef2a5..7de029c18 100644 --- a/src/atlclients/authStore.ts +++ b/src/atlclients/authStore.ts @@ -33,6 +33,10 @@ import { import { Negotiator } from './negotiate'; import { OAuthRefesher } from './oauthRefresher'; +function isAtlassianCloud(site: DetailedSiteInfo): boolean { + return site.host.endsWith('.atlassian.net') || site.host.endsWith('.jira.com'); +} + const keychainServiceNameV3 = version.endsWith('-insider') ? 'atlascode-insiders-authinfoV3' : 'atlascode-authinfoV3'; enum Priority { @@ -87,7 +91,7 @@ export class CredentialManager implements Disposable { public async checkScopes(site: DetailedSiteInfo, scopes: string[]): Promise { // Scopes are only applicable to cloud sites - if (!site.host.endsWith('.atlassian.net')) { + if (!isAtlassianCloud(site)) { return undefined; } @@ -120,7 +124,7 @@ export class CredentialManager implements Disposable { async getApiTokenIfExists(site: DetailedSiteInfo): Promise { // Only applicable to cloud sites - if (!site.host.endsWith('.atlassian.net')) { + if (!isAtlassianCloud(site)) { return undefined; } @@ -144,7 +148,7 @@ export class CredentialManager implements Disposable { async findApiTokenForSite(site?: DetailedSiteInfo | string): Promise { const siteToCheck = typeof site === 'string' ? Container.siteManager.getSiteForId(ProductJira, site) : site; - if (!siteToCheck || !siteToCheck.host.endsWith('.atlassian.net')) { + if (!siteToCheck || !isAtlassianCloud(siteToCheck)) { return undefined; } @@ -152,16 +156,14 @@ export class CredentialManager implements Disposable { const selectedSiteEmail = (await this.getAuthInfo(siteToCheck))?.user.email; // For a cloud site - check if we have another cloud site with the same user and API key - const promises = sites - .filter((site) => site.host.endsWith('.atlassian.net')) - .map(async (site) => { - const authInfo = await this.getAuthInfo(site); - if (authInfo?.user.email === selectedSiteEmail && isBasicAuthInfo(authInfo)) { - // There's another site with the same user and cloud, so we can use that API key for suggestions - return authInfo as BasicAuthInfo; - } - return undefined; - }); + const promises = sites.filter(isAtlassianCloud).map(async (site) => { + const authInfo = await this.getAuthInfo(site); + if (authInfo?.user.email === selectedSiteEmail && isBasicAuthInfo(authInfo)) { + // There's another site with the same user and cloud, so we can use that API key for suggestions + return authInfo as BasicAuthInfo; + } + return undefined; + }); const results = await Promise.all(promises); return results.find((authInfo) => authInfo !== undefined); diff --git a/src/rovo-dev/rovoDevChatContextProvider.ts b/src/rovo-dev/rovoDevChatContextProvider.ts index 6b0e3187f..37b52ca94 100644 --- a/src/rovo-dev/rovoDevChatContextProvider.ts +++ b/src/rovo-dev/rovoDevChatContextProvider.ts @@ -43,7 +43,7 @@ export class RovoDevChatContextProvider { // search for a Jira work item if (dragDropData.find((x) => x.includes('atlascode.views.jira.assignedWorkItemsTreeView'))) { const uri = URL.parse(dragDropData[0] || dragDropData[1]); - if (uri?.hostname.endsWith('.atlassian.net')) { + if (uri?.hostname.endsWith('.atlassian.net') || uri?.hostname.endsWith('.jira.com')) { const urlString = uri.toString(); await this.addContextItem({ contextType: 'jiraWorkItem',