@salesforce/plugin-trust
Version:
validate a digital signature for a npm package
83 lines (82 loc) • 2.6 kB
TypeScript
import { Readable } from 'node:stream';
import { URL } from 'node:url';
import { Ux } from '@salesforce/sf-plugins-core/Ux';
import { Logger } from '@salesforce/core';
import { NpmMeta } from './npmCommand.js';
import { type NpmName } from './npmName.js';
export declare const DEFAULT_REGISTRY = "https://registry.npmjs.org/";
export type ConfigContext = {
configDir?: string;
cacheDir?: string;
dataDir?: string;
cliRoot?: string;
};
export type Verifier = {
verify(): Promise<NpmMeta>;
isAllowListed(): Promise<boolean>;
};
declare class CodeVerifierInfo {
private signature?;
private publicKey?;
private data?;
get dataToVerify(): Readable;
set dataToVerify(value: Readable);
get signatureStream(): Readable;
set signatureStream(value: Readable);
get publicKeyStream(): Readable;
set publicKeyStream(value: Readable);
}
export declare function verify(codeVerifierInfo: CodeVerifierInfo): Promise<boolean>;
export declare const getNpmRegistry: () => URL;
export declare function isAllowListed({ logger, configPath, name, }: {
logger: Logger;
configPath: string;
name?: string;
}): Promise<boolean>;
/**
* class for verifying a digital signature pack of an npm
*/
export declare class InstallationVerification implements Verifier {
private pluginNpmName?;
private config?;
private logger?;
/**
* setter for the cli engine config
*
* @param _config cli engine config
*/
setConfig(_config?: ConfigContext): InstallationVerification;
/**
* setter for the plugin name
*
* @param _pluginName the published plugin name
*/
setPluginNpmName(_pluginName?: NpmName | undefined): InstallationVerification;
/**
* validates the digital signature.
*/
verify(): Promise<NpmMeta>;
isAllowListed(): Promise<boolean>;
/**
* Downloads the tgz file content and stores it in a cache folder
*/
streamTagGz(): Promise<NpmMeta>;
private getConfigPath;
private getCachePath;
/**
* Invoke npm to discover a urls for the certificate and digital signature.
*/
private retrieveNpmMeta;
private getLogger;
}
export declare class VerificationConfig {
verifier?: Verifier;
private ux;
log(message: string): void;
}
export declare const doPrompt: (ux: Ux) => (plugin?: string) => Promise<void>;
export declare const doInstallationCodeSigningVerification: (ux: Ux) => (config: ConfigContext, plugin: {
plugin: string;
tag: string;
}, verificationConfig: VerificationConfig) => Promise<void>;
export {};