@codingame/monaco-vscode-extension-gallery-service-override 38.1.3 → 39.0.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.
Files changed (20) hide show
  1. package/package.json +2 -2
  2. package/session.js +0 -1
  3. package/vscode/src/vs/platform/extensionManagement/common/abstractExtensionManagementService.js +25 -16
  4. package/vscode/src/vs/platform/extensionManagement/common/allowedExtensionsService.js +5 -5
  5. package/vscode/src/vs/platform/extensionManagement/common/extensionGalleryManifestService.d.ts +4 -0
  6. package/vscode/src/vs/platform/extensionManagement/common/extensionGalleryManifestService.js +19 -0
  7. package/vscode/src/vs/platform/extensionManagement/common/extensionGalleryService.d.ts +20 -1
  8. package/vscode/src/vs/platform/extensionManagement/common/extensionGalleryService.js +67 -24
  9. package/vscode/src/vs/platform/extensionManagement/common/extensionTipsService.js +1 -0
  10. package/vscode/src/vs/workbench/contrib/extensions/browser/abstractRuntimeExtensionsEditor.js +19 -18
  11. package/vscode/src/vs/workbench/contrib/extensions/browser/extensions.web.contribution.js +1 -1
  12. package/vscode/src/vs/workbench/contrib/extensions/common/reportExtensionIssueAction.js +1 -1
  13. package/vscode/src/vs/workbench/contrib/extensions/common/runtimeExtensionsInput.js +2 -2
  14. package/vscode/src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.d.ts +12 -1
  15. package/vscode/src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.js +58 -24
  16. package/vscode/src/vs/workbench/services/extensionManagement/common/extensionFeaturesManagemetService.js +4 -4
  17. package/vscode/src/vs/workbench/services/extensionManagement/common/extensionManagementServerService.js +2 -2
  18. package/vscode/src/vs/workbench/services/extensionManagement/common/extensionManagementService.js +46 -46
  19. package/vscode/src/vs/sessions/contrib/extensions/browser/extensions.contribution.d.ts +0 -1
  20. package/vscode/src/vs/sessions/contrib/extensions/browser/extensions.contribution.js +0 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-extension-gallery-service-override",
3
- "version": "38.1.3",
3
+ "version": "39.0.0",
4
4
  "private": false,
5
5
  "description": "VSCode public API plugged on the monaco editor - extension-gallery service-override",
6
6
  "keywords": [],
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "type": "module",
17
17
  "dependencies": {
18
- "@codingame/monaco-vscode-api": "38.1.3"
18
+ "@codingame/monaco-vscode-api": "39.0.0"
19
19
  },
20
20
  "main": "index.js",
21
21
  "module": "index.js",
