@gitkraken/core-gitlens 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -1
- package/README.md +13 -10
- package/dist/git/context.d.ts +4 -3
- package/dist/git/context.d.ts.map +1 -1
- package/dist/git/context.js.map +1 -1
- package/dist/git/providers/operations.d.ts +1 -0
- package/dist/git/providers/operations.d.ts.map +1 -1
- package/dist/git/providers/worktrees.d.ts +2 -0
- package/dist/git/providers/worktrees.d.ts.map +1 -1
- package/dist/git/utils/conflictResolution.utils.d.ts +32 -0
- package/dist/git/utils/conflictResolution.utils.d.ts.map +1 -1
- package/dist/git/utils/conflictResolution.utils.js +95 -0
- package/dist/git/utils/conflictResolution.utils.js.map +1 -1
- package/dist/git-cli/providers/operations.d.ts +1 -0
- package/dist/git-cli/providers/operations.d.ts.map +1 -1
- package/dist/git-cli/providers/operations.js +22 -1
- package/dist/git-cli/providers/operations.js.map +1 -1
- package/dist/git-cli/providers/worktrees.d.ts +2 -0
- package/dist/git-cli/providers/worktrees.d.ts.map +1 -1
- package/dist/git-cli/providers/worktrees.js +3 -0
- package/dist/git-cli/providers/worktrees.js.map +1 -1
- package/dist/plus/ai/utils/ai.utils.js +5 -5
- package/dist/plus/ai/utils/ai.utils.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +6 -13
- package/dist/plus/git-github/api/github.d.ts.map +1 -1
- package/dist/plus/git-github/api/github.js +5 -10
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/integrations/authentication/cloudIntegrationService.d.ts +11 -0
- package/dist/plus/integrations/authentication/cloudIntegrationService.d.ts.map +1 -0
- package/dist/plus/integrations/authentication/cloudIntegrationService.js +90 -0
- package/dist/plus/integrations/authentication/cloudIntegrationService.js.map +1 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +67 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts.map +1 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.js +295 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.d.ts +92 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.d.ts.map +1 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js +185 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js.map +1 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts +62 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts.map +1 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js +122 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -0
- package/dist/plus/integrations/authentication/manualTokenProvider.d.ts +15 -0
- package/dist/plus/integrations/authentication/manualTokenProvider.d.ts.map +1 -0
- package/dist/plus/integrations/authentication/manualTokenProvider.js +49 -0
- package/dist/plus/integrations/authentication/manualTokenProvider.js.map +1 -0
- package/dist/plus/integrations/authentication/models.d.ts +87 -0
- package/dist/plus/integrations/authentication/models.d.ts.map +1 -0
- package/dist/plus/integrations/authentication/models.js +64 -0
- package/dist/plus/integrations/authentication/models.js.map +1 -0
- package/dist/plus/integrations/constants.d.ts +47 -0
- package/dist/plus/integrations/constants.d.ts.map +1 -0
- package/dist/plus/integrations/constants.js +128 -0
- package/dist/plus/integrations/constants.js.map +1 -0
- package/dist/plus/integrations/context.d.ts +354 -0
- package/dist/plus/integrations/context.d.ts.map +1 -0
- package/dist/plus/integrations/context.js +2 -0
- package/dist/plus/integrations/context.js.map +1 -0
- package/dist/plus/integrations/errors.d.ts +14 -0
- package/dist/plus/integrations/errors.d.ts.map +1 -0
- package/dist/plus/integrations/errors.js +19 -0
- package/dist/plus/integrations/errors.js.map +1 -0
- package/dist/plus/integrations/index.d.ts +32 -0
- package/dist/plus/integrations/index.d.ts.map +1 -0
- package/dist/plus/integrations/index.js +62 -0
- package/dist/plus/integrations/index.js.map +1 -0
- package/dist/plus/integrations/integrationService.d.ts +98 -0
- package/dist/plus/integrations/integrationService.d.ts.map +1 -0
- package/dist/plus/integrations/integrationService.js +627 -0
- package/dist/plus/integrations/integrationService.js.map +1 -0
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +82 -0
- package/dist/plus/integrations/models/gitHostIntegration.d.ts.map +1 -0
- package/dist/plus/integrations/models/gitHostIntegration.js +522 -0
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -0
- package/dist/plus/integrations/models/integration.d.ts +127 -0
- package/dist/plus/integrations/models/integration.d.ts.map +1 -0
- package/dist/plus/integrations/models/integration.js +456 -0
- package/dist/plus/integrations/models/integration.js.map +1 -0
- package/dist/plus/integrations/models/issuesIntegration.d.ts +28 -0
- package/dist/plus/integrations/models/issuesIntegration.d.ts.map +1 -0
- package/dist/plus/integrations/models/issuesIntegration.js +101 -0
- package/dist/plus/integrations/models/issuesIntegration.js.map +1 -0
- package/dist/plus/integrations/providers/apiClients.d.ts +25 -0
- package/dist/plus/integrations/providers/apiClients.d.ts.map +1 -0
- package/dist/plus/integrations/providers/apiClients.js +39 -0
- package/dist/plus/integrations/providers/apiClients.js.map +1 -0
- package/dist/plus/integrations/providers/azure/azure.d.ts +47 -0
- package/dist/plus/integrations/providers/azure/azure.d.ts.map +1 -0
- package/dist/plus/integrations/providers/azure/azure.js +444 -0
- package/dist/plus/integrations/providers/azure/azure.js.map +1 -0
- package/dist/plus/integrations/providers/azure/models.d.ts +286 -0
- package/dist/plus/integrations/providers/azure/models.d.ts.map +1 -0
- package/dist/plus/integrations/providers/azure/models.js +203 -0
- package/dist/plus/integrations/providers/azure/models.js.map +1 -0
- package/dist/plus/integrations/providers/azureDevOps.d.ts +95 -0
- package/dist/plus/integrations/providers/azureDevOps.d.ts.map +1 -0
- package/dist/plus/integrations/providers/azureDevOps.js +432 -0
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts +42 -0
- package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts.map +1 -0
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js +513 -0
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucket/models.d.ts +222 -0
- package/dist/plus/integrations/providers/bitbucket/models.d.ts.map +1 -0
- package/dist/plus/integrations/providers/bitbucket/models.js +158 -0
- package/dist/plus/integrations/providers/bitbucket/models.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucket-server/models.d.ts +120 -0
- package/dist/plus/integrations/providers/bitbucket-server/models.d.ts.map +1 -0
- package/dist/plus/integrations/providers/bitbucket-server/models.js +111 -0
- package/dist/plus/integrations/providers/bitbucket-server/models.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucket-server.d.ts +60 -0
- package/dist/plus/integrations/providers/bitbucket-server.d.ts.map +1 -0
- package/dist/plus/integrations/providers/bitbucket-server.js +138 -0
- package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucket.d.ts +50 -0
- package/dist/plus/integrations/providers/bitbucket.d.ts.map +1 -0
- package/dist/plus/integrations/providers/bitbucket.js +181 -0
- package/dist/plus/integrations/providers/bitbucket.js.map +1 -0
- package/dist/plus/integrations/providers/github/github.d.ts +5 -0
- package/dist/plus/integrations/providers/github/github.d.ts.map +1 -0
- package/dist/plus/integrations/providers/github/github.js +47 -0
- package/dist/plus/integrations/providers/github/github.js.map +1 -0
- package/dist/plus/integrations/providers/github/github.utils.d.ts +11 -0
- package/dist/plus/integrations/providers/github/github.utils.d.ts.map +1 -0
- package/dist/plus/integrations/providers/github/github.utils.js +6 -0
- package/dist/plus/integrations/providers/github/github.utils.js.map +1 -0
- package/dist/plus/integrations/providers/github/models.d.ts +3 -0
- package/dist/plus/integrations/providers/github/models.d.ts.map +1 -0
- package/dist/plus/integrations/providers/github/models.js +2 -0
- package/dist/plus/integrations/providers/github/models.js.map +1 -0
- package/dist/plus/integrations/providers/github.d.ts +73 -0
- package/dist/plus/integrations/providers/github.d.ts.map +1 -0
- package/dist/plus/integrations/providers/github.js +160 -0
- package/dist/plus/integrations/providers/github.js.map +1 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +63 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.d.ts.map +1 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.js +828 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.d.ts +21 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.d.ts.map +1 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.js +45 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.js.map +1 -0
- package/dist/plus/integrations/providers/gitlab/models.d.ts +128 -0
- package/dist/plus/integrations/providers/gitlab/models.d.ts.map +1 -0
- package/dist/plus/integrations/providers/gitlab/models.js +96 -0
- package/dist/plus/integrations/providers/gitlab/models.js.map +1 -0
- package/dist/plus/integrations/providers/gitlab.d.ts +79 -0
- package/dist/plus/integrations/providers/gitlab.d.ts.map +1 -0
- package/dist/plus/integrations/providers/gitlab.js +253 -0
- package/dist/plus/integrations/providers/gitlab.js.map +1 -0
- package/dist/plus/integrations/providers/jira.d.ts +46 -0
- package/dist/plus/integrations/providers/jira.d.ts.map +1 -0
- package/dist/plus/integrations/providers/jira.js +255 -0
- package/dist/plus/integrations/providers/jira.js.map +1 -0
- package/dist/plus/integrations/providers/linear.d.ts +47 -0
- package/dist/plus/integrations/providers/linear.d.ts.map +1 -0
- package/dist/plus/integrations/providers/linear.js +198 -0
- package/dist/plus/integrations/providers/linear.js.map +1 -0
- package/dist/plus/integrations/providers/models.d.ts +433 -0
- package/dist/plus/integrations/providers/models.d.ts.map +1 -0
- package/dist/plus/integrations/providers/models.js +602 -0
- package/dist/plus/integrations/providers/models.js.map +1 -0
- package/dist/plus/integrations/providers/providersApi.d.ts +129 -0
- package/dist/plus/integrations/providers/providersApi.d.ts.map +1 -0
- package/dist/plus/integrations/providers/providersApi.js +602 -0
- package/dist/plus/integrations/providers/providersApi.js.map +1 -0
- package/dist/plus/integrations/providers/utils.d.ts +54 -0
- package/dist/plus/integrations/providers/utils.d.ts.map +1 -0
- package/dist/plus/integrations/providers/utils.js +262 -0
- package/dist/plus/integrations/providers/utils.js.map +1 -0
- package/dist/plus/integrations/telemetry.d.ts +26 -0
- package/dist/plus/integrations/telemetry.d.ts.map +1 -0
- package/dist/plus/integrations/telemetry.js +11 -0
- package/dist/plus/integrations/telemetry.js.map +1 -0
- package/dist/plus/integrations/utils/integration.utils.d.ts +14 -0
- package/dist/plus/integrations/utils/integration.utils.d.ts.map +1 -0
- package/dist/plus/integrations/utils/integration.utils.js +111 -0
- package/dist/plus/integrations/utils/integration.utils.js.map +1 -0
- package/dist/utils/disposable.d.ts +15 -2
- package/dist/utils/disposable.d.ts.map +1 -1
- package/dist/utils/disposable.js.map +1 -1
- package/package.json +43 -2
- package/src/git/context.ts +4 -3
- package/src/git/providers/operations.ts +1 -1
- package/src/git/providers/worktrees.ts +14 -2
- package/src/git/utils/conflictResolution.utils.ts +126 -0
- package/src/git-cli/providers/operations.ts +22 -2
- package/src/git-cli/providers/worktrees.ts +17 -2
- package/src/plus/ai/utils/ai.utils.ts +5 -5
- package/src/plus/git-github/api/github.ts +13 -25
- package/src/plus/integrations/authentication/cloudIntegrationService.ts +120 -0
- package/src/plus/integrations/authentication/configuredIntegrationService.ts +414 -0
- package/src/plus/integrations/authentication/integrationAuthenticationProvider.ts +289 -0
- package/src/plus/integrations/authentication/integrationAuthenticationService.ts +144 -0
- package/src/plus/integrations/authentication/manualTokenProvider.ts +72 -0
- package/src/plus/integrations/authentication/models.ts +168 -0
- package/src/plus/integrations/constants.ts +169 -0
- package/src/plus/integrations/context.ts +383 -0
- package/src/plus/integrations/errors.ts +35 -0
- package/src/plus/integrations/index.ts +119 -0
- package/src/plus/integrations/integrationService.ts +924 -0
- package/src/plus/integrations/models/gitHostIntegration.ts +738 -0
- package/src/plus/integrations/models/integration.ts +657 -0
- package/src/plus/integrations/models/issuesIntegration.ts +124 -0
- package/src/plus/integrations/providers/apiClients.ts +72 -0
- package/src/plus/integrations/providers/azure/azure.ts +691 -0
- package/src/plus/integrations/providers/azure/models.ts +605 -0
- package/src/plus/integrations/providers/azureDevOps.ts +677 -0
- package/src/plus/integrations/providers/bitbucket/bitbucket.ts +774 -0
- package/src/plus/integrations/providers/bitbucket/models.ts +445 -0
- package/src/plus/integrations/providers/bitbucket-server/models.ts +252 -0
- package/src/plus/integrations/providers/bitbucket-server.ts +282 -0
- package/src/plus/integrations/providers/bitbucket.ts +350 -0
- package/src/plus/integrations/providers/github/github.ts +64 -0
- package/src/plus/integrations/providers/github/github.utils.ts +23 -0
- package/src/plus/integrations/providers/github/models.ts +29 -0
- package/src/plus/integrations/providers/github.ts +366 -0
- package/src/plus/integrations/providers/gitlab/gitlab.ts +1210 -0
- package/src/plus/integrations/providers/gitlab/gitlab.utils.ts +71 -0
- package/src/plus/integrations/providers/gitlab/models.ts +257 -0
- package/src/plus/integrations/providers/gitlab.ts +473 -0
- package/src/plus/integrations/providers/jira.ts +359 -0
- package/src/plus/integrations/providers/linear.ts +275 -0
- package/src/plus/integrations/providers/models.ts +1114 -0
- package/src/plus/integrations/providers/providersApi.ts +1126 -0
- package/src/plus/integrations/providers/utils.ts +359 -0
- package/src/plus/integrations/telemetry.ts +29 -0
- package/src/plus/integrations/utils/integration.utils.ts +138 -0
- package/src/utils/disposable.ts +15 -2
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { trace } from '../../../utils/decorators/log.js';
|
|
8
|
+
import { Emitter } from '../../../utils/event.js';
|
|
9
|
+
import { GitCloudHostIntegrationId } from '../constants.js';
|
|
10
|
+
import { isCloudGitSelfManagedHostIntegrationId, isGitSelfManagedHostIntegrationId, } from '../utils/integration.utils.js';
|
|
11
|
+
import { isSupportedCloudIntegrationId } from './models.js';
|
|
12
|
+
const maxSmallIntegerV8 = 2 ** 30 - 1; // Max number that can be stored in V8's smis (small integers)
|
|
13
|
+
class IntegrationAuthenticationProviderBase {
|
|
14
|
+
authenticationService;
|
|
15
|
+
configuredIntegrationService;
|
|
16
|
+
disposables = [];
|
|
17
|
+
constructor(authenticationService, configuredIntegrationService) {
|
|
18
|
+
this.authenticationService = authenticationService;
|
|
19
|
+
this.configuredIntegrationService = configuredIntegrationService;
|
|
20
|
+
}
|
|
21
|
+
dispose() {
|
|
22
|
+
this.disposables.forEach(d => d.dispose());
|
|
23
|
+
}
|
|
24
|
+
_onDidChange = new Emitter();
|
|
25
|
+
get onDidChange() {
|
|
26
|
+
return this._onDidChange.event;
|
|
27
|
+
}
|
|
28
|
+
async deleteSession(descriptor) {
|
|
29
|
+
const configured = this.configuredIntegrationService.getConfigured(this.authProviderId, {
|
|
30
|
+
cloud: true,
|
|
31
|
+
domain: isGitSelfManagedHostIntegrationId(this.authProviderId) ? descriptor?.domain : undefined,
|
|
32
|
+
});
|
|
33
|
+
await this.configuredIntegrationService.deleteStoredSessions(this.authProviderId, descriptor, undefined);
|
|
34
|
+
if (configured?.length) {
|
|
35
|
+
this.fireChange();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async deleteAllSessions() {
|
|
39
|
+
const configured = this.configuredIntegrationService.getConfigured(this.authProviderId, {
|
|
40
|
+
cloud: true,
|
|
41
|
+
});
|
|
42
|
+
await this.configuredIntegrationService.deleteAllStoredSessions(this.authProviderId, undefined);
|
|
43
|
+
if (configured?.length) {
|
|
44
|
+
this.fireChange();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async getSession(descriptor, options) {
|
|
48
|
+
let session;
|
|
49
|
+
let previousToken;
|
|
50
|
+
if (options?.forceNewSession) {
|
|
51
|
+
await this.configuredIntegrationService.deleteStoredSessions(this.authProviderId, descriptor, undefined);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
session = await this.configuredIntegrationService.getStoredSession(this.authProviderId, descriptor);
|
|
55
|
+
previousToken = session?.accessToken;
|
|
56
|
+
}
|
|
57
|
+
const isExpiredSession = session?.expiresAt != null && new Date(session.expiresAt).getTime() < Date.now();
|
|
58
|
+
if (session == null || isExpiredSession) {
|
|
59
|
+
session = await this.getNewSession(descriptor, {
|
|
60
|
+
...options,
|
|
61
|
+
refreshIfExpired: isExpiredSession,
|
|
62
|
+
});
|
|
63
|
+
if (session != null) {
|
|
64
|
+
await this.configuredIntegrationService.storeSession(this.authProviderId, session);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (previousToken !== session?.accessToken) {
|
|
68
|
+
this.fireChange();
|
|
69
|
+
}
|
|
70
|
+
return session;
|
|
71
|
+
}
|
|
72
|
+
fireChange() {
|
|
73
|
+
queueMicrotask(() => this._onDidChange.fire());
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
__decorate([
|
|
77
|
+
trace()
|
|
78
|
+
], IntegrationAuthenticationProviderBase.prototype, "deleteSession", null);
|
|
79
|
+
__decorate([
|
|
80
|
+
trace()
|
|
81
|
+
], IntegrationAuthenticationProviderBase.prototype, "deleteAllSessions", null);
|
|
82
|
+
__decorate([
|
|
83
|
+
trace()
|
|
84
|
+
], IntegrationAuthenticationProviderBase.prototype, "getSession", null);
|
|
85
|
+
export class CloudIntegrationAuthenticationProvider extends IntegrationAuthenticationProviderBase {
|
|
86
|
+
_authProviderId;
|
|
87
|
+
constructor(authenticationService, configuredIntegrationService, _authProviderId) {
|
|
88
|
+
super(authenticationService, configuredIntegrationService);
|
|
89
|
+
this._authProviderId = _authProviderId;
|
|
90
|
+
}
|
|
91
|
+
get authProviderId() {
|
|
92
|
+
return this._authProviderId;
|
|
93
|
+
}
|
|
94
|
+
async getNewSession(descriptor, options) {
|
|
95
|
+
if (options?.forceNewSession) {
|
|
96
|
+
if ((await this.disconnectCloudSession()) === 'failure') {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
void this.connectCloudSession(false, options?.source);
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
// TODO: This is a stopgap to make sure we're not hammering the api on automatic calls to get the session.
|
|
103
|
+
// Ultimately we want to timestamp calls to syncCloudIntegrations and use that to determine whether we should
|
|
104
|
+
// make the call or not.
|
|
105
|
+
let session = options?.refreshIfExpired || options?.createIfNeeded || options?.forceNewSession || options?.sync
|
|
106
|
+
? await this.getCloudSession(descriptor)
|
|
107
|
+
: undefined;
|
|
108
|
+
const shouldCreateSession = options?.createIfNeeded && session == null;
|
|
109
|
+
if (shouldCreateSession) {
|
|
110
|
+
const connected = await this.connectCloudSession(true, options?.source);
|
|
111
|
+
if (!connected)
|
|
112
|
+
return undefined;
|
|
113
|
+
// This should get us the session we just created with connectCloudSession, because a syncCloudIntegrations run from
|
|
114
|
+
// integration service should have resulted in it being created and stored by this provider
|
|
115
|
+
session = await this.getSession(descriptor, { source: options?.source });
|
|
116
|
+
}
|
|
117
|
+
return session;
|
|
118
|
+
}
|
|
119
|
+
connectCloudSession(skipIfConnected, source) {
|
|
120
|
+
// Capture in a const so the type guard narrows it to `SupportedCloudIntegrationIds` (a getter
|
|
121
|
+
// access wouldn't narrow), letting us call the service directly without a cast.
|
|
122
|
+
const id = this.authProviderId;
|
|
123
|
+
if (isSupportedCloudIntegrationId(id)) {
|
|
124
|
+
return this.authenticationService.connectCloudIntegrations({ integrationIds: [id], skipIfConnected: skipIfConnected, skipPreSync: true }, {
|
|
125
|
+
source: source ?? 'integrations',
|
|
126
|
+
detail: {
|
|
127
|
+
action: 'connect',
|
|
128
|
+
integration: id,
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return Promise.resolve(false);
|
|
133
|
+
}
|
|
134
|
+
async getCloudSession(descriptor) {
|
|
135
|
+
const loggedIn = (await this.authenticationService.ctx.account.getAccount()) != null;
|
|
136
|
+
if (!loggedIn)
|
|
137
|
+
return undefined;
|
|
138
|
+
const cloudIntegrations = this.authenticationService.cloudIntegrations;
|
|
139
|
+
let session = await cloudIntegrations.getConnectionSession(this.authProviderId);
|
|
140
|
+
// Make an exception for GitHub and Cloud Self-Hosted integrations because they always return 0
|
|
141
|
+
if (session?.expiresIn === 0 &&
|
|
142
|
+
(this.authProviderId === GitCloudHostIntegrationId.GitHub ||
|
|
143
|
+
isCloudGitSelfManagedHostIntegrationId(this.authProviderId))) {
|
|
144
|
+
// It never expires so don't refresh it frequently:
|
|
145
|
+
session.expiresIn = maxSmallIntegerV8; // maximum expiration length
|
|
146
|
+
}
|
|
147
|
+
if (session != null && session.expiresIn < 60) {
|
|
148
|
+
session = await cloudIntegrations.getConnectionSession(this.authProviderId, session.accessToken);
|
|
149
|
+
}
|
|
150
|
+
if (!session)
|
|
151
|
+
return undefined;
|
|
152
|
+
let sessionProtocol;
|
|
153
|
+
try {
|
|
154
|
+
sessionProtocol = new URL(session.domain).protocol;
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
// If the domain is invalid, we can't use it to create a session
|
|
158
|
+
sessionProtocol = undefined;
|
|
159
|
+
}
|
|
160
|
+
// TODO: Once we care about domains, we should try to match the domain here against ours, and if it fails, return undefined
|
|
161
|
+
return {
|
|
162
|
+
id: this.configuredIntegrationService.getSessionId(descriptor),
|
|
163
|
+
accessToken: session.accessToken,
|
|
164
|
+
scopes: descriptor.scopes,
|
|
165
|
+
account: {
|
|
166
|
+
id: '',
|
|
167
|
+
label: '',
|
|
168
|
+
},
|
|
169
|
+
cloud: true,
|
|
170
|
+
type: session.type,
|
|
171
|
+
expiresAt: new Date(session.expiresIn * 1000 + Date.now()),
|
|
172
|
+
// Note: do not use the session's domain, because the format is different than in our model
|
|
173
|
+
domain: descriptor.domain,
|
|
174
|
+
protocol: sessionProtocol ?? undefined,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
async disconnectCloudSession() {
|
|
178
|
+
const loggedIn = (await this.authenticationService.ctx.account.getAccount()) != null;
|
|
179
|
+
if (!loggedIn)
|
|
180
|
+
return 'skip';
|
|
181
|
+
const cloudIntegrations = this.authenticationService.cloudIntegrations;
|
|
182
|
+
return (await cloudIntegrations.disconnect(this.authProviderId)) ? 'success' : 'failure';
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=integrationAuthenticationProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrationAuthenticationProvider.js","sourceRoot":"","sources":["../../src/authentication/integrationAuthenticationProvider.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AAGzD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EACN,sCAAsC,EACtC,iCAAiC,GACjC,MAAM,+BAA+B,CAAC;AAIvC,OAAO,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,8DAA8D;AAyBrG,MAAe,qCAAqC;IAM/B;IACA;IAJD,WAAW,GAAiB,EAAE,CAAC;IAElD,YACoB,qBAAuD,EACvD,4BAA0D;QAD1D,0BAAqB,GAArB,qBAAqB,CAAkC;QACvD,iCAA4B,GAA5B,4BAA4B,CAA8B;IA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CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1F,CAAC;CACD"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { GitRemote } from '../../../git/models/remote.js';
|
|
2
|
+
import type { Disposable } from '../../../utils/disposable.js';
|
|
3
|
+
import type { IntegrationIds, SupportedCloudIntegrationIds } from '../constants.js';
|
|
4
|
+
import type { IntegrationServiceContext } from '../context.js';
|
|
5
|
+
import type { IntegrationService } from '../integrationService.js';
|
|
6
|
+
import type { GitHostIntegration } from '../models/gitHostIntegration.js';
|
|
7
|
+
import type { ApiClients } from '../providers/apiClients.js';
|
|
8
|
+
import type { Source } from '../telemetry.js';
|
|
9
|
+
import type { CloudIntegrationService } from './cloudIntegrationService.js';
|
|
10
|
+
import type { ConfiguredIntegrationService } from './configuredIntegrationService.js';
|
|
11
|
+
import type { IntegrationAuthenticationProvider } from './integrationAuthenticationProvider.js';
|
|
12
|
+
export declare class IntegrationAuthenticationService implements Disposable {
|
|
13
|
+
private readonly configuredIntegrationService;
|
|
14
|
+
readonly ctx: IntegrationServiceContext;
|
|
15
|
+
/**
|
|
16
|
+
* Lazy accessor for the owning {@link IntegrationService}. Injected by the composition root
|
|
17
|
+
* ({@link createIntegrationManager}) to break the auth↔service construction cycle without a
|
|
18
|
+
* mutable setter or a host round-trip; only resolved at runtime (long after construction).
|
|
19
|
+
*/
|
|
20
|
+
private readonly getIntegrationService;
|
|
21
|
+
/** The package's cloud token-exchange client, constructed by the composition root. */
|
|
22
|
+
readonly cloudIntegrations: CloudIntegrationService;
|
|
23
|
+
private readonly providers;
|
|
24
|
+
constructor(configuredIntegrationService: ConfiguredIntegrationService, ctx: IntegrationServiceContext,
|
|
25
|
+
/**
|
|
26
|
+
* Lazy accessor for the owning {@link IntegrationService}. Injected by the composition root
|
|
27
|
+
* ({@link createIntegrationManager}) to break the auth↔service construction cycle without a
|
|
28
|
+
* mutable setter or a host round-trip; only resolved at runtime (long after construction).
|
|
29
|
+
*/
|
|
30
|
+
getIntegrationService: () => IntegrationService,
|
|
31
|
+
/** The package's cloud token-exchange client, constructed by the composition root. */
|
|
32
|
+
cloudIntegrations: CloudIntegrationService);
|
|
33
|
+
dispose(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Initiates the cloud-integration connect flow on the owning service. Cloud auth providers call
|
|
36
|
+
* this when they need a session that doesn't exist yet (see
|
|
37
|
+
* {@link CloudIntegrationAuthenticationProvider}).
|
|
38
|
+
*/
|
|
39
|
+
connectCloudIntegrations(connect: {
|
|
40
|
+
integrationIds: SupportedCloudIntegrationIds[];
|
|
41
|
+
skipIfConnected?: boolean;
|
|
42
|
+
skipPreSync?: boolean;
|
|
43
|
+
}, source?: Source): Promise<boolean>;
|
|
44
|
+
/**
|
|
45
|
+
* Resolves the connected git-host integration for a `GitRemote`, via the owning service. Lets
|
|
46
|
+
* package-internal callers (e.g. the Bitbucket provider) resolve a remote's integration without a
|
|
47
|
+
* host round-trip.
|
|
48
|
+
*/
|
|
49
|
+
getByRemote(remote: GitRemote): Promise<GitHostIntegration | undefined>;
|
|
50
|
+
/** Resolves the per-integration `ignoreSSLErrors` flag via the owning service (host-config-backed). */
|
|
51
|
+
ignoreSSLErrors(integration: GitHostIntegration | {
|
|
52
|
+
id: IntegrationIds;
|
|
53
|
+
domain?: string;
|
|
54
|
+
}): boolean | 'force';
|
|
55
|
+
/** The package-built per-provider API clients, via the owning service (built once + memoized there). */
|
|
56
|
+
get apis(): ApiClients;
|
|
57
|
+
get(providerId: IntegrationIds): Promise<IntegrationAuthenticationProvider>;
|
|
58
|
+
reset(): Promise<void>;
|
|
59
|
+
supports(providerId: string): boolean;
|
|
60
|
+
private ensureProvider;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=integrationAuthenticationService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrationAuthenticationService.d.ts","sourceRoot":"","sources":["../../src/authentication/integrationAuthenticationService.ts"],"names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O,CAAC;QAAC,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,EAC7G,MAAM,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC;IAInB;;;;OAIG;IACH,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC;IAIvE,uGAAuG;IACvG,eAAe,CAAC,WAAW,EAAE,kBAAkB,GAAG;QAAE,EAAE,EAAE,cAAc,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,GAAG,OAAO;IAI7G,wGAAwG;IACxG,IAAI,IAAI,IAAI,UAAU,CAErB;IAEK,GAAG,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,iCAAiC,CAAC;IAK3E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAS5B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;YAevB,cAAc;CAyC5B"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { gate } from '../../../utils/decorators/gate.js';
|
|
8
|
+
import { debug } from '../../../utils/decorators/log.js';
|
|
9
|
+
import { GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId, IssuesCloudHostIntegrationId, } from '../constants.js';
|
|
10
|
+
import { supportedIntegrationIds } from '../utils/integration.utils.js';
|
|
11
|
+
import { CloudIntegrationAuthenticationProvider } from './integrationAuthenticationProvider.js';
|
|
12
|
+
export class IntegrationAuthenticationService {
|
|
13
|
+
configuredIntegrationService;
|
|
14
|
+
ctx;
|
|
15
|
+
getIntegrationService;
|
|
16
|
+
cloudIntegrations;
|
|
17
|
+
providers = new Map();
|
|
18
|
+
constructor(configuredIntegrationService, ctx,
|
|
19
|
+
/**
|
|
20
|
+
* Lazy accessor for the owning {@link IntegrationService}. Injected by the composition root
|
|
21
|
+
* ({@link createIntegrationManager}) to break the auth↔service construction cycle without a
|
|
22
|
+
* mutable setter or a host round-trip; only resolved at runtime (long after construction).
|
|
23
|
+
*/
|
|
24
|
+
getIntegrationService,
|
|
25
|
+
/** The package's cloud token-exchange client, constructed by the composition root. */
|
|
26
|
+
cloudIntegrations) {
|
|
27
|
+
this.configuredIntegrationService = configuredIntegrationService;
|
|
28
|
+
this.ctx = ctx;
|
|
29
|
+
this.getIntegrationService = getIntegrationService;
|
|
30
|
+
this.cloudIntegrations = cloudIntegrations;
|
|
31
|
+
}
|
|
32
|
+
dispose() {
|
|
33
|
+
this.providers.forEach(p => p.dispose());
|
|
34
|
+
this.providers.clear();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Initiates the cloud-integration connect flow on the owning service. Cloud auth providers call
|
|
38
|
+
* this when they need a session that doesn't exist yet (see
|
|
39
|
+
* {@link CloudIntegrationAuthenticationProvider}).
|
|
40
|
+
*/
|
|
41
|
+
connectCloudIntegrations(connect, source) {
|
|
42
|
+
return this.getIntegrationService().connectCloudIntegrations(connect, source);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Resolves the connected git-host integration for a `GitRemote`, via the owning service. Lets
|
|
46
|
+
* package-internal callers (e.g. the Bitbucket provider) resolve a remote's integration without a
|
|
47
|
+
* host round-trip.
|
|
48
|
+
*/
|
|
49
|
+
getByRemote(remote) {
|
|
50
|
+
return this.getIntegrationService().getByRemote(remote);
|
|
51
|
+
}
|
|
52
|
+
/** Resolves the per-integration `ignoreSSLErrors` flag via the owning service (host-config-backed). */
|
|
53
|
+
ignoreSSLErrors(integration) {
|
|
54
|
+
return this.getIntegrationService().ignoreSSLErrors(integration);
|
|
55
|
+
}
|
|
56
|
+
/** The package-built per-provider API clients, via the owning service (built once + memoized there). */
|
|
57
|
+
get apis() {
|
|
58
|
+
return this.getIntegrationService().apis;
|
|
59
|
+
}
|
|
60
|
+
async get(providerId) {
|
|
61
|
+
return this.ensureProvider(providerId);
|
|
62
|
+
}
|
|
63
|
+
async reset() {
|
|
64
|
+
// TODO: This really isn't ideal, since it will only work for "cloud" providers as we won't have any more specific descriptors
|
|
65
|
+
await Promise.allSettled(supportedIntegrationIds.map(async (providerId) => (await this.ensureProvider(providerId)).deleteAllSessions()));
|
|
66
|
+
}
|
|
67
|
+
supports(providerId) {
|
|
68
|
+
switch (providerId) {
|
|
69
|
+
case GitCloudHostIntegrationId.AzureDevOps:
|
|
70
|
+
case GitSelfManagedHostIntegrationId.AzureDevOpsServer:
|
|
71
|
+
case GitCloudHostIntegrationId.Bitbucket:
|
|
72
|
+
case GitCloudHostIntegrationId.GitLab:
|
|
73
|
+
case IssuesCloudHostIntegrationId.Jira:
|
|
74
|
+
case GitCloudHostIntegrationId.GitHub:
|
|
75
|
+
return true;
|
|
76
|
+
default:
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async ensureProvider(providerId) {
|
|
81
|
+
let provider = this.providers.get(providerId);
|
|
82
|
+
if (provider != null)
|
|
83
|
+
return provider;
|
|
84
|
+
// Optional consumer override for custom auth (e.g. a manual-token provider). GitLens omits it —
|
|
85
|
+
// the package constructs its own cloud providers below (so GitLens's cloud auth needs no host hook).
|
|
86
|
+
const hostProvider = await this.ctx.hooks?.createAuthenticationProvider?.({
|
|
87
|
+
id: providerId,
|
|
88
|
+
auth: this,
|
|
89
|
+
configured: this.configuredIntegrationService,
|
|
90
|
+
});
|
|
91
|
+
if (hostProvider != null) {
|
|
92
|
+
this.providers.set(providerId, hostProvider);
|
|
93
|
+
return hostProvider;
|
|
94
|
+
}
|
|
95
|
+
// Every cloud integration shares one provider, parameterized by id (cloud-only).
|
|
96
|
+
switch (providerId) {
|
|
97
|
+
case GitCloudHostIntegrationId.GitHub:
|
|
98
|
+
case GitSelfManagedHostIntegrationId.CloudGitHubEnterprise:
|
|
99
|
+
case GitCloudHostIntegrationId.GitLab:
|
|
100
|
+
case GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted:
|
|
101
|
+
case GitCloudHostIntegrationId.AzureDevOps:
|
|
102
|
+
case GitSelfManagedHostIntegrationId.AzureDevOpsServer:
|
|
103
|
+
case GitCloudHostIntegrationId.Bitbucket:
|
|
104
|
+
case GitSelfManagedHostIntegrationId.BitbucketServer:
|
|
105
|
+
case IssuesCloudHostIntegrationId.Jira:
|
|
106
|
+
case IssuesCloudHostIntegrationId.Linear:
|
|
107
|
+
provider = new CloudIntegrationAuthenticationProvider(this, this.configuredIntegrationService, providerId);
|
|
108
|
+
break;
|
|
109
|
+
default:
|
|
110
|
+
throw new Error(`No authentication provider registered for integration '${providerId}'`);
|
|
111
|
+
}
|
|
112
|
+
this.providers.set(providerId, provider);
|
|
113
|
+
return provider;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
__decorate([
|
|
117
|
+
debug()
|
|
118
|
+
], IntegrationAuthenticationService.prototype, "reset", null);
|
|
119
|
+
__decorate([
|
|
120
|
+
gate()
|
|
121
|
+
], IntegrationAuthenticationService.prototype, "ensureProvider", null);
|
|
122
|
+
//# sourceMappingURL=integrationAuthenticationService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrationAuthenticationService.js","sourceRoot":"","sources":["../../src/authentication/integrationAuthenticationService.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AAGzD,OAAO,EACN,yBAAyB,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FAAiF;QACjF,QAAQ,UAAU,EAAE,CAAC;YACpB,KAAK,yBAAyB,CAAC,MAAM,CAAC;YACtC,KAAK,+BAA+B,CAAC,qBAAqB,CAAC;YAC3D,KAAK,yBAAyB,CAAC,MAAM,CAAC;YACtC,KAAK,+BAA+B,CAAC,qBAAqB,CAAC;YAC3D,KAAK,yBAAyB,CAAC,WAAW,CAAC;YAC3C,KAAK,+BAA+B,CAAC,iBAAiB,CAAC;YACvD,KAAK,yBAAyB,CAAC,SAAS,CAAC;YACzC,KAAK,+BAA+B,CAAC,eAAe,CAAC;YACrD,KAAK,4BAA4B,CAAC,IAAI,CAAC;YACvC,KAAK,4BAA4B,CAAC,MAAM;gBACvC,QAAQ,GAAG,IAAI,sCAAsC,CACpD,IAAI,EACJ,IAAI,CAAC,4BAA4B,EACjC,UAAU,CACV,CAAC;gBACF,MAAM;YACP;gBACC,MAAM,IAAI,KAAK,CAAC,0DAA0D,UAAU,GAAG,CAAC,CAAC;QAC3F,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACzC,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD;AAjEM;IADL,KAAK,EAAE;6DAQP;AAiBa;IADb,IAAI,EAAE;sEAyCN"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IntegrationIds } from '../constants.js';
|
|
2
|
+
import type { IntegrationAuthenticationProvider } from './integrationAuthenticationProvider.js';
|
|
3
|
+
export interface ManualTokenAuthProviderOptions {
|
|
4
|
+
readonly id: IntegrationIds;
|
|
5
|
+
readonly token: string;
|
|
6
|
+
readonly account: {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly label: string;
|
|
9
|
+
};
|
|
10
|
+
readonly scopes?: readonly string[];
|
|
11
|
+
readonly domain?: string;
|
|
12
|
+
readonly cloud?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function createManualTokenAuthProvider(options: ManualTokenAuthProviderOptions): IntegrationAuthenticationProvider;
|
|
15
|
+
//# sourceMappingURL=manualTokenProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manualTokenProvider.d.ts","sourceRoot":"","sources":["../../src/authentication/manualTokenProvider.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EACX,iCAAiC,EAEjC,MAAM,wCAAwC,CAAC;AAGhD,MAAM,WAAW,8BAA8B;IAC9C,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAClE,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,6BAA6B,CAC5C,OAAO,EAAE,8BAA8B,GACrC,iCAAiC,CA4BnC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Convenience for "manual token" auth — when a consumer already has an access
|
|
2
|
+
// token (CLI flag, env var, secret manager) and just wants the package to use
|
|
3
|
+
// it without an OAuth dance. Wire it into the manager via the
|
|
4
|
+
// `createAuthenticationProvider` hook:
|
|
5
|
+
//
|
|
6
|
+
// const manager = createIntegrationManager({
|
|
7
|
+
// ...runtime,
|
|
8
|
+
// hooks: {
|
|
9
|
+
// createAuthenticationProvider: async ({ id }) =>
|
|
10
|
+
// id === GitCloudHostIntegrationId.GitHub
|
|
11
|
+
// ? createManualTokenAuthProvider({
|
|
12
|
+
// id: id,
|
|
13
|
+
// token: process.env.GITHUB_TOKEN!,
|
|
14
|
+
// account: { id: 'me', label: 'CLI Token' },
|
|
15
|
+
// })
|
|
16
|
+
// : undefined,
|
|
17
|
+
// },
|
|
18
|
+
// });
|
|
19
|
+
//
|
|
20
|
+
// The provider is intentionally minimal — sessions are non-cancellable, never
|
|
21
|
+
// expire, and persist for the lifetime of the manager. For OAuth flows or
|
|
22
|
+
// refreshable tokens, implement `IntegrationAuthenticationProvider` yourself.
|
|
23
|
+
import { Emitter } from '../../../utils/event.js';
|
|
24
|
+
export function createManualTokenAuthProvider(options) {
|
|
25
|
+
const onDidChange = new Emitter();
|
|
26
|
+
const session = {
|
|
27
|
+
id: `manual:${options.id}`,
|
|
28
|
+
accessToken: options.token,
|
|
29
|
+
account: options.account,
|
|
30
|
+
scopes: options.scopes ?? [],
|
|
31
|
+
cloud: options.cloud ?? true,
|
|
32
|
+
type: undefined,
|
|
33
|
+
domain: options.domain ?? '',
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
get onDidChange() {
|
|
37
|
+
return onDidChange.event;
|
|
38
|
+
},
|
|
39
|
+
getSession: (_descriptor, options) =>
|
|
40
|
+
// A manual token can't be refreshed; on a forced new session, fail safe by returning undefined
|
|
41
|
+
// rather than handing back the same (likely-rejected) token, which would loop a caller's
|
|
42
|
+
// reauthenticate-on-failure flow.
|
|
43
|
+
Promise.resolve(options?.forceNewSession ? undefined : session),
|
|
44
|
+
deleteSession: () => Promise.resolve(),
|
|
45
|
+
deleteAllSessions: () => Promise.resolve(),
|
|
46
|
+
dispose: () => onDidChange.dispose(),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=manualTokenProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manualTokenProvider.js","sourceRoot":"","sources":["../../src/authentication/manualTokenProvider.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,8EAA8E;AAC9E,8DAA8D;AAC9D,uCAAuC;AACvC,EAAE;AACF,+CAA+C;AAC/C,oBAAoB;A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loudIntegrationIds } from '../constants.js';
|
|
2
|
+
import { IssuesCloudHostIntegrationId } from '../constants.js';
|
|
3
|
+
/**
|
|
4
|
+
* Mirrors the shape of `vscode.AuthenticationSession` so the integrations
|
|
5
|
+
* package can stay vscode-free. Host adapters bridge VS Code sessions to
|
|
6
|
+
* this shape via {@link AuthenticationProvider}.
|
|
7
|
+
*/
|
|
8
|
+
export interface AuthenticationSessionLike {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly accessToken: string;
|
|
11
|
+
readonly account: {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly label: string;
|
|
14
|
+
};
|
|
15
|
+
readonly scopes: readonly string[];
|
|
16
|
+
}
|
|
17
|
+
export interface ProviderAuthenticationSession extends AuthenticationSessionLike {
|
|
18
|
+
readonly cloud: boolean;
|
|
19
|
+
readonly type: CloudIntegrationAuthType | undefined;
|
|
20
|
+
readonly expiresAt?: Date;
|
|
21
|
+
readonly domain: string;
|
|
22
|
+
readonly protocol?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface TokenInfo<T extends IntegrationIds | 'gitkraken' = IntegrationIds | 'gitkraken'> {
|
|
25
|
+
readonly providerId: T;
|
|
26
|
+
/**
|
|
27
|
+
* The first 3 characters of the md5 hash of the token.
|
|
28
|
+
* It's a very obfuscated representation of the token that we can use in logs
|
|
29
|
+
* to see whether the token survives refreshing or gets updated.
|
|
30
|
+
*/
|
|
31
|
+
readonly microHash: string | undefined;
|
|
32
|
+
readonly cloud: boolean;
|
|
33
|
+
readonly type: CloudIntegrationAuthType | undefined;
|
|
34
|
+
readonly scopes: readonly string[] | undefined;
|
|
35
|
+
readonly expiresAt?: Date;
|
|
36
|
+
}
|
|
37
|
+
export interface TokenWithInfo<T extends IntegrationIds = IntegrationIds> extends TokenInfo<T> {
|
|
38
|
+
readonly accessToken: string;
|
|
39
|
+
}
|
|
40
|
+
export declare function toTokenInfo<T extends IntegrationIds | 'gitkraken'>(providerId: T, accessToken: string | undefined, info: {
|
|
41
|
+
cloud: boolean;
|
|
42
|
+
type: CloudIntegrationAuthType | undefined;
|
|
43
|
+
scopes?: readonly string[];
|
|
44
|
+
expiresAt?: Date;
|
|
45
|
+
}): TokenInfo<T>;
|
|
46
|
+
export declare function toTokenWithInfo<T extends IntegrationIds>(providerId: T, session: ProviderAuthenticationSession, altToken?: string): TokenWithInfo<T>;
|
|
47
|
+
export type TokenOptInfo<T extends IntegrationIds = IntegrationIds> = TokenWithInfo<T> | {
|
|
48
|
+
providerId: T;
|
|
49
|
+
accessToken?: undefined;
|
|
50
|
+
};
|
|
51
|
+
export interface ConfiguredIntegrationDescriptor {
|
|
52
|
+
readonly cloud: boolean;
|
|
53
|
+
readonly integrationId: IntegrationIds;
|
|
54
|
+
readonly scopes: string;
|
|
55
|
+
readonly domain?: string;
|
|
56
|
+
readonly expiresAt?: string | Date;
|
|
57
|
+
}
|
|
58
|
+
export interface CloudIntegrationAuthenticationSession {
|
|
59
|
+
type: CloudIntegrationAuthType;
|
|
60
|
+
accessToken: string;
|
|
61
|
+
domain: string;
|
|
62
|
+
expiresIn: number;
|
|
63
|
+
scopes: string;
|
|
64
|
+
}
|
|
65
|
+
export interface CloudIntegrationAuthorization {
|
|
66
|
+
url: string;
|
|
67
|
+
}
|
|
68
|
+
export interface CloudIntegrationConnection {
|
|
69
|
+
type: CloudIntegrationAuthType;
|
|
70
|
+
provider: CloudIntegrationType;
|
|
71
|
+
domain: string;
|
|
72
|
+
}
|
|
73
|
+
export type CloudIntegrationType = 'jira' | 'linear' | 'trello' | 'gitlab' | 'github' | 'bitbucket' | 'bitbucketServer' | 'azure' | 'azureDevopsServer' | 'githubEnterprise' | 'gitlabSelfHosted';
|
|
74
|
+
export type CloudIntegrationAuthType = 'oauth' | 'pat';
|
|
75
|
+
export declare const CloudIntegrationAuthenticationUriPathPrefix = "did-authenticate-cloud-integration";
|
|
76
|
+
/** Returns all supported cloud integration ids. */
|
|
77
|
+
export declare function getSupportedCloudIntegrationIds(): readonly SupportedCloudIntegrationIds[];
|
|
78
|
+
/** Whether `id` is a supported cloud integration id. */
|
|
79
|
+
export declare function isSupportedCloudIntegrationId(id: string): id is SupportedCloudIntegrationIds;
|
|
80
|
+
export declare function isIssueCloudIntegrationId(id: string): id is IssuesCloudHostIntegrationId;
|
|
81
|
+
export declare const toIntegrationId: {
|
|
82
|
+
[key in CloudIntegrationType]: IntegrationIds;
|
|
83
|
+
};
|
|
84
|
+
export declare const toCloudIntegrationType: {
|
|
85
|
+
[key in IntegrationIds]: CloudIntegrationType | undefined;
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/authentication/models.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AACpF,OAAO,EAGN,4BAA4B,EAE5B,MAAM,iBAAiB,CAAC;AAEzB;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAClE,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,6BAA8B,SAAQ,yBAAyB;IAC/E,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,wBAAwB,GAAG,SAAS,CAAC;IACpD,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,M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c;CAY5E,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE;KAAG,GAAG,IAAI,cAAc,GAAG,oBAAoB,GAAG,SAAS;CAY/F,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { microhash } from '../../../utils/hash.js';
|
|
2
|
+
import { GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId, IssuesCloudHostIntegrationId, supportedOrderedCloudIntegrationIds, } from '../constants.js';
|
|
3
|
+
export function toTokenInfo(providerId, accessToken, info) {
|
|
4
|
+
return {
|
|
5
|
+
providerId: providerId,
|
|
6
|
+
microHash: microhash(accessToken, 3),
|
|
7
|
+
cloud: info.cloud,
|
|
8
|
+
type: info.type,
|
|
9
|
+
scopes: info.scopes,
|
|
10
|
+
expiresAt: info.expiresAt,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function toTokenWithInfo(providerId, session, altToken) {
|
|
14
|
+
const { accessToken: sessionToken, ...sessionInfo } = session;
|
|
15
|
+
const accessToken = altToken ?? session.accessToken;
|
|
16
|
+
return {
|
|
17
|
+
// pass original token info to form the correlated microhash
|
|
18
|
+
...toTokenInfo(providerId, sessionToken, sessionInfo),
|
|
19
|
+
// use the actual token used for the request
|
|
20
|
+
accessToken: accessToken,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export const CloudIntegrationAuthenticationUriPathPrefix = 'did-authenticate-cloud-integration';
|
|
24
|
+
/** Returns all supported cloud integration ids. */
|
|
25
|
+
export function getSupportedCloudIntegrationIds() {
|
|
26
|
+
// Return the shared const directly (readonly so callers can't mutate it) — this runs on hot,
|
|
27
|
+
// per-integration membership paths, so avoid allocating a fresh array per call.
|
|
28
|
+
return supportedOrderedCloudIntegrationIds;
|
|
29
|
+
}
|
|
30
|
+
/** Whether `id` is a supported cloud integration id. */
|
|
31
|
+
export function isSupportedCloudIntegrationId(id) {
|
|
32
|
+
return getSupportedCloudIntegrationIds().includes(id);
|
|
33
|
+
}
|
|
34
|
+
export function isIssueCloudIntegrationId(id) {
|
|
35
|
+
const issueIds = Object.values(IssuesCloudHostIntegrationId);
|
|
36
|
+
return issueIds.includes(id);
|
|
37
|
+
}
|
|
38
|
+
export const toIntegrationId = {
|
|
39
|
+
jira: IssuesCloudHostIntegrationId.Jira,
|
|
40
|
+
linear: IssuesCloudHostIntegrationId.Linear,
|
|
41
|
+
trello: IssuesCloudHostIntegrationId.Trello,
|
|
42
|
+
gitlab: GitCloudHostIntegrationId.GitLab,
|
|
43
|
+
github: GitCloudHostIntegrationId.GitHub,
|
|
44
|
+
githubEnterprise: GitSelfManagedHostIntegrationId.CloudGitHubEnterprise,
|
|
45
|
+
gitlabSelfHosted: GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted,
|
|
46
|
+
bitbucket: GitCloudHostIntegrationId.Bitbucket,
|
|
47
|
+
bitbucketServer: GitSelfManagedHostIntegrationId.BitbucketServer,
|
|
48
|
+
azure: GitCloudHostIntegrationId.AzureDevOps,
|
|
49
|
+
azureDevopsServer: GitSelfManagedHostIntegrationId.AzureDevOpsServer,
|
|
50
|
+
};
|
|
51
|
+
export const toCloudIntegrationType = {
|
|
52
|
+
[IssuesCloudHostIntegrationId.Jira]: 'jira',
|
|
53
|
+
[IssuesCloudHostIntegrationId.Linear]: 'linear',
|
|
54
|
+
[IssuesCloudHostIntegrationId.Trello]: 'trello',
|
|
55
|
+
[GitCloudHostIntegrationId.GitLab]: 'gitlab',
|
|
56
|
+
[GitCloudHostIntegrationId.GitHub]: 'github',
|
|
57
|
+
[GitCloudHostIntegrationId.Bitbucket]: 'bitbucket',
|
|
58
|
+
[GitCloudHostIntegrationId.AzureDevOps]: 'azure',
|
|
59
|
+
[GitSelfManagedHostIntegrationId.AzureDevOpsServer]: 'azureDevopsServer',
|
|
60
|
+
[GitSelfManagedHostIntegrationId.CloudGitHubEnterprise]: 'githubEnterprise',
|
|
61
|
+
[GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted]: 'gitlabSelfHosted',
|
|
62
|
+
[GitSelfManagedHostIntegrationId.BitbucketServer]: 'bitbucketServer',
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/authentication/models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EACN,yBAAyB,EACzB,+BAA+B,EAC/B,4BAA4B,EAC5B,mCAAmC,GACnC,MAAM,iBAAiB,CAAC;AAwCzB,MAAM,UAAU,WAAW,CAC1B,UAAa,EACb,WAA+B,EAC/B,IAAkH;IAElH,OAAO;QACN,UAAU,EAAE,UAAU;QACtB,SAAS,EAAE,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;QACpC,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,SAAS,EAAE,IAAI,CAAC,SAAS;KACzB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAC9B,UAAa,EACb,OAAsC,EACtC,QAAiB;IAEjB,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,CAAC;IAC9D,MAAM,WAAW,GAAG,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC;IACpD,OAAO;QACN,4DAA4D;QAC5D,GAAG,WAAW,CAAC,UAAU,EAAE,YAAY,EAAE,WAAW,CAAC;QACrD,4CAA4C;QAC5C,WAAW,EAAE,WAAW;KACxB,CAAC;AACH,CAAC;AA+CD,MAAM,CAAC,MAAM,2CAA2C,GAAG,oCAAoC,CAAC;AAEhG,mDAAmD;AACnD,MAAM,UAAU,+BAA+B;IAC9C,6FAA6F;IAC7F,gFAAgF;IAChF,OAAO,mCAAmC,CAAC;AAC5C,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,6BAA6B,CAA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