2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { IStrictMarketplaceSource } from '../../../../../base/common/managedSettings.js';
7
>
import { isEqual } from '../../../../../base/common/resources.js';
8
>
import { URI } from '../../../../../base/common/uri.js';
9
>
import { IMarketplaceReference, MarketplaceReferenceKind, parseMarketplaceReference } from './marketplaceReference.js';
10
>
11
>
/**
12
>
* The allowlist entry type for `chat.plugins.strictMarketplaces`. Re-exported
13
>
* from `base/common` so chat plugin code can import it alongside the matcher it
14
>
* operates with; the same type is consumed by the managed-settings adapter.
15
>
*/
16
>
export type { IStrictMarketplaceSource };
17
>
18
>
/**
19
>
* The value of the `chat.plugins.strictMarketplaces` allowlist.
20
>
* - `undefined`: no restrictions — all marketplaces are allowed.
21
>
* - `[]`: complete lockdown — no marketplace is allowed.
22
>
* - non-empty array: only marketplaces matching an entry are allowed.
23
>
*/
24
>
export type StrictKnownMarketplaces = readonly IStrictMarketplaceSource[];
25
>
26
>
/**
27
>
* Coerces a resolved configuration value into a {@link StrictKnownMarketplaces}
28
>
* allowlist. Returns `undefined` (meaning "no restrictions") when the value is
29
>
* not an array — which is also how an unset policy surfaces (the registered
30
>
* `null` default). Malformed entries (non-objects or entries without a string
31
>
* `source`) are dropped so a bad managed-settings payload degrades to "no match"
32
>
* rather than throwing during matching.
33
>
*/
34
>
export function getStrictKnownMarketplaces(value: unknown): StrictKnownMarketplaces | undefined {
35
if (!Array.isArray(value)) {
36
return undefined;