package/session.js CHANGED
@@ -2,7 +2,6 @@
2
2
  import { IExtensionRecommendationNotificationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionRecommendations/common/extensionRecommendations.service';
3
3
  import { SyncDescriptor } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/descriptors';
4
4
  import getServiceOverride$1 from './common.js';
5
- import './vscode/src/vs/sessions/contrib/extensions/browser/extensions.contribution.js';
6
5
  import { NullExtensionRecommendationNotificationService } from './vscode/src/vs/sessions/services/extensionRecommendations/common/extensionRecommendationNotificationService.js';
7
6
 
8
7
  function getServiceOverride({ webOnly = false, transformExtensionGalleryManifest } = {}) {
@@ -12,7 +12,7 @@ import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
12
12
  import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
13
13
  import { TargetPlatformToString, isTargetPlatformCompatible, ExtensionManagementError, ExtensionManagementErrorCode, InstallOperation, EXTENSION_INSTALL_DEP_PACK_CONTEXT, EXTENSION_INSTALL_SOURCE_CONTEXT, StatisticType, ExtensionGalleryError, ExtensionGalleryErrorCode, ExtensionSignatureVerificationCode } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagement';
14
14
  import { IAllowedExtensionsService, IExtensionGalleryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagement.service';
15
- import { areSameExtensions, ExtensionKey, getGalleryExtensionId, getGalleryExtensionTelemetryData, isMalicious, getLocalExtensionTelemetryData } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagementUtil';
15
+ import { getExtensionBlockedMessage, areSameExtensions, ExtensionKey, getGalleryExtensionId, getGalleryExtensionTelemetryData, isMalicious, getLocalExtensionTelemetryData } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagementUtil';
16
16
  import { isApplicationScopedExtension, ExtensionType } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensions/common/extensions';
17
17
  import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
18
18
  import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
@@ -29,13 +29,16 @@ let CommontExtensionManagementService = class CommontExtensionManagementService
29
29
  this.preferPreReleases = this.productService.quality !== "stable";
30
30
  }
31
31
  async canInstall(extension) {
32
+ if (extension.blockingInfo) {
33
+ return getExtensionBlockedMessage(extension.blockingInfo);
34
+ }
32
35
  const allowedToInstall = this.allowedExtensionsService.isAllowed({
33
36
  id: extension.identifier.id,
34
37
  publisherDisplayName: extension.publisherDisplayName
35
38
  });
36
39
  if (allowedToInstall !== true) {
37
40
  return (new MarkdownString(localize(
38
- 2598,
41
+ 2803,
39
42
  "This extension cannot be installed because {0}",
40
43
  allowedToInstall.value
41
44
  )));
@@ -43,12 +46,12 @@ let CommontExtensionManagementService = class CommontExtensionManagementService
43
46
  if (!(await this.isExtensionPlatformCompatible(extension))) {
44
47
  const learnLink = isWeb ? "https://aka.ms/vscode-web-extensions-guide" : "https://aka.ms/vscode-platform-specific-extensions";
45
48
  return (new MarkdownString(`${( localize(
46
- 2599,
49
+ 2804,
47
50
  "The '{0}' extension is not available in {1} for the {2} platform.",
48
51
  extension.displayName ?? extension.identifier.id,
49
52
  this.productService.nameLong,
50
53
  TargetPlatformToString(await this.getTargetPlatform())
51
- ))} [${( localize(2600, "Learn Why"))}](${learnLink})`));
54
+ ))} [${( localize(2805, "Learn Why"))}](${learnLink})`));
52
55
  }
53
56
  return true;
54
57
  }
@@ -145,7 +148,7 @@ let AbstractExtensionManagementService = class AbstractExtensionManagementServic
145
148
  }
146
149
  async installGalleryExtensions(extensions) {
147
150
  if (!this.galleryService.isEnabled()) {
148
- throw ( new ExtensionManagementError(( localize(2601, "Marketplace is not enabled")), ExtensionManagementErrorCode.NotAllowed));
151
+ throw ( new ExtensionManagementError(( localize(2806, "Marketplace is not enabled")), ExtensionManagementErrorCode.NotAllowed));
149
152
  }
150
153
  const results = [];
151
154
  const installableExtensions = [];
@@ -832,7 +835,7 @@ let AbstractExtensionManagementService = class AbstractExtensionManagementServic
832
835
  const extensionsControlManifest = await this.getExtensionsControlManifest();
833
836
  if (isMalicious(extension.identifier, extensionsControlManifest.malicious)) {
834
837
  throw ( new ExtensionManagementError(( localize(
835
- 2602,
838
+ 2807,
836
839
  "Can't install '{0}' extension since it was reported to be problematic.",
837
840
  extension.identifier.id
838
841
  )), ExtensionManagementErrorCode.Malicious));
@@ -852,17 +855,23 @@ let AbstractExtensionManagementService = class AbstractExtensionManagementServic
852
855
  }, CancellationToken.None))[0];
853
856
  if (!compatibleExtension) {
854
857
  throw ( new ExtensionManagementError(( localize(
855
- 2603,
858
+ 2808,
856
859
  "Can't install '{0}' extension since it was deprecated and the replacement extension '{1}' can't be found.",
857
860
  extension.identifier.id,
858
861
  deprecationInfo.extension.id
859
862
  )), ExtensionManagementErrorCode.Deprecated));
860
863
  }
861
864
  } else {
865
+ if (extension.blockingInfo) {
866
+ throw ( new ExtensionManagementError(
867
+ getExtensionBlockedMessage(extension.blockingInfo).value,
868
+ ExtensionManagementErrorCode.NotAllowed
869
+ ));
870
+ }
862
871
  if ((await this.canInstall(extension)) !== true) {
863
872
  const targetPlatform = await this.getTargetPlatform();
864
873
  throw ( new ExtensionManagementError(( localize(
865
- 2599,
874
+ 2804,
866
875
  "The '{0}' extension is not available in {1} for the {2} platform.",
867
876
  extension.identifier.id,
868
877
  this.productService.nameLong,
@@ -873,13 +882,13 @@ let AbstractExtensionManagementService = class AbstractExtensionManagementServic
873
882
  if (!compatibleExtension) {
874
883
  if (!installPreRelease && extension.hasPreReleaseVersion && extension.properties.isPreReleaseVersion && (await this.galleryService.getExtensions([extension.identifier], CancellationToken.None))[0]) {
875
884
  throw ( new ExtensionManagementError(( localize(
876
- 2604,
885
+ 2809,
877
886
  "Can't install release version of '{0}' extension because it has no release version.",
878
887
  extension.displayName ?? extension.identifier.id
879
888
  )), ExtensionManagementErrorCode.ReleaseVersionNotFound));
880
889
  }
881
890
  throw ( new ExtensionManagementError(( localize(
882
- 2605,
891
+ 2810,
883
892
  "Can't install '{0}' extension because it is not compatible with the current version of {1} (version {2}).",
884
893
  extension.identifier.id,
885
894
  this.productService.nameLong,
@@ -1199,7 +1208,7 @@ let AbstractExtensionManagementService = class AbstractExtensionManagementServic
1199
1208
  if (extensionToUninstall === dependingExtension) {
1200
1209
  if (dependents.length === 1) {
1201
1210
  return localize(
1202
- 2606,
1211
+ 2811,
1203
1212
  "Cannot uninstall '{0}' extension. '{1}' extension depends on this.",
1204
1213
  extensionToUninstall.manifest.displayName || extensionToUninstall.manifest.name,
1205
1214
  dependents[0].manifest.displayName || dependents[0].manifest.name
@@ -1207,7 +1216,7 @@ let AbstractExtensionManagementService = class AbstractExtensionManagementServic
1207
1216
  }
1208
1217
  if (dependents.length === 2) {
1209
1218
  return localize(
1210
- 2607,
1219
+ 2812,
1211
1220
  "Cannot uninstall '{0}' extension. '{1}' and '{2}' extensions depend on this.",
1212
1221
  extensionToUninstall.manifest.displayName || extensionToUninstall.manifest.name,
1213
1222
  dependents[0].manifest.displayName || dependents[0].manifest.name,
@@ -1215,7 +1224,7 @@ let AbstractExtensionManagementService = class AbstractExtensionManagementServic
1215
1224
  );
1216
1225
  }
1217
1226
  return localize(
1218
- 2608,
1227
+ 2813,
1219
1228
  "Cannot uninstall '{0}' extension. '{1}', '{2}' and other extension depend on this.",
1220
1229
  extensionToUninstall.manifest.displayName || extensionToUninstall.manifest.name,
1221
1230
  dependents[0].manifest.displayName || dependents[0].manifest.name,
@@ -1224,7 +1233,7 @@ let AbstractExtensionManagementService = class AbstractExtensionManagementServic
1224
1233
  }
1225
1234
  if (dependents.length === 1) {
1226
1235
  return localize(
1227
- 2609,
1236
+ 2814,
1228
1237
  "Cannot uninstall '{0}' extension . It includes uninstalling '{1}' extension and '{2}' extension depends on this.",
1229
1238
  extensionToUninstall.manifest.displayName || extensionToUninstall.manifest.name,
1230
1239
  dependingExtension.manifest.displayName || dependingExtension.manifest.name,
@@ -1233,7 +1242,7 @@ let AbstractExtensionManagementService = class AbstractExtensionManagementServic
1233
1242
  }
1234
1243
  if (dependents.length === 2) {
1235
1244
  return localize(
1236
- 2610,
1245
+ 2815,
1237
1246
  "Cannot uninstall '{0}' extension. It includes uninstalling '{1}' extension and '{2}' and '{3}' extensions depend on this.",
1238
1247
  extensionToUninstall.manifest.displayName || extensionToUninstall.manifest.name,
1239
1248
  dependingExtension.manifest.displayName || dependingExtension.manifest.name,
@@ -1242,7 +1251,7 @@ let AbstractExtensionManagementService = class AbstractExtensionManagementServic
1242
1251
  );
1243
1252
  }
1244
1253
  return localize(
1245
- 2611,
1254
+ 2816,
1246
1255
  "Cannot uninstall '{0}' extension. It includes uninstalling '{1}' extension and '{2}', '{3}' and other extensions depend on this.",
1247
1256
  extensionToUninstall.manifest.displayName || extensionToUninstall.manifest.name,
1248
1257
  dependingExtension.manifest.displayName || dependingExtension.manifest.name,
@@ -77,14 +77,14 @@ let AllowedExtensionsService = class AllowedExtensionsService extends Disposable
77
77
  query: `@id:${AllowedExtensionsConfigKey}`
78
78
  }).toString());
79
79
  const extensionValue = this._allowedExtensionsConfigValue[id];
80
- const extensionReason = ( new MarkdownString(( localize(2612, "it is not in the [allowed list]({0})", settingsCommandLink))));
80
+ const extensionReason = ( new MarkdownString(( localize(2817, "it is not in the [allowed list]({0})", settingsCommandLink))));
81
81
  if (!isUndefined(extensionValue)) {
82
82
  if (isBoolean(extensionValue)) {
83
83
  return extensionValue ? true : extensionReason;
84
84
  }
85
85
  if (extensionValue === "stable" && prerelease) {
86
86
  return (new MarkdownString(localize(
87
- 2613,
87
+ 2818,
88
88
  "the pre-release versions of this extension are not in the [allowed list]({0})",
89
89
  settingsCommandLink
90
90
  )));
@@ -107,7 +107,7 @@ let AllowedExtensionsService = class AllowedExtensionsService extends Disposable
107
107
  return false;
108
108
  }))) {
109
109
  return (new MarkdownString(localize(
110
- 2614,
110
+ 2819,
111
111
  "the version {0} of this extension is not in the [allowed list]({1})",
112
112
  version,
113
113
  settingsCommandLink
@@ -120,7 +120,7 @@ let AllowedExtensionsService = class AllowedExtensionsService extends Disposable
120
120
  if (!isUndefined(publisherValue)) {
121
121
  if (isBoolean(publisherValue)) {
122
122
  return publisherValue ? true : ( new MarkdownString(( localize(
123
- 2615,
123
+ 2820,
124
124
  "the extensions from this publisher are not in the [allowed list]({1})",
125
125
  publisherKey,
126
126
  settingsCommandLink
@@ -128,7 +128,7 @@ let AllowedExtensionsService = class AllowedExtensionsService extends Disposable
128
128
  }
129
129
  if (publisherValue === "stable" && prerelease) {
130
130
  return (new MarkdownString(localize(
131
- 2616,
131
+ 2821,
132
132
  "the pre-release versions from this publisher are not in the [allowed list]({1})",
133
133
  publisherKey,
134
134
  settingsCommandLink
@@ -8,7 +8,11 @@ export declare class ExtensionGalleryManifestService extends Disposable implemen
8
8
  readonly _serviceBrand: undefined;
9
9
  readonly onDidChangeExtensionGalleryManifest: Event<any>;
10
10
  readonly onDidChangeExtensionGalleryManifestStatus: Event<any>;
11
+ protected extensionGalleryAccessToken: string | undefined;
12
+ protected extensionGalleryServiceIndexUrl: string | undefined;
11
13
  get extensionGalleryManifestStatus(): ExtensionGalleryManifestStatus;
12
14
  constructor(productService: IProductService);
13
15
  getExtensionGalleryManifest(): Promise<IExtensionGalleryManifest | null>;
16
+ getAccessToken(targetUrl: string): Promise<string | undefined>;
17
+ protected setAuthorization(accessToken: string | undefined, serviceIndexUrl: string | undefined): void;
14
18
  }
@@ -2,6 +2,7 @@
2
2
  import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
3
  import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
4
4
  import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
5
+ import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
5
6
  import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
6
7
  import { ExtensionGalleryManifestStatus, ExtensionGalleryResourceType, Flag } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionGalleryManifest';
7
8
  import { FilterType, SortBy } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagement';
@@ -161,6 +162,24 @@ let ExtensionGalleryManifestService = class ExtensionGalleryManifestService exte
161
162
  }
162
163
  };
163
164
  }
165
+ async getAccessToken(targetUrl) {
166
+ const accessToken = this.extensionGalleryAccessToken;
167
+ const serviceIndexUrl = this.extensionGalleryServiceIndexUrl;
168
+ if (!accessToken || !serviceIndexUrl) {
169
+ return undefined;
170
+ }
171
+ try {
172
+ const target = ( URI.parse(targetUrl));
173
+ const serviceIndex = ( URI.parse(serviceIndexUrl));
174
+ return target.scheme === "https" && serviceIndex.scheme === "https" && target.authority.toLowerCase() === serviceIndex.authority.toLowerCase() ? accessToken : undefined;
175
+ } catch {
176
+ return undefined;
177
+ }
178
+ }
179
+ setAuthorization(accessToken, serviceIndexUrl) {
180
+ this.extensionGalleryAccessToken = accessToken;
181
+ this.extensionGalleryServiceIndexUrl = serviceIndexUrl;
182
+ }
164
183
  };
165
184
  ExtensionGalleryManifestService = ( __decorate([( __param(0, IProductService))], ExtensionGalleryManifestService));
166
185
 
@@ -3,7 +3,7 @@ import { IPager } from "@codingame/monaco-vscode-api/vscode/vs/base/common/pagin
3
3
  import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
4
4
  import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
5
5
  import { IEnvironmentService } from "@codingame/monaco-vscode-api/vscode/vs/platform/environment/common/environment.service";
6
- import { IExtensionIdentifier, IExtensionInfo, IGalleryExtension, IGalleryExtensionVersion, InstallOperation, IQueryOptions, IExtensionsControlManifest, ITranslation, StatisticType, IExtensionQueryOptions, IProductVersion } from "@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagement";
6
+ import { IExtensionIdentifier, IExtensionInfo, IGalleryExtension, IGalleryExtensionVersion, InstallOperation, IQueryOptions, IExtensionsControlManifest, ITranslation, StatisticType, IExtensionQueryOptions, IProductVersion, IExtensionBlockingInfo } from "@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagement";
7
7
  import { IAllowedExtensionsService } from "@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagement.service";
8
8
  import { IExtensionGalleryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagement.service";
9
9
  import { IExtensionManifest, TargetPlatform } from "@codingame/monaco-vscode-api/vscode/vs/platform/extensions/common/extensions";
@@ -30,7 +30,25 @@ export interface IRawGalleryExtensionVersion {
30
30
  readonly files?: IRawGalleryExtensionFile[];
31
31
  properties?: IRawGalleryExtensionProperty[];
32
32
  readonly targetPlatform?: string;
33
+ readonly flags?: string;
34
+ readonly blocking?: IRawGalleryExtensionBlocking;
33
35
  }
36
+ /** The blocking metadata this client consumes. The contract carries more, which is ignored. */
37
+ export interface IRawGalleryExtensionBlocking {
38
+ readonly origin?: string;
39
+ }
40
+ /**
41
+ * Reads the blocked state of an extension at a given version. At either granularity the flag and
42
+ * the object are two representations of one fact, so either alone still means blocked: a producer
43
+ * emitting one without the other is defective, and failing safe is the correct response.
44
+ */
45
+ export declare function getBlockingInfo(extension: {
46
+ readonly flags: string;
47
+ readonly blocking?: IRawGalleryExtensionBlocking;
48
+ }, version: {
49
+ readonly flags?: string;
50
+ readonly blocking?: IRawGalleryExtensionBlocking;
51
+ }): IExtensionBlockingInfo | undefined;
34
52
  export declare function sortExtensionVersions(versions: IRawGalleryExtensionVersion[], preferredTargetPlatform: TargetPlatform): IRawGalleryExtensionVersion[];
35
53
  /**
36
54
  * Filters extension versions to return only the relevant versions for a given target platform.
@@ -97,6 +115,7 @@ export declare abstract class AbstractExtensionGalleryService implements IExtens
97
115
  getAllVersions(extensionIdentifier: IExtensionIdentifier): Promise<IGalleryExtensionVersion[]>;
98
116
  getAllCompatibleVersions(extensionIdentifier: IExtensionIdentifier, includePreRelease: boolean, targetPlatform: TargetPlatform): Promise<IGalleryExtensionVersion[]>;
99
117
  private getVersions;
118
+ private getRequestHeaders;
100
119
  private getAsset;
101
120
  getExtensionsControlManifest(): Promise<IExtensionsControlManifest>;
102
121
  private getRequestTimeout;
@@ -11,7 +11,7 @@ import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
11
11
  import { isOfflineError } from '@codingame/monaco-vscode-api/vscode/vs/base/parts/request/common/request';
12
12
  import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
13
13
  import { IEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/platform/environment/common/environment.service';
14
- import { getTargetPlatform, SortOrder, SortBy, FilterType, toTargetPlatform, WEB_EXTENSION_TAG, isTargetPlatformCompatible, EXTENSION_IDENTIFIER_REGEX, ExtensionGalleryError, ExtensionGalleryErrorCode, isNotWebExtensionInWebTargetPlatform, InstallOperation, ExtensionRequestsTimeoutConfigKey } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagement';
14
+ import { getTargetPlatform, SortOrder, SortBy, FilterType, ExtensionBlockingOrigin, toTargetPlatform, WEB_EXTENSION_TAG, isTargetPlatformCompatible, EXTENSION_IDENTIFIER_REGEX, ExtensionGalleryError, ExtensionGalleryErrorCode, isNotWebExtensionInWebTargetPlatform, InstallOperation, ExtensionRequestsTimeoutConfigKey } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagement';
15
15
  import { IAllowedExtensionsService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagement.service';
16
16
  import { adoptToGalleryExtensionId, getGalleryExtensionId, areSameExtensions, getGalleryExtensionTelemetryData } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagementUtil';
17
17
  import { TargetPlatform } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensions/common/extensions';
@@ -57,6 +57,9 @@ const PropertyType = {
57
57
  ExecutesCode: "Microsoft.VisualStudio.Code.ExecutesCode",
58
58
  Private: "PrivateMarketplace"
59
59
  };
60
+ const ExtensionFlag = {
61
+ Blocked: "blocked"
62
+ };
60
63
  const DefaultPageSize = 10;
61
64
  const DefaultQueryState = {
62
65
  pageNumber: 1,
@@ -225,6 +228,28 @@ function isPrivateExtension(version) {
225
228
  const values = version.properties ? version.properties.filter(p => p.key === PropertyType.Private) : [];
226
229
  return values.length > 0 && values[0].value === "true";
227
230
  }
231
+ function getBlockingInfo(extension, version) {
232
+ if (isBlocked(extension.flags, extension.blocking)) {
233
+ return {
234
+ origin: toBlockingOrigin(extension.blocking?.origin)
235
+ };
236
+ }
237
+ if (isBlocked(version.flags, version.blocking)) {
238
+ return {
239
+ origin: toBlockingOrigin(version.blocking?.origin)
240
+ };
241
+ }
242
+ return undefined;
243
+ }
244
+ function isBlocked(flags, blocking) {
245
+ return !!blocking || hasExtensionFlag(flags, ExtensionFlag.Blocked);
246
+ }
247
+ function toBlockingOrigin(origin) {
248
+ return typeof origin === "string" && origin.trim().toLowerCase() === ExtensionBlockingOrigin.Policy ? ExtensionBlockingOrigin.Policy : ExtensionBlockingOrigin.Service;
249
+ }
250
+ function hasExtensionFlag(flags, flag) {
251
+ return !!flags && ( flags.split(",").some(f => f.trim().toLowerCase() === flag));
252
+ }
228
253
  function executesCode(version) {
229
254
  const values = version.properties ? version.properties.filter(p => p.key === PropertyType.ExecutesCode) : [];
230
255
  return values.length > 0 ? values[0].value === "true" : undefined;
@@ -394,6 +419,7 @@ function toExtension(
394
419
  hasPreReleaseVersion: hasPreReleaseForExtension(id, productService) ?? isPreReleaseVersion(latestVersion),
395
420
  hasReleaseVersion: true,
396
421
  private: isPrivateExtension(latestVersion),
422
+ blockingInfo: getBlockingInfo(galleryExtension, version),
397
423
  preview: getIsPreview(galleryExtension.flags),
398
424
  isSigned: !!assets.signature,
399
425
  queryContext,
@@ -540,6 +566,7 @@ let AbstractExtensionGalleryService = class AbstractExtensionGalleryService {
540
566
  version: this.productService.version,
541
567
  date: this.productService.date
542
568
  },
569
+ includeBlockedVersions: options.includeBlockedVersions,
543
570
  isQueryForReleaseVersionFromPreReleaseVersion
544
571
  }, extensionGalleryManifest, token);
545
572
  if (options.source) {
@@ -745,7 +772,8 @@ let AbstractExtensionGalleryService = class AbstractExtensionGalleryService {
745
772
  targetPlatform: extension.properties.targetPlatform,
746
773
  manifestAsset: extension.assets.manifest,
747
774
  engine: extension.properties.engine,
748
- enabledApiProposals: extension.properties.enabledApiProposals
775
+ enabledApiProposals: extension.properties.enabledApiProposals,
776
+ blocked: !!extension.blockingInfo
749
777
  }, {
750
778
  targetPlatform,
751
779
  compatible: true,
@@ -766,6 +794,9 @@ let AbstractExtensionGalleryService = class AbstractExtensionGalleryService {
766
794
  ) {
767
795
  const hasPreRelease = hasPreReleaseForExtension(extension.id, this.productService);
768
796
  const excludeVersionRange = getExcludeVersionRangeForExtension(extension.id, this.productService);
797
+ if (extension.blocked) {
798
+ return false;
799
+ }
769
800
  if (extension.isPreReleaseVersion && hasPreRelease === false ) {
770
801
  return false;
771
802
  }
@@ -1018,7 +1049,8 @@ let AbstractExtensionGalleryService = class AbstractExtensionGalleryService {
1018
1049
  productVersion: criteria.productVersion,
1019
1050
  version: criteria.versions?.find(
1020
1051
  extensionIdentifierWithVersion => areSameExtensions(extensionIdentifierWithVersion, extensionIdentifier)
1021
- )?.version ?? (includePreRelease ? VersionKind.Latest : VersionKind.Release)
1052
+ )?.version ?? (includePreRelease ? VersionKind.Latest : VersionKind.Release),
1053
+ includeBlockedVersions: criteria.includeBlockedVersions
1022
1054
  }, allTargetPlatforms);
1023
1055
  if (rawGalleryExtensionVersion) {
1024
1056
  extensions.push(toExtension(
@@ -1068,7 +1100,8 @@ let AbstractExtensionGalleryService = class AbstractExtensionGalleryService {
1068
1100
  productVersion: criteria.productVersion,
1069
1101
  version: criteria.versions?.find(
1070
1102
  extensionIdentifierWithVersion => areSameExtensions(extensionIdentifierWithVersion, extensionIdentifier)
1071
- )?.version ?? (includePreRelease ? VersionKind.Latest : VersionKind.Release)
1103
+ )?.version ?? (includePreRelease ? VersionKind.Latest : VersionKind.Release),
1104
+ includeBlockedVersions: criteria.includeBlockedVersions
1072
1105
  }, allTargetPlatforms);
1073
1106
  const extension = rawGalleryExtensionVersion ? toExtension(
1074
1107
  rawGalleryExtension,
@@ -1132,18 +1165,22 @@ let AbstractExtensionGalleryService = class AbstractExtensionGalleryService {
1132
1165
  targetPlatform: getTargetPlatformForExtensionVersion(rawGalleryExtensionVersion),
1133
1166
  engine: getEngine(rawGalleryExtensionVersion),
1134
1167
  manifestAsset: getVersionAsset(rawGalleryExtensionVersion, AssetType.Manifest),
1135
- enabledApiProposals: getEnabledApiProposals(rawGalleryExtensionVersion)
1168
+ enabledApiProposals: getEnabledApiProposals(rawGalleryExtensionVersion),
1169
+ blocked: isBlocked(rawGalleryExtensionVersion.flags, rawGalleryExtensionVersion.blocking)
1136
1170
  }, criteria, rawGalleryExtension.publisher.displayName, allTargetPlatforms)) {
1137
1171
  return rawGalleryExtensionVersion;
1138
1172
  }
1139
1173
  if (version && rawGalleryExtensionVersion.version === version) {
1174
+ if (criteria.includeBlockedVersions && isBlocked(rawGalleryExtensionVersion.flags, rawGalleryExtensionVersion.blocking)) {
1175
+ return rawGalleryExtensionVersion;
1176
+ }
1140
1177
  return null;
1141
1178
  }
1142
1179
  }
1143
1180
  if (version || criteria.compatible) {
1144
1181
  return null;
1145
1182
  }
1146
- return rawGalleryExtension.versions[0];
1183
+ return rawGalleryExtensionVersions.find(version => !isBlocked(version.flags, version.blocking)) ?? null;
1147
1184
  }
1148
1185
  async setEngineIfNotExists(extensionId, rawGalleryExtensionVersion) {
1149
1186
  if (getEngine(rawGalleryExtensionVersion)) {
@@ -1205,9 +1242,8 @@ let AbstractExtensionGalleryService = class AbstractExtensionGalleryService {
1205
1242
  return flags;
1206
1243
  }, 0)
1207
1244
  });
1208
- const commonHeaders = await this.commonHeadersPromise;
1209
1245
  const headers = {
1210
- ...commonHeaders,
1246
+ ...(await this.getRequestHeaders(extensionsQueryApi)),
1211
1247
  "Content-Type": "application/json",
1212
1248
  "Accept": "application/json;api-version=3.0-preview.1",
1213
1249
  "Accept-Encoding": "gzip",
@@ -1334,9 +1370,8 @@ let AbstractExtensionGalleryService = class AbstractExtensionGalleryService {
1334
1370
  let errorCode;
1335
1371
  const stopWatch = ( new StopWatch());
1336
1372
  try {
1337
- const commonHeaders = await this.commonHeadersPromise;
1338
1373
  const headers = {
1339
- ...commonHeaders,
1374
+ ...(await this.getRequestHeaders(( uri.toString(true)))),
1340
1375
  "Content-Type": "application/json",
1341
1376
  "Accept": "application/json;api-version=7.2-preview",
1342
1377
  "Accept-Encoding": "gzip"
@@ -1410,9 +1445,8 @@ let AbstractExtensionGalleryService = class AbstractExtensionGalleryService {
1410
1445
  statTypeName: type
1411
1446
  });
1412
1447
  const Accept = "*/*;api-version=4.0-preview.1";
1413
- const commonHeaders = await this.commonHeadersPromise;
1414
1448
  const headers = {
1415
- ...commonHeaders,
1449
+ ...(await this.getRequestHeaders(url)),
1416
1450
  Accept
1417
1451
  };
1418
1452
  try {
@@ -1600,7 +1634,8 @@ let AbstractExtensionGalleryService = class AbstractExtensionGalleryService {
1600
1634
  targetPlatform: getTargetPlatformForExtensionVersion(version),
1601
1635
  engine: getEngine(version),
1602
1636
  manifestAsset: getVersionAsset(version, AssetType.Manifest),
1603
- enabledApiProposals: getEnabledApiProposals(version)
1637
+ enabledApiProposals: getEnabledApiProposals(version),
1638
+ blocked: isBlocked(version.flags, version.blocking)
1604
1639
  }, {
1605
1640
  compatible: !!onlyCompatible,
1606
1641
  productVersion,
@@ -1631,6 +1666,17 @@ let AbstractExtensionGalleryService = class AbstractExtensionGalleryService {
1631
1666
  }
1632
1667
  return result;
1633
1668
  }
1669
+ async getRequestHeaders(url, headers) {
1670
+ const commonHeaders = await this.commonHeadersPromise;
1671
+ const accessToken = await this.extensionGalleryManifestService.getAccessToken(url);
1672
+ return {
1673
+ ...commonHeaders,
1674
+ ...headers,
1675
+ ...(accessToken ? {
1676
+ Authorization: `Bearer ${accessToken}`
1677
+ } : {})
1678
+ };
1679
+ }
1634
1680
  async getAsset(
1635
1681
  extension,
1636
1682
  asset,
@@ -1640,23 +1686,15 @@ let AbstractExtensionGalleryService = class AbstractExtensionGalleryService {
1640
1686
  options = {},
1641
1687
  token = CancellationToken.None
1642
1688
  ) {
1643
- const commonHeaders = await this.commonHeadersPromise;
1644
- const baseOptions = {
1645
- type: "GET"
1646
- };
1647
- const headers = {
1648
- ...commonHeaders,
1649
- ...(options.headers || {})
1650
- };
1651
1689
  options = {
1652
1690
  ...options,
1653
- ...baseOptions,
1654
- headers
1691
+ type: "GET"
1655
1692
  };
1656
1693
  const url = asset.uri;
1657
1694
  const fallbackUrl = asset.fallbackUri;
1658
1695
  const firstOptions = {
1659
1696
  ...options,
1697
+ headers: await this.getRequestHeaders(url, options.headers),
1660
1698
  url,
1661
1699
  timeout: this.getRequestTimeout(),
1662
1700
  callSite
@@ -1685,6 +1723,7 @@ let AbstractExtensionGalleryService = class AbstractExtensionGalleryService {
1685
1723
  });
1686
1724
  const fallbackOptions = {
1687
1725
  ...options,
1726
+ headers: await this.getRequestHeaders(fallbackUrl, options.headers),
1688
1727
  url: fallbackUrl,
1689
1728
  timeout: this.getRequestTimeout(),
1690
1729
  callSite: `${callSite}.fallback`
@@ -1705,9 +1744,13 @@ let AbstractExtensionGalleryService = class AbstractExtensionGalleryService {
1705
1744
  autoUpdate: {}
1706
1745
  };
1707
1746
  }
1747
+ const accessToken = await this.extensionGalleryManifestService.getAccessToken(this.extensionsControlUrl);
1708
1748
  const context = await this.requestService.request({
1709
1749
  type: "GET",
1710
1750
  url: this.extensionsControlUrl,
1751
+ headers: accessToken ? {
1752
+ Authorization: `Bearer ${accessToken}`
1753
+ } : undefined,
1711
1754
  timeout: this.getRequestTimeout(),
1712
1755
  callSite: "extensionGalleryService.getExtensionsControlManifest"
1713
1756
  }, CancellationToken.None);
@@ -1794,4 +1837,4 @@ let AbstractExtensionGalleryService = class AbstractExtensionGalleryService {
1794
1837
  };
1795
1838
  AbstractExtensionGalleryService = ( __decorate([( __param(1, IRequestService)), ( __param(2, ILogService)), ( __param(3, IEnvironmentService)), ( __param(4, ITelemetryService)), ( __param(5, IFileService)), ( __param(6, IProductService)), ( __param(7, IConfigurationService)), ( __param(8, IAllowedExtensionsService)), ( __param(9, IExtensionGalleryManifestService))], AbstractExtensionGalleryService));
1796
1839
 
1797
- export { AbstractExtensionGalleryService, filterLatestExtensionVersionsForTargetPlatform, sortExtensionVersions };
1840
+ export { AbstractExtensionGalleryService, filterLatestExtensionVersionsForTargetPlatform, getBlockingInfo, sortExtensionVersions };
@@ -13,6 +13,7 @@ import '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
13
13
  import '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
14
14
  import '@codingame/monaco-vscode-api/vscode/vs/base/common/process';
15
15
  import '@codingame/monaco-vscode-api/vscode/vs/base/common/strings';
16
+ import '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
16
17
  import '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagement';
17
18
  import '@codingame/monaco-vscode-api/vscode/vs/platform/extensions/common/extensions';
18
19
  import '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';