Skip to main content

npmHttpUtils

Index

Enumerations

AuthType

AuthType:

ALWAYS_AUTH

ALWAYS_AUTH: 3

BEST_EFFORT

BEST_EFFORT: 1

CONFIGURATION

CONFIGURATION: 2

NO_AUTH

NO_AUTH: 0

Type Aliases

GetPackageMetadataOptions

GetPackageMetadataOptions: Omit<Options, ident | configuration> & { cache?: Cache; project: Project; version?: string }

Options

Options: httpUtils.Options & RegistryOptions & { authType?: AuthType; otp?: string }

PackageMetadata

PackageMetadata: { dist-tags: Record<string, string>; versions: Record<string, { [ key in typeof CACHED_FIELDS[number] ]: any } & { dist: { tarball: string } }> }

Type declaration

  • dist-tags: Record<string, string>
  • versions: Record<string, { [ key in typeof CACHED_FIELDS[number] ]: any } & { dist: { tarball: string } }>

Functions

customPackageError

  • customPackageError(error: RequestError, configuration: Configuration): null | string
  • Parameters

    Returns null | string

del

  • del(path: string, __namedParameters: Options & { attemptedAs?: string }): Promise<Buffer>
  • Parameters

    • path: string
    • __namedParameters: Options & { attemptedAs?: string }

    Returns Promise<Buffer>

get

  • get(path: string, __namedParameters: Options): Promise<any>
  • Parameters

    • path: string
    • __namedParameters: Options

    Returns Promise<any>

getIdentUrl

  • getIdentUrl(ident: Ident): string
  • Parameters

    Returns string

getPackageMetadata

  • Caches and returns the package metadata for the given ident.

    Note: This function only caches and returns specific fields from the metadata. If you need other fields, use the uncached get or consider whether it would make more sense to extract the fields from the on-disk packages using the linkers or from the fetch results using the fetchers.


    Parameters

    Returns Promise<PackageMetadata>

handleInvalidAuthenticationError

  • handleInvalidAuthenticationError(error: any, __namedParameters: { attemptedAs?: string; configuration: Configuration; headers: undefined | {}; registry: string }): Promise<void>
  • Consumes all 401 Unauthorized errors and reports them as AUTHENTICATION_INVALID.

    It doesn't handle 403 Forbidden, as the npm registry uses it when the user attempts a prohibited action, such as publishing a package with a similar name to an existing package.


    Parameters

    • error: any
    • __namedParameters: { attemptedAs?: string; configuration: Configuration; headers: undefined | {}; registry: string }

    Returns Promise<void>

post

  • post(path: string, body: Body, __namedParameters: Options & { attemptedAs?: string }): Promise<Buffer>
  • Parameters

    • path: string
    • body: Body
    • __namedParameters: Options & { attemptedAs?: string }

    Returns Promise<Buffer>

put

  • put(path: string, body: Body, __namedParameters: Options & { attemptedAs?: string }): Promise<Buffer>
  • Parameters

    • path: string
    • body: Body
    • __namedParameters: Options & { attemptedAs?: string }

    Returns Promise<Buffer>