@gitkraken/core-gitlens 0.52.0 → 0.53.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 +8 -1
- package/dist/_types/provider-apis/types/exportedTypes/github.d.ts +75 -0
- package/dist/_types/provider-apis/types/exportedTypes/types.d.ts +7 -0
- package/dist/plus/git-github/api/issueWrites.js +1 -1
- package/dist/plus/git-github/api/issueWrites.js.map +1 -1
- package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.d.ts +5 -1
- package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js +44 -20
- package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js.map +1 -1
- package/dist/plus/integrations/authentication/cloudIntegrationObservations.d.ts +49 -0
- package/dist/plus/integrations/authentication/cloudIntegrationObservations.js +118 -0
- package/dist/plus/integrations/authentication/cloudIntegrationObservations.js.map +1 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +38 -25
- package/dist/plus/integrations/authentication/configuredIntegrationService.js +376 -141
- package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
- package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts +8 -2
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js +34 -4
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -1
- package/dist/plus/integrations/authentication/models.d.ts +6 -0
- package/dist/plus/integrations/authentication/models.js +9 -1
- package/dist/plus/integrations/authentication/models.js.map +1 -1
- package/dist/plus/integrations/authentication/observedAuthenticationProvider.d.ts +13 -2
- package/dist/plus/integrations/authentication/observedAuthenticationProvider.js +68 -30
- package/dist/plus/integrations/authentication/observedAuthenticationProvider.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +2 -1
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +8 -0
- package/dist/plus/integrations/integrationService.js +148 -36
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +3 -0
- package/dist/plus/integrations/models/integration.d.ts +4 -0
- package/dist/plus/integrations/models/integration.js +61 -16
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/models/issueRelationships.d.ts +31 -0
- package/dist/plus/integrations/models/issueRelationships.js +0 -0
- package/dist/plus/integrations/models/publicIntegration.d.ts +0 -1
- package/dist/plus/integrations/providers/github.d.ts +8 -0
- package/dist/plus/integrations/providers/github.js +162 -2
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +0 -1
- package/dist/plus/integrations/providers/providerApiClient.d.ts +1 -1
- package/dist/plus/integrations/providers/providerApiClient.js +33 -14
- package/dist/plus/integrations/providers/providerApiClient.js.map +1 -1
- package/dist/plus/integrations/providers/providerErrors.d.ts +1 -0
- package/dist/plus/integrations/providers/providerErrors.js +1 -2
- package/dist/plus/integrations/providers/providerErrors.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.d.ts +2 -1
- package/dist/plus/integrations/providers/providersApi.js +2 -0
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/plus/integrations/reads/drains.d.ts +0 -1
- package/docs/integrations.md +36 -0
- package/package.json +2 -2
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { chunk } from "../../../utils/array.js";
|
|
2
|
+
import { isCancellationError } from "../../../utils/cancellation.js";
|
|
2
3
|
import { batch, mapBounded, mapSettledBounded } from "../../../utils/promise.js";
|
|
3
4
|
import { AuthenticationError, RequestNotFoundError } from "../../../git/errors.js";
|
|
4
5
|
import { parseGitRemoteUrl } from "../../../git/utils/remote.utils.js";
|
|
5
6
|
import { getGitHubNoReplyAddressParts } from "../../../git/remotes/github.js";
|
|
7
|
+
import { uuid } from "../../../utils/crypto.js";
|
|
6
8
|
import "../../../git/models/pullRequest.js";
|
|
7
9
|
import { decodeGitHubCheckRunId, fromGitHubCheckContextState, fromGitHubIssueOrPullRequestState, fromGitHubMergeQueueEntryState, fromGitHubMergeQueueRemoval, fromGitHubPullRequestMergeableState, fromGitHubPullRequestReviewDecision, fromGitHubPullRequestStatusCheckRollupState, toGitHubCheckRunId } from "../../git-github/models.js";
|
|
8
10
|
import { IntegrationReadUnavailableError } from "../errors.js";
|
|
@@ -11,9 +13,10 @@ import { toCollectionScopeFailure } from "../collectionMetadata.js";
|
|
|
11
13
|
import "../providerFilters.js";
|
|
12
14
|
import { resolveBranchPullRequests } from "./utils/providerPaging.js";
|
|
13
15
|
import { providersMetadata } from "./metadata.js";
|
|
14
|
-
import { areDomainsOnSameHostname, isWebRemoteScheme } from "../utils/domain.utils.js";
|
|
16
|
+
import { areDomainsOnSameHostname, isWebRemoteScheme, matchesInstallationOrigin } from "../utils/domain.utils.js";
|
|
15
17
|
import { getGitHubEnterprisePullRequestWriteOrigin } from "../utils/integration.utils.js";
|
|
16
|
-
import { getSessionIdentity, toTokenWithInfo } from "../authentication/models.js";
|
|
18
|
+
import { getSessionIdentity, isSameAuthenticationSession, toTokenWithInfo } from "../authentication/models.js";
|
|
19
|
+
import { ObservedAuthenticationProvider } from "../authentication/observedAuthenticationProvider.js";
|
|
17
20
|
import { getProviderPullRequestIdentity, stampNativePullRequest } from "./models.js";
|
|
18
21
|
import { pullRequestCheckRunsEtag } from "../reads/etag.js";
|
|
19
22
|
import "../../git-github/api/aliasedQuery.js";
|
|
@@ -1019,6 +1022,9 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
|
|
|
1019
1022
|
return getGitHubPullRequestIdentityFromMaybeUrl(search, this.id);
|
|
1020
1023
|
}
|
|
1021
1024
|
};
|
|
1025
|
+
function isSelectedRelationshipSession(session, connectionId) {
|
|
1026
|
+
return session?.id === connectionId && Boolean(session.accessToken) && matchesInstallationOrigin(session.domain, "https://github.com") && (session.baseUrl == null || matchesInstallationOrigin(session.baseUrl, "https://github.com"));
|
|
1027
|
+
}
|
|
1022
1028
|
var GitHubIntegration = class extends GitHubIntegrationBase {
|
|
1023
1029
|
authProvider = authProvider;
|
|
1024
1030
|
id = "github";
|
|
@@ -1027,6 +1033,160 @@ var GitHubIntegration = class extends GitHubIntegrationBase {
|
|
|
1027
1033
|
get domain() {
|
|
1028
1034
|
return metadata.domain;
|
|
1029
1035
|
}
|
|
1036
|
+
relationshipCredentials = /* @__PURE__ */ new Map();
|
|
1037
|
+
dispose() {
|
|
1038
|
+
this.relationshipCredentials.clear();
|
|
1039
|
+
super.dispose();
|
|
1040
|
+
}
|
|
1041
|
+
getIssueRelationships(options, isHostSessionCurrent, captureCurrency) {
|
|
1042
|
+
return this.withRelationshipSession(options, false, isHostSessionCurrent, captureCurrency, async (api, credentials, proof) => {
|
|
1043
|
+
const result = await api.getIssueRelationships(options, credentials);
|
|
1044
|
+
return result.ok ? {
|
|
1045
|
+
...result,
|
|
1046
|
+
connectionProof: proof
|
|
1047
|
+
} : result;
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
writeIssueRelationship(options, isHostSessionCurrent, captureCurrency) {
|
|
1051
|
+
return this.withRelationshipSession(options, true, isHostSessionCurrent, captureCurrency, (api, credentials) => api.writeIssueRelationship(options, credentials));
|
|
1052
|
+
}
|
|
1053
|
+
async withRelationshipSession(options, write, isHostSessionCurrent, captureCurrency, run) {
|
|
1054
|
+
const notSent = write ? {
|
|
1055
|
+
mutationDispatched: false,
|
|
1056
|
+
outcome: "not-sent"
|
|
1057
|
+
} : {};
|
|
1058
|
+
const disconnected = {
|
|
1059
|
+
ok: false,
|
|
1060
|
+
reason: "no-connection",
|
|
1061
|
+
...notSent
|
|
1062
|
+
};
|
|
1063
|
+
const { connectionId, expectedLogin } = options;
|
|
1064
|
+
const credential = await this.getRelationshipCredential(options).catch((ex) => isCancellationError(ex) ? void 0 : issueWriteFailure(ex));
|
|
1065
|
+
if (credential == null) return disconnected;
|
|
1066
|
+
if ("reason" in credential) return {
|
|
1067
|
+
...credential,
|
|
1068
|
+
...notSent
|
|
1069
|
+
};
|
|
1070
|
+
const isCurrent = () => credential.guard.isCurrent() && (isHostSessionCurrent == null || isHostSessionCurrent()) && this.isIntegrationAccessEnabled() && this.relationshipCredentials.get(connectionId) === credential;
|
|
1071
|
+
const isSessionCurrent = async () => isCurrent() && await credential.guard.verify() && isCurrent();
|
|
1072
|
+
let unauthorized = false;
|
|
1073
|
+
const onUnauthorized = () => {
|
|
1074
|
+
unauthorized = true;
|
|
1075
|
+
};
|
|
1076
|
+
const token = credential.session.accessToken;
|
|
1077
|
+
let sdkStarted = false;
|
|
1078
|
+
let result;
|
|
1079
|
+
try {
|
|
1080
|
+
const api = (await this.getProvidersApi()).githubRelationships;
|
|
1081
|
+
if (!await isSessionCurrent() || !isCurrent()) return disconnected;
|
|
1082
|
+
captureCurrency?.(isCurrent);
|
|
1083
|
+
const viewerFailure = expectedLogin === void 0 ? void 0 : await this.checkRelationshipLogin(credential.session, expectedLogin, isCurrent, onUnauthorized);
|
|
1084
|
+
if (viewerFailure != null) result = {
|
|
1085
|
+
ok: false,
|
|
1086
|
+
reason: viewerFailure,
|
|
1087
|
+
...notSent
|
|
1088
|
+
};
|
|
1089
|
+
else if ((expectedLogin === void 0 || await isSessionCurrent()) && isCurrent()) {
|
|
1090
|
+
sdkStarted = true;
|
|
1091
|
+
result = await run(api, {
|
|
1092
|
+
token,
|
|
1093
|
+
isSessionCurrent,
|
|
1094
|
+
isSessionCurrentNow: isCurrent,
|
|
1095
|
+
onUnauthorized
|
|
1096
|
+
}, credential.proof);
|
|
1097
|
+
} else result = disconnected;
|
|
1098
|
+
} catch (ex) {
|
|
1099
|
+
result = sdkStarted && write ? {
|
|
1100
|
+
ok: false,
|
|
1101
|
+
reason: "unknown",
|
|
1102
|
+
outcome: "unconfirmed"
|
|
1103
|
+
} : {
|
|
1104
|
+
...issueWriteFailure(ex),
|
|
1105
|
+
...notSent
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
const verified = await isSessionCurrent().catch((ex) => isCancellationError(ex) ? false : issueWriteFailure(ex));
|
|
1109
|
+
const current = isCurrent();
|
|
1110
|
+
if (verified !== true || !current) {
|
|
1111
|
+
const lookupFailure = current && typeof verified === "object" ? verified : void 0;
|
|
1112
|
+
if (lookupFailure != null && !result.ok) return unauthorized && !write ? {
|
|
1113
|
+
...result,
|
|
1114
|
+
reason: "no-connection"
|
|
1115
|
+
} : result;
|
|
1116
|
+
if (!write || !sdkStarted) return lookupFailure != null ? {
|
|
1117
|
+
...lookupFailure,
|
|
1118
|
+
...notSent
|
|
1119
|
+
} : disconnected;
|
|
1120
|
+
if (!result.ok) return result.mutationDispatched === false ? {
|
|
1121
|
+
...result,
|
|
1122
|
+
reason: "no-connection"
|
|
1123
|
+
} : result;
|
|
1124
|
+
return {
|
|
1125
|
+
ok: false,
|
|
1126
|
+
reason: lookupFailure?.reason ?? "unknown",
|
|
1127
|
+
outcome: "unconfirmed",
|
|
1128
|
+
..."previousParent" in result && result.previousParent != null && {
|
|
1129
|
+
phase: "attach",
|
|
1130
|
+
detached: true
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
if (unauthorized) {
|
|
1135
|
+
this.handleConnectionAuthenticationRejection(connectionId, true, token);
|
|
1136
|
+
if (!result.ok) return {
|
|
1137
|
+
...result,
|
|
1138
|
+
reason: "no-connection"
|
|
1139
|
+
};
|
|
1140
|
+
}
|
|
1141
|
+
return result;
|
|
1142
|
+
}
|
|
1143
|
+
async checkRelationshipLogin(session, expectedLogin, isCurrent, onUnauthorized) {
|
|
1144
|
+
const github = await this.authenticationService.apis.github;
|
|
1145
|
+
if (github == null) return "unsupported";
|
|
1146
|
+
if (!isCurrent()) return "no-connection";
|
|
1147
|
+
const login = await github.getWriteViewer(this, toTokenWithInfo(this.id, session), void 0, onUnauthorized);
|
|
1148
|
+
if (!login) return "unknown";
|
|
1149
|
+
return login.toLowerCase() === expectedLogin.toLowerCase() ? void 0 : "no-connection";
|
|
1150
|
+
}
|
|
1151
|
+
async getRelationshipCredential({ connectionId, expectedConnectionProof }) {
|
|
1152
|
+
const selectionCurrent = await this.authenticationService.captureConfiguredConnection(this.id, connectionId);
|
|
1153
|
+
if (!selectionCurrent?.()) return void 0;
|
|
1154
|
+
const cached = this.relationshipCredentials.get(connectionId);
|
|
1155
|
+
if (expectedConnectionProof != null && cached?.proof !== expectedConnectionProof) return void 0;
|
|
1156
|
+
const provider = await this.authenticationService.get(this.id);
|
|
1157
|
+
const descriptor = {
|
|
1158
|
+
...this.authProviderDescriptor,
|
|
1159
|
+
connectionId,
|
|
1160
|
+
cloud: true
|
|
1161
|
+
};
|
|
1162
|
+
const observe = provider instanceof ObservedAuthenticationProvider ? provider.captureRelationshipSession(descriptor) : void 0;
|
|
1163
|
+
let session = await this.resolveReadSessionOrThrow(connectionId, void 0);
|
|
1164
|
+
if (!isSelectedRelationshipSession(session, connectionId)) return void 0;
|
|
1165
|
+
if (cached?.guard.isCurrent() && isSameAuthenticationSession(cached.session, session) && await cached.guard.verify()) return cached;
|
|
1166
|
+
if (expectedConnectionProof != null) return void 0;
|
|
1167
|
+
let observed = observe?.(session);
|
|
1168
|
+
if (observed?.isRetired() && provider instanceof ObservedAuthenticationProvider) {
|
|
1169
|
+
const accountId = session.account.id;
|
|
1170
|
+
const capture = provider.captureRelationshipSession(descriptor);
|
|
1171
|
+
session = await this.resolveReadSessionOrThrow(connectionId, void 0);
|
|
1172
|
+
if (!isSelectedRelationshipSession(session, connectionId) || session.account.id !== accountId) return;
|
|
1173
|
+
observed = capture(session);
|
|
1174
|
+
}
|
|
1175
|
+
const guard = observed == null ? await this.authenticationService.trackStoredRelationshipSession(this.id, session) : {
|
|
1176
|
+
isCurrent: () => selectionCurrent() && observed.isCurrent(),
|
|
1177
|
+
verify: observed.verify
|
|
1178
|
+
};
|
|
1179
|
+
if (!selectionCurrent() || !guard?.isCurrent()) return void 0;
|
|
1180
|
+
const latest = this.relationshipCredentials.get(connectionId);
|
|
1181
|
+
if (latest !== cached) return latest?.guard.isCurrent() && isSameAuthenticationSession(latest.session, session) ? latest : void 0;
|
|
1182
|
+
const credential = {
|
|
1183
|
+
proof: uuid(),
|
|
1184
|
+
session,
|
|
1185
|
+
guard
|
|
1186
|
+
};
|
|
1187
|
+
this.relationshipCredentials.set(connectionId, credential);
|
|
1188
|
+
return credential;
|
|
1189
|
+
}
|
|
1030
1190
|
apiBaseUrlFor(_session) {}
|
|
1031
1191
|
access() {
|
|
1032
1192
|
return Promise.resolve(true);
|