UNPKG

better-vsts-npm-auth

Version:

Platform agnostic library which provides a robust solution for maintaining credentials in your npmrc files

64 lines (63 loc) 1.79 kB
export interface INpmSettings { [key: string]: string; } /** * Represents an .npmrc configuration file and presents an interface * for interactions with it. */ export declare class Npmrc { filePath: string; settings: INpmSettings; /** * @param {string} basePath - path to .npmrc file or directory containing .npmrc file */ constructor(basePath: string); /** * Inspects this object's settings for registry entries * and returns an array of Registry objects for the ones * it finds. * @returns {Registry[]} */ getRegistries(): Array<Registry>; /** * Reads the contents of the .npmrc file corresponding * to this object then parses and initializes settings. * When finished, returns this object. */ readSettingsFromFile(): Promise<Npmrc>; /** * Encodes this object's settings and then * writes them to disk at the .npmrc location * the object was instantiated from. */ saveSettingsToFile(): Promise<void>; /** * Checks whether the given key is an auth setting. */ static isAuthSetting(key: string): boolean; /** * Reads NPM settings to determine the location of the * userconfig and creates an Npmrc object for it. */ static getUserNpmrc(): Npmrc; } export interface IBasicAuthSettings extends INpmSettings { username: string; password: string; email: string; } /** * An abstraction for an npm registry configuration entry */ export declare class Registry { url: string; token: string; basicAuthSettings: IBasicAuthSettings; feed: string; project: string; constructor(registryUrl: string); /** * Returns the auth settings for this Registry */ getAuthSettings(): INpmSettings; }