Home Reference Source Repository

Function

Static Public Summary
public

buildAuthorization(accessKeyId: string, credentialScope: string, signedHeaders: string, signature: string): string

public

async buildCanonicalRequest(httpRequestMethod: string, canonicalURI: string, canonicalQueryString: string, canonicalHeaders: string, signedHeaders: string, requestPayload: string): Promise<string>

public

buildStringToSign(requestDate: string, credentialScope: string, hashedCanonicalRequest: string): string

public

Formats a Date object to an AWS date string

public

async preCalculateSigningKey(secretAccessKey: string, date: string, region: string, service: string): Promise<string>

public

preCalculatedSign(signingKey: string, stringToSign: string): Promise<string>

public

async sign(secretAccessKey: string, date: string, region: string, service: string, stringToSign: string): Promise<string>

Static Public

public buildAuthorization(accessKeyId: string, credentialScope: string, signedHeaders: string, signature: string): string source

import {buildAuthorization} from 'aws-sigv4/src/index.js'

Creates the authorization string https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html

Params:

NameTypeAttributeDescription
accessKeyId string
  • nullable: false
credentialScope string
  • nullable: false
signedHeaders string
  • nullable: false
signature string
  • nullable: false

Return:

string

public async buildCanonicalRequest(httpRequestMethod: string, canonicalURI: string, canonicalQueryString: string, canonicalHeaders: string, signedHeaders: string, requestPayload: string): Promise<string> source

import {buildCanonicalRequest} from 'aws-sigv4/src/index.js'

Creates the canonical request https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html

Params:

NameTypeAttributeDescription
httpRequestMethod string
  • nullable: false

The HTTP request method (e.g. GET or POST)

canonicalURI string
  • nullable: false

The canonical URI

canonicalQueryString string
  • nullable: false

The canonical query string

canonicalHeaders string
  • nullable: false

The canonical headers

signedHeaders string
  • nullable: false

The signed headers

requestPayload string
  • nullable: false

The payload of the request

Return:

Promise<string>

The canonical request

public buildStringToSign(requestDate: string, credentialScope: string, hashedCanonicalRequest: string): string source

import {buildStringToSign} from 'aws-sigv4/src/index.js'

Creates the string to sign https://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html

Params:

NameTypeAttributeDescription
requestDate string
  • nullable: false

The request date (YYYMMDDThhmmssZ)

credentialScope string
  • nullable: false

the credential scope (formatted as YYYYMMDD/region/service/aws4_request)

hashedCanonicalRequest string
  • nullable: false

Return:

string

The string to sign

public formatDateTime(date: Date): string source

import {formatDateTime} from 'aws-sigv4/src/index.js'

Formats a Date object to an AWS date string

Params:

NameTypeAttributeDescription
date Date
  • nullable: false

The date

Return:

string

The formatted date string

public async preCalculateSigningKey(secretAccessKey: string, date: string, region: string, service: string): Promise<string> source

import {preCalculateSigningKey} from 'aws-sigv4/src/index.js'

Pre-calculates the signing key https://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html

Params:

NameTypeAttributeDescription
secretAccessKey string
  • nullable: false

The secret access key for the AWS account

date string
  • nullable: false

The date in YYYYMMDD format

region string
  • nullable: false

The AWS region (e.g. us-east-1)

service string
  • nullable: false

The AWS service (e.g. iam)

Return:

Promise<string>

The pre-calculated signing key

public preCalculatedSign(signingKey: string, stringToSign: string): Promise<string> source

import {preCalculatedSign} from 'aws-sigv4/src/index.js'

Pre-calculates the signature https://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html

Params:

NameTypeAttributeDescription
signingKey string
  • nullable: false

The pre-calculated signing key

stringToSign string
  • nullable: false

The string to sign

Return:

Promise<string>

The pre-calculated signature

public async sign(secretAccessKey: string, date: string, region: string, service: string, stringToSign: string): Promise<string> source

import {sign} from 'aws-sigv4/src/index.js'

Calculates the signature https://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html

Params:

NameTypeAttributeDescription
secretAccessKey string
  • nullable: false

The secret access key for the AWS account

date string
  • nullable: false

The date in YYYYMMDD format

region string
  • nullable: false

The AWS region (e.g. us-east-1)

service string
  • nullable: false

The AWS service (e.g. iam)

stringToSign string
  • nullable: false

The string to sign

Return:

Promise<string>

The signature