UNPKG

@salesforce/plugin-trust

Version:

validate a digital signature for a npm package

58 lines 2.26 kB
/* * Copyright 2026, Salesforce, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { SfCommand, Flags } from '@salesforce/sf-plugins-core'; import { Messages } from '@salesforce/core'; import { AllowList } from '../../../../shared/allowlist.js'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); const messages = Messages.loadMessages('@salesforce/plugin-trust', 'allowlist.add'); export class AllowListAdd extends SfCommand { static summary = messages.getMessage('summary'); static description = messages.getMessage('description'); static examples = messages.getMessages('examples'); static flags = { name: Flags.string({ char: 'n', summary: messages.getMessage('flags.name.summary'), required: true, multiple: true, }), }; async run() { const { flags } = await this.parse(AllowListAdd); const allowList = new AllowList(this.config.configDir); const existingAllowList = await allowList.get(); const results = []; const addedPlugins = []; for (const name of flags.name) { const shouldAddPlugin = !existingAllowList.includes(name); if (shouldAddPlugin) { addedPlugins.push(name); results.push({ Plugin: name, Status: 'added' }); } else { results.push({ Plugin: name, Status: 'skipped', Reason: 'already within allowlist' }); } } if (addedPlugins.length > 0) { await allowList.save([...existingAllowList, ...addedPlugins]); } this.table({ data: results, }); return results; } } //# sourceMappingURL=add.js.map