


























@@ -22,6 +22,7 @@ import {
2222resolveMarketplaceInstallShortcut,
2323} from "../plugins/marketplace.js";
2424import {
25+getOfficialExternalPluginCatalogEntryForPackage,
2526getOfficialExternalPluginCatalogEntry,
2627resolveOfficialExternalPluginId,
2728resolveOfficialExternalPluginInstall,
@@ -42,6 +43,7 @@ import {
4243resolveBundledInstallPlanBeforeNpm,
4344resolveBundledInstallPlanForNpmFailure,
4445resolveOfficialExternalInstallPlanBeforeNpm,
46+resolveOfficialExternalNpmPackageTrust,
4547} from "./plugin-install-plan.js";
4648import {
4749createHookPackInstallLogger,
@@ -62,6 +64,29 @@ function resolveInstallSafetyOverrides(overrides: InstallSafetyOverrides): Insta
6264};
6365}
646667+function findTrustedOfficialExternalPackageInstall(packageName: string):
68+| {
69+pluginId: string;
70+npmSpec?: string;
71+expectedIntegrity?: string;
72+}
73+| undefined {
74+const entry = getOfficialExternalPluginCatalogEntryForPackage(packageName);
75+if (entry?.source !== "official") {
76+return undefined;
77+}
78+const pluginId = resolveOfficialExternalPluginId(entry);
79+if (!pluginId) {
80+return undefined;
81+}
82+const install = resolveOfficialExternalPluginInstall(entry);
83+return {
84+ pluginId,
85+ ...(install?.npmSpec ? { npmSpec: install.npmSpec } : {}),
86+ ...(install?.expectedIntegrity ? { expectedIntegrity: install.expectedIntegrity } : {}),
87+};
88+}
89+6590function isRecord(value: unknown): value is Record<string, unknown> {
6691return Boolean(value && typeof value === "object" && !Array.isArray(value));
6792}
@@ -693,6 +718,10 @@ export async function runPluginInstallCommand(params: {
693718runtime.error("unsupported npm: spec: missing package");
694719return runtime.exit(1);
695720}
721+const officialNpmTrust = resolveOfficialExternalNpmPackageTrust({
722+npmSpec: npmPrefixSpec,
723+findOfficialExternalPackage: findTrustedOfficialExternalPackageInstall,
724+});
696725const npmPrefixResult = await tryInstallPluginOrHookPackFromNpmSpec({
697726 snapshot,
698727 installMode,
@@ -701,6 +730,15 @@ export async function runPluginInstallCommand(params: {
701730 safetyOverrides,
702731allowBundledFallback: false,
703732 extensionsDir,
733+ ...(officialNpmTrust
734+ ? {
735+expectedPluginId: officialNpmTrust.pluginId,
736+ ...(officialNpmTrust.expectedIntegrity
737+ ? { expectedIntegrity: officialNpmTrust.expectedIntegrity }
738+ : {}),
739+trustedSourceLinkedOfficialInstall: true,
740+}
741+ : {}),
704742 runtime,
705743});
706744if (!npmPrefixResult.ok) {
@@ -827,6 +865,10 @@ export async function runPluginInstallCommand(params: {
827865return;
828866}
829867868+const officialNpmTrust = resolveOfficialExternalNpmPackageTrust({
869+npmSpec: raw,
870+findOfficialExternalPackage: findTrustedOfficialExternalPackageInstall,
871+});
830872const npmResult = await tryInstallPluginOrHookPackFromNpmSpec({
831873 snapshot,
832874 installMode,
@@ -835,6 +877,15 @@ export async function runPluginInstallCommand(params: {
835877 safetyOverrides,
836878allowBundledFallback: true,
837879 extensionsDir,
880+ ...(officialNpmTrust
881+ ? {
882+expectedPluginId: officialNpmTrust.pluginId,
883+ ...(officialNpmTrust.expectedIntegrity
884+ ? { expectedIntegrity: officialNpmTrust.expectedIntegrity }
885+ : {}),
886+trustedSourceLinkedOfficialInstall: true,
887+}
888+ : {}),
838889 runtime,
839890});
840891if (!npmResult.ok) {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。