Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @aws-sdk/signature-v4

Index

References

SignatureV4

Re-exports SignatureV4

SignatureV4CryptoInit

Re-exports SignatureV4CryptoInit

SignatureV4Init

Re-exports SignatureV4Init

clearCredentialCache

Re-exports clearCredentialCache

createScope

Re-exports createScope

getCanonicalHeaders

Re-exports getCanonicalHeaders

getCanonicalQuery

Re-exports getCanonicalQuery

getPayloadHash

Re-exports getPayloadHash

getSigningKey

Re-exports getSigningKey

moveHeadersToQuery

Re-exports moveHeadersToQuery

prepareRequest

Re-exports prepareRequest

Variables

Const ALGORITHM_IDENTIFIER

ALGORITHM_IDENTIFIER: "AWS4-HMAC-SHA256" = "AWS4-HMAC-SHA256"

Const ALGORITHM_IDENTIFIER_V4A

ALGORITHM_IDENTIFIER_V4A: "AWS4-ECDSA-P256-SHA256" = "AWS4-ECDSA-P256-SHA256"

Const ALGORITHM_QUERY_PARAM

ALGORITHM_QUERY_PARAM: "X-Amz-Algorithm" = "X-Amz-Algorithm"

Const AMZ_DATE_HEADER

AMZ_DATE_HEADER: string = AMZ_DATE_QUERY_PARAM.toLowerCase()

Const AMZ_DATE_QUERY_PARAM

AMZ_DATE_QUERY_PARAM: "X-Amz-Date" = "X-Amz-Date"

Const AUTH_HEADER

AUTH_HEADER: "authorization" = "authorization"

Const CREDENTIAL_QUERY_PARAM

CREDENTIAL_QUERY_PARAM: "X-Amz-Credential" = "X-Amz-Credential"

Const DATE_HEADER

DATE_HEADER: "date" = "date"

Const EVENT_ALGORITHM_IDENTIFIER

EVENT_ALGORITHM_IDENTIFIER: "AWS4-HMAC-SHA256-PAYLOAD" = "AWS4-HMAC-SHA256-PAYLOAD"

Const EXPIRES_QUERY_PARAM

EXPIRES_QUERY_PARAM: "X-Amz-Expires" = "X-Amz-Expires"

Const GENERATED_HEADERS

GENERATED_HEADERS: string[] = [AUTH_HEADER, AMZ_DATE_HEADER, DATE_HEADER]

Const HOST_HEADER

HOST_HEADER: "host" = "host"

Const KEY_TYPE_IDENTIFIER

KEY_TYPE_IDENTIFIER: "aws4_request" = "aws4_request"

Const MAX_CACHE_SIZE

MAX_CACHE_SIZE: 50 = 50

Const MAX_PRESIGNED_TTL

MAX_PRESIGNED_TTL: number = 60 * 60 * 24 * 7

Const PROXY_HEADER_PATTERN

PROXY_HEADER_PATTERN: RegExp = /^proxy-/

Const REGION_SET_PARAM

REGION_SET_PARAM: "X-Amz-Region-Set" = "X-Amz-Region-Set"

Const SEC_HEADER_PATTERN

SEC_HEADER_PATTERN: RegExp = /^sec-/

Const SHA256_HEADER

SHA256_HEADER: "x-amz-content-sha256" = "x-amz-content-sha256"

Const SIGNATURE_HEADER

SIGNATURE_HEADER: string = SIGNATURE_QUERY_PARAM.toLowerCase()

Const SIGNATURE_QUERY_PARAM

SIGNATURE_QUERY_PARAM: "X-Amz-Signature" = "X-Amz-Signature"

Const SIGNED_HEADERS_QUERY_PARAM

SIGNED_HEADERS_QUERY_PARAM: "X-Amz-SignedHeaders" = "X-Amz-SignedHeaders"

Const TOKEN_HEADER

TOKEN_HEADER: string = TOKEN_QUERY_PARAM.toLowerCase()

Const TOKEN_QUERY_PARAM

TOKEN_QUERY_PARAM: "X-Amz-Security-Token" = "X-Amz-Security-Token"

Const UNSIGNABLE_PATTERNS

