UNPKG

3.08 kBTypeScriptView Raw
1import { AwsCredentialIdentity, ChecksumConstructor, EventSigner, EventSigningArguments, FormattedEvent, HashConstructor, HttpRequest, MessageSigner, Provider, RequestPresigner, RequestPresigningArguments, RequestSigner, RequestSigningArguments, SignableMessage, SignedMessage, 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: AwsCredentialIdentity | Provider<AwsCredentialIdentity>;
17 /**
18 * A constructor function for a hash object that will calculate SHA-256 HMAC
19 * checksums.
20 */
21 sha256?: ChecksumConstructor | 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: ChecksumConstructor | HashConstructor;
42}
43export declare class SignatureV4 implements RequestPresigner, RequestSigner, StringSigner, EventSigner, MessageSigner {
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 private readonly headerMarshaller;
51 constructor({ applyChecksum, credentials, region, service, sha256, uriEscapePath, }: SignatureV4Init & SignatureV4CryptoInit);
52 presign(originalRequest: HttpRequest, options?: RequestPresigningArguments): Promise<HttpRequest>;
53 sign(stringToSign: string, options?: SigningArguments): Promise<string>;
54 sign(event: FormattedEvent, options: EventSigningArguments): Promise<string>;
55 sign(event: SignableMessage, options: SigningArguments): Promise<SignedMessage>;
56 sign(requestToSign: HttpRequest, options?: RequestSigningArguments): Promise<HttpRequest>;
57 private signEvent;
58 signMessage(signableMessage: SignableMessage, { signingDate, signingRegion, signingService }: SigningArguments): Promise<SignedMessage>;
59 private signString;
60 private signRequest;
61 private createCanonicalRequest;
62 private createStringToSign;
63 private getCanonicalPath;
64 private getSignature;
65 private getSigningKey;
66 private validateResolvedCredentials;
67}