feat(core): Add 'verify' option to installPackage handler and update … (#28257)

This commit is contained in:
Sandra Zollner
2026-04-09 16:39:07 +00:00
committed by GitHub
parent 769c21946c
commit dfdc6d2c75
3 changed files with 28 additions and 2 deletions
@@ -68,6 +68,23 @@ describe('CommunityPackages Handler', () => {
expect(mockResponse.json).toHaveBeenCalledWith(mapToCommunityPackage(mockInstalledPackage));
});
it('should forward verify:true to lifecycle when provided', async () => {
const req = {
body: { name: 'n8n-nodes-test', verify: true },
user: mockUser,
};
mockLifecycle.install.mockResolvedValue(mockInstalledPackage as InstalledPackages);
await handler.installPackage[handler.installPackage.length - 1](req, mockResponse);
expect(mockLifecycle.install).toHaveBeenCalledWith(
{ name: 'n8n-nodes-test', version: undefined, verify: true },
mockUser,
'publicApi',
);
});
it('should return 400 when name is missing', async () => {
const req = {
body: {},
@@ -16,14 +16,18 @@ export = {
installPackage: [
apiKeyHasScope('communityPackage:install'),
async (
req: AuthenticatedRequest<Record<string, never>, unknown, { name: string; version?: string }>,
req: AuthenticatedRequest<
Record<string, never>,
unknown,
{ name: string; version?: string; verify?: boolean }
>,
res: express.Response,
): Promise<express.Response> => {
const lifecycle = Container.get(CommunityPackagesLifecycleService);
try {
const installedPackage = await lifecycle.install(
{ name: req.body.name, version: req.body.version, verify: false },
{ name: req.body.name, version: req.body.version, verify: req.body.verify ?? false },
req.user,
'publicApi',
);
@@ -8,3 +8,8 @@ properties:
version:
type: string
description: Specific semver version to install
verify:
type: boolean
description: >
Whether to verify the package against the n8n-vetted package list.
Required when the instance has N8N_UNVERIFIED_PACKAGES_ENABLED=false.