UNSIGNABLE_PATTERNS: RegExp[] = [/^proxy-/i, /^sec-/i]

Const UNSIGNED_PAYLOAD

UNSIGNED_PAYLOAD: "UNSIGNED-PAYLOAD" = "UNSIGNED-PAYLOAD"

Const cacheQueue

cacheQueue: Array<string> = []

Const region

region: "us-east-1" = "us-east-1"

Const requests

requests: Array<TestCase> = [{name: "get-header-key-duplicate",request: {protocol: "https:",method: "GET",hostname: "example.amazonaws.com",query: {},headers: {host: "example.amazonaws.com","my-header1": "value2,value2,value1","x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;x-amz-date, Signature=c9d5ea9f3f72853aea855b47ea873832890dbdd183b4468f858259531a5138ea",},{name: "get-header-value-multiline",request: {protocol: "https:",method: "GET",hostname: "example.amazonaws.com",query: {},headers: {host: "example.amazonaws.com","my-header1": "value1,value2,value3","x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;x-amz-date, Signature=ba17b383a53190154eb5fa66a1b836cc297cc0a3d70a5d00705980573d8ff790",},{name: "get-header-value-order",request: {protocol: "https:",method: "GET",hostname: "example.amazonaws.com",query: {},headers: {host: "example.amazonaws.com","my-header1": "value4,value1,value3,value2","x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;x-amz-date, Signature=08c7e5a9acfcfeb3ab6b2185e75ce8b1deb5e634ec47601a50643f830c755c01",},{name: "get-header-value-trim",request: {protocol: "https:",method: "GET",hostname: "example.amazonaws.com",query: {},headers: {host: "example.amazonaws.com","my-header1": "value1","my-header2": '"a b c"',"x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;my-header2;x-amz-date, Signature=acc3ed3afb60bb290fc8d2dd0098b9911fcaa05412b367055dee359757a9c736",},{name: "get-unreserved",request: {protocol: "https:",method: "GET",hostname: "example.amazonaws.com",query: {},headers: {host: "example.amazonaws.com","x-amz-date": "20150830T123600Z",},path: "/-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=07ef7494c76fa4850883e2b006601f940f8a34d404d0cfa977f52a65bbf5f24f",},{name: "get-utf8",request: {protocol: "https:",method: "GET",hostname: "example.amazonaws.com",query: {},headers: {host: "example.amazonaws.com","x-amz-date": "20150830T123600Z",},path: "/ሴ",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=8318018e0b0f223aa2bbf98705b62bb787dc9c0e678f255a891fd03141be5d85",},{name: "get-vanilla",request: {protocol: "https:",method: "GET",hostname: "example.amazonaws.com",query: {},headers: {host: "example.amazonaws.com","x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=5fa00fa31553b73ebf1942676e86291e8372ff2a2260956d9b8aae1d763fbf31",},{name: "get-vanilla-empty-query-key",request: {protocol: "https:",method: "GET",hostname: "example.amazonaws.com",query: {Param1: "value1",},headers: {host: "example.amazonaws.com","x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=a67d582fa61cc504c4bae71f336f98b97f1ea3c7a6bfe1b6e45aec72011b9aeb",},{name: "get-vanilla-query",request: {protocol: "https:",method: "GET",hostname: "example.amazonaws.com",query: {},headers: {host: "example.amazonaws.com","x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=5fa00fa31553b73ebf1942676e86291e8372ff2a2260956d9b8aae1d763fbf31",},{name: "get-vanilla-query-order-key-case",request: {protocol: "https:",method: "GET",hostname: "example.amazonaws.com",query: {Param2: "value2",Param1: "value1",},headers: {host: "example.amazonaws.com","x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=b97d918cfa904a5beff61c982a1b6f458b799221646efd99d3219ec94cdf2500",},{name: "get-vanilla-query-unreserved",request: {protocol: "https:",method: "GET",hostname: "example.amazonaws.com",query: {"-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz":"-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",},headers: {host: "example.amazonaws.com","x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=9c3e54bfcdf0b19771a7f523ee5669cdf59bc7cc0884027167c21bb143a40197",},{name: "get-vanilla-utf8-query",request: {protocol: "https:",method: "GET",hostname: "example.amazonaws.com",query: {ሴ: "bar",},headers: {host: "example.amazonaws.com","x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=2cdec8eed098649ff3a119c94853b13c643bcf08f8b0a1d91e12c9027818dd04",},{name: "post-header-key-case",request: {protocol: "https:",method: "POST",hostname: "example.amazonaws.com",query: {},headers: {host: "example.amazonaws.com","x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=5da7c1a2acd57cee7505fc6676e4e544621c30862966e37dddb68e92efbe5d6b",},{name: "post-header-key-sort",request: {protocol: "https:",method: "POST",hostname: "example.amazonaws.com",query: {},headers: {host: "example.amazonaws.com","my-header1": "value1","x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;x-amz-date, Signature=c5410059b04c1ee005303aed430f6e6645f61f4dc9e1461ec8f8916fdf18852c",},{name: "post-header-value-case",request: {protocol: "https:",method: "POST",hostname: "example.amazonaws.com",query: {},headers: {host: "example.amazonaws.com","my-header1": "VALUE1","x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;x-amz-date, Signature=cdbc9802e29d2942e5e10b5bccfdd67c5f22c7c4e8ae67b53629efa58b974b7d",},{name: "post-sts-header-after",request: {protocol: "https:",method: "POST",hostname: "example.amazonaws.com",query: {},headers: {host: "example.amazonaws.com","x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=5da7c1a2acd57cee7505fc6676e4e544621c30862966e37dddb68e92efbe5d6b",},{name: "post-sts-header-before",request: {protocol: "https:",method: "POST",hostname: "example.amazonaws.com",query: {},headers: {host: "example.amazonaws.com","x-amz-date": "20150830T123600Z","x-amz-security-token":"AQoDYXdzEPT//////////wEXAMPLEtc764bNrC9SAPBSM22wDOk4x4HIZ8j4FZTwdQWLWsKWHGBuFqwAeMicRXmxfpSPfIeoIYRqTflfKD8YUuwthAx7mSEI/qkPpKPi/kMcGdQrmGdeehM4IC1NtBmUpp2wUE8phUZampKsburEDy0KPkyQDYwT7WZ0wq5VSXDvp75YU9HFvlRd8Tx6q6fE8YQcHNVXAkiY9q6d+xo0rKwT38xVqr7ZD0u0iPPkUL64lIZbqBAz+scqKmlzm8FDrypNC9Yjc8fPOLn9FX9KSYvKTr4rvx3iSIlTJabIQwj2ICCR/oLxBA==",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date;x-amz-security-token, Signature=85d96828115b5dc0cfc3bd16ad9e210dd772bbebba041836c64533a82be05ead",},{name: "post-vanilla",request: {protocol: "https:",method: "POST",hostname: "example.amazonaws.com",query: {},headers: {host: "example.amazonaws.com","x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=5da7c1a2acd57cee7505fc6676e4e544621c30862966e37dddb68e92efbe5d6b",},{name: "post-vanilla-empty-query-value",request: {protocol: "https:",method: "POST",hostname: "example.amazonaws.com",query: {Param1: "value1",},headers: {host: "example.amazonaws.com","x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=28038455d6de14eafc1f9222cf5aa6f1a96197d7deb8263271d420d138af7f11",},{name: "post-vanilla-query",request: {protocol: "https:",method: "POST",hostname: "example.amazonaws.com",query: {Param1: "value1",},headers: {host: "example.amazonaws.com","x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=28038455d6de14eafc1f9222cf5aa6f1a96197d7deb8263271d420d138af7f11",},{name: "post-vanilla-query-nonunreserved",request: {protocol: "https:",method: "POST",hostname: "example.amazonaws.com",query: {"@#$%^": "","+": '/,?><`";:\\|][{}',},headers: {host: "example.amazonaws.com","x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=66c82657c86e26fb25238d0e69f011edc4c6df5ae71119d7cb98ed9b87393c1e",},{name: "post-vanilla-query-space",request: {protocol: "https:",method: "POST",hostname: "example.amazonaws.com",query: {p: "",},headers: {host: "example.amazonaws.com","x-amz-date": "20150830T123600Z",},path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=e71688addb58a26418614085fb730ba3faa623b461c17f48f2fbdb9361b94a9b",},{name: "post-x-www-form-urlencoded",request: {protocol: "https:",method: "POST",hostname: "example.amazonaws.com",query: {},headers: {"content-type": "application/x-www-form-urlencoded",host: "example.amazonaws.com","x-amz-date": "20150830T123600Z",},body: "Param1=value1",path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature=ff11897932ad3f4e8b18135d722051e5ac45fc38421b1da7b9d196a0fe09473a",},{name: "post-x-www-form-urlencoded-parameters",request: {protocol: "https:",method: "POST",hostname: "example.amazonaws.com",query: {},headers: {"content-type": "application/x-www-form-urlencoded; charset=utf8",host: "example.amazonaws.com","x-amz-date": "20150830T123600Z",},body: "Param1=value1",path: "/",},authorization:"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature=1a72ec8f64bd914b0e42e42607c7fbce7fb2c7465f63e3092b3b0d39fa77a6fe",},]

Const service

service: "service" = "service"

Const signingDate

signingDate: Date = new Date("2015-08-30T12:36:00Z")

Const signingKeyCache

signingKeyCache: Record<string, Uint8Array>

Functions

Const clearCredentialCache

  • clearCredentialCache(): void

Const cloneQuery

Const cloneRequest

Const createScope

  • createScope(shortDate: string, region: string, service: string): string
  • Create a string describing the scope of credentials used to sign a request.

    Parameters

    • shortDate: string

      The current calendar date in the form YYYYMMDD.

    • region: string

      The AWS region in which the service resides.

    • service: string

      The service to which the signed request is being sent.

    Returns string

Const deleteHeader

  • deleteHeader(soughtHeader: string, headers: HeaderBag): void

Const formatDate

  • formatDate(now: DateInput): { longDate: string; shortDate: string }

Const getCanonicalHeaderList

  • getCanonicalHeaderList(headers: object): string

Private Const getCanonicalHeaders

  • getCanonicalHeaders(__namedParameters: { headers: HeaderBag }, unsignableHeaders?: Set<string>, signableHeaders?: Set<string>): HeaderBag

Private Const getCanonicalQuery

Const getHeaderValue

  • getHeaderValue(soughtHeader: string, headers: HeaderBag): string | undefined

Private Const getPayloadHash

  • getPayloadHash(__namedParameters: { body: any; headers: HeaderBag }, hashConstructor: HashConstructor): Promise<string>

Const getSigningKey

  • getSigningKey(sha256Constructor: HashConstructor, credentials: Credentials, shortDate: string, region: string, service: string): Promise<Uint8Array>
  • Derive a signing key from its composite parts

    Parameters

    • sha256Constructor: HashConstructor

      A constructor function that can instantiate SHA-256 hash objects.

    • credentials: Credentials

      The credentials with which the request will be signed.

    • shortDate: string

      The current calendar date in the form YYYYMMDD.

    • region: string

      The AWS region in which the service resides.

    • service: string

      The service to which the signed request is being sent.

    Returns Promise<Uint8Array>

Const hasHeader

  • hasHeader(soughtHeader: string, headers: HeaderBag): boolean

Const hmac

Const iso8601

  • iso8601(time: number | string | Date): string

Private Const moveHeadersToQuery

Private Const prepareRequest

Const toDate

  • toDate(time: number | string | Date): Date

Object literals

Const ALWAYS_UNSIGNABLE_HEADERS

ALWAYS_UNSIGNABLE_HEADERS: object

authorization

authorization: boolean = true

cache-control

cache-control: boolean = true

connection

connection: boolean = true

expect

expect: boolean = true

from

from: boolean = true

keep-alive

keep-alive: boolean = true

max-forwards

max-forwards: boolean = true

pragma

pragma: boolean = true

referer

referer: boolean = true

te

te: boolean = true

trailer

trailer: boolean = true

transfer-encoding

transfer-encoding: boolean = true

upgrade

upgrade: boolean = true

user-agent

user-agent: boolean = true

x-amzn-trace-id

x-amzn-trace-id: boolean = true

Const credentials

credentials: object

accessKeyId

accessKeyId: string = "AKIDEXAMPLE"

secretAccessKey

secretAccessKey: string = "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY"