@types/aws4
- Version 1.11.6
- Published
- 8.7 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
. ReturnsrequestOptions
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;
Used as a cache by getDateTime and getDate. Setting it will shortcut those functions.
Set by: - prepareRequest - getDateTime - sign
property isCodeCommitGit
isCodeCommitGit: boolean;
property parsedPath
parsedPath?: { path: string; query: Record<string, string | string[]> };
Set by: - prepareRequest - sign - canonicalString - parsePath
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 characterThese 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;
**Will throw if parsedPath is undefined!**
Rebuild the path from parsedPath.
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):YYYYMMDDThhmmssZIf isCodeCommitGit is
true
, then the trailingZ
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;
Parse request.path and store the results in parsedPath.
method prepareRequest
prepareRequest: () => void;
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
andAWS_ACCESS_KEY
.
property secretAccessKey
secretAccessKey?: string;
Equivalent to the env vars
AWS_SECRET_ACCESS_KEY
andAWS_SECRET_KEY
.
property sessionToken
sessionToken?: string;
Equivalent to the env var
AWS_SESSION_TOKEN
.
interface Request
interface Request extends RequestOptions {}
property body
body?: string | Buffer;
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 tonew Date()
property host
host?: string;
Defaults to RequestSigner.createHost() if possible.
property hostname
hostname?: string;
Equivalent to host
property method
method?: string;
Defaults to
"GET"
, or"POST"
if there is a body.
property path
path?: string;
Defaults to
/
.
property region
region?: string;
Defaults to RequestSigner.matchHost()[1], or
"us-east-1"
.
property service
service?: string;
Defaults to RequestSigner.matchHost()[0], or
""
.
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 oneto 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[](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>
- Updated .
Package analyzed in 3827 ms. - Missing or incorrect documentation? Open an issue for this package.