UNPKG

2.66 kBTypeScriptView Raw
1import { Credentials, EventSigner, EventSigningArguments, FormattedEvent, HashConstructor, HttpRequest, Provider, RequestPresigner, RequestPresigningArguments, RequestSigner, RequestSigningArguments, SigningArguments, StringSigner } from "@aws-sdk/types";
2export interface SignatureV4Init {
3 /**
4 * The service signing name.
5 */
6 service: string;
7 /**
8 * The region name or a function that returns a promise that will be
9 * resolved with the region name.
10 */
11 region: string | Provider<string>;
12 /**
13 * The credentials with which the request should be signed or a function
14 * that returns a promise that will be resolved with credentials.
15 */
16 credentials: Credentials | Provider<Credentials>;
17 /**
18 * A constructor function for a hash object that will calculate SHA-256 HMAC
19 * checksums.
20 */
21 sha256?: HashConstructor;
22 /**
23 * Whether to uri-escape the request URI path as part of computing the
24 * canonical request string. This is required for every AWS service, except
25 * Amazon S3, as of late 2017.
26 *
27 * @default [true]
28 */
29 uriEscapePath?: boolean;
30 /**
31 * Whether to calculate a checksum of the request body and include it as
32 * either a request header (when signing) or as a query string parameter
33 * (when presigning). This is required for AWS Glacier and Amazon S3 and optional for
34 * every other AWS service as of late 2017.
35 *
36 * @default [true]
37 */
38 applyChecksum?: boolean;
39}
40export interface SignatureV4CryptoInit {
41 sha256: HashConstructor;
42}
43export declare class SignatureV4 implements RequestPresigner, RequestSigner, StringSigner, EventSigner {
44 private readonly service;
45 private readonly regionProvider;
46 private readonly credentialProvider;
47 private readonly sha256;
48 private readonly uriEscapePath;
49 private readonly applyChecksum;
50 constructor({ applyChecksum, credentials, region, service, sha256, uriEscapePath, }: SignatureV4Init & SignatureV4CryptoInit);
51 presign(originalRequest: HttpRequest, options?: RequestPresigningArguments): Promise<HttpRequest>;
52 sign(stringToSign: string, options?: SigningArguments): Promise<string>;
53 sign(event: FormattedEvent, options: EventSigningArguments): Promise<string>;
54 sign(requestToSign: HttpRequest, options?: RequestSigningArguments): Promise<HttpRequest>;
55 private signEvent;
56 private signString;
57 private signRequest;
58 private createCanonicalRequest;
59 private createStringToSign;
60 private getCanonicalPath;
61 private getSignature;
62 private getSigningKey;
63 private validateResolvedCredentials;
64}