@types/aws4

  • Version 1.11.1
  • Published
  • 9.22 kB
  • 1 dependency
  • MIT license

Install

npm i @types/aws4
yarn add @types/aws4
pnpm add @types/aws4

Overview

TypeScript definitions for aws4

Index

Functions

function sign

sign: (requestOptions: string | Request, credentials?: Credentials) => Request;
  • Calculates and populates any necessary AWS headers and/or request options on requestOptions. Returns requestOptions as a convenience for chaining.

Classes

class RequestSigner

class RequestSigner {}

    constructor

    constructor(requestOptions: string | Request, credentials?: Credentials);

      property credentials

      credentials: Credentials;

        property datetime

        datetime?: string;

        property isCodeCommitGit

        isCodeCommitGit: boolean;

        property parsedPath

        parsedPath?: { path: string; query: Record<string, string | string[]> };

        property region

        region: string;

          property request

          request: Request;

            property service

            service: string;

              method authHeader

              authHeader: () => string;
              • Generate the Authorization header value.

              method canonicalHeaders

              canonicalHeaders: () => string;
              • Generate a string representation of request.headers: - one header per line, formatted as <key>:<value> - lines are sorted. - <key> is in lowercase and is trimmed. - <value> is trimmed, and contiguous whitespaces are reduced to a single space character .

                These headers are filtered out: - authorization - connection - x-amzn-trace-id - user-agent - expect - presigned-expires - range

              method canonicalString

              canonicalString: () => string;
              • Generate a string representation of the Request. https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html

              method createHost

              createHost: () => string;

              method credentialString

              credentialString: () => string;
              • Generate the “credential scope” part of the signature.

              method defaultCredentials

              defaultCredentials: () => Credentials;
              • Extract credentials from the environment, if found.

              method formatPath

              formatPath: () => string;

              method getDate

              getDate: () => string;
              • If datetime is set, its first 8 characters are returned.

                Else, call getDateTime and return the first 8 characters.

              method getDateTime

              getDateTime: () => string;
              • If datetime is set, it is returned without further processing.

                Else, parse the Date header from request.headers, or get the current date, and format it as (ISO 8601):

                YYYYMMDDThhmmssZ

                If isCodeCommitGit is true, then the trailing Z is removed.

                The result is stored to datetime before being returned.

              method isSingleRegion

              isSingleRegion: () => boolean;
              • https://docs.aws.amazon.com/general/latest/gr/rande.html

              method matchHost

              matchHost: (host: string) => [string, string];
              • Extract the service code and region code from a Host name.

                Returns

                two element string tuple with values [service, region].

              method parsePath

              parsePath: () => void;

              method prepareRequest

              prepareRequest: () => void;
              • Calls parsePath. Prepare the Request by setting the required headers, or query parameters if request.signQuery is true.

              method sign

              sign: () => Request;
              • Sign the Request. The Request is returned for convenience.

              method signature

              signature: () => string;
              • Compute the Request HMAC signature.

              method signedHeaders

              signedHeaders: () => string;
              • Generates a list of the header names of request.headers separated by ;.

                These headers are filtered out: - authorization - connection - x-amzn-trace-id - user-agent - expect - presigned-expires - range

              method stringToSign

              stringToSign: () => string;
              • Generate the raw data to be signed. https://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html

              Interfaces

              interface Credentials

              interface Credentials {}

                property accessKeyId

                accessKeyId?: string;
                • Equivalent to the env vars AWS_ACCESS_KEY_ID and AWS_ACCESS_KEY.

                property secretAccessKey

                secretAccessKey?: string;
                • Equivalent to the env vars AWS_SECRET_ACCESS_KEY and AWS_SECRET_KEY.

                property sessionToken

                sessionToken?: string;
                • Equivalent to the env var AWS_SESSION_TOKEN.

                interface Request

                interface Request extends RequestOptions {}

                  property body

                  body?: string;
                  • Defaults to "".

                  property doNotEncodePath

                  doNotEncodePath?: boolean;
                  • If true, path won’t be encoded in the signature.

                  property doNotModifyHeaders

                  doNotModifyHeaders?: boolean;
                  • If true, signing the Request won’t mutate the headers.

                  property headers

                  headers?: OutgoingHttpHeaders;
                  • Some headers have a default value: - Host: Defaults to hostname, host, or RequestSigner.createHost() - Content-Type: defaults to "application/x-www-form-urlencoded; charset=utf-8" if there is a body - Date: used to calculate the signature date if given, defaults to new Date()

                  property host

                  host?: string;

                  property hostname

                  hostname?: string;

                  property method

                  method?: string;
                  • Defaults to "GET", or "POST" if there is a body.

                  property path

                  path?: string;
                  • Defaults to /.

                  property region

                  region?: string;

                  property service

                  service?: string;

                  property signQuery

                  signQuery?: boolean;
                  • To sign the query instead of adding an Authorization header, defaults to false.

                  Package Files (1)

                  Dependencies (1)

                  Dev Dependencies (0)

                  No dev dependencies.

                  Peer Dependencies (0)

                  No peer dependencies.

                  Badge

                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/aws4.

                  • Markdown
                    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/aws4)
                  • HTML
                    <a href="https://www.jsdocs.io/package/@types/aws4"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>