UNPKG

3.97 kBTypeScriptView Raw
1import { HttpRequest } from "./http";
2/**
3 * @public
4 *
5 * A `Date` object, a unix (epoch) timestamp in seconds, or a string that can be
6 * understood by the JavaScript `Date` constructor.
7 */
8export type DateInput = number | string | Date;
9/**
10 * @public
11 */
12export interface SigningArguments {
13 /**
14 * The date and time to be used as signature metadata. This value should be
15 * a Date object, a unix (epoch) timestamp, or a string that can be
16 * understood by the JavaScript `Date` constructor.If not supplied, the
17 * value returned by `new Date()` will be used.
18 */
19 signingDate?: DateInput;
20 /**
21 * The service signing name. It will override the service name of the signer
22 * in current invocation
23 */
24 signingService?: string;
25 /**
26 * The region name to sign the request. It will override the signing region of the
27 * signer in current invocation
28 */
29 signingRegion?: string;
30}
31/**
32 * @public
33 */
34export interface RequestSigningArguments extends SigningArguments {
35 /**
36 * A set of strings whose members represents headers that cannot be signed.
37 * All headers in the provided request will have their names converted to
38 * lower case and then checked for existence in the unsignableHeaders set.
39 */
40 unsignableHeaders?: Set<string>;
41 /**
42 * A set of strings whose members represents headers that should be signed.
43 * Any values passed here will override those provided via unsignableHeaders,
44 * allowing them to be signed.
45 *
46 * All headers in the provided request will have their names converted to
47 * lower case before signing.
48 */
49 signableHeaders?: Set<string>;
50}
51/**
52 * @public
53 */
54export interface RequestPresigningArguments extends RequestSigningArguments {
55 /**
56 * The number of seconds before the presigned URL expires
57 */
58 expiresIn?: number;
59 /**
60 * A set of strings whose representing headers that should not be hoisted
61 * to presigned request's query string. If not supplied, the presigner
62 * moves all the AWS-specific headers (starting with `x-amz-`) to the request
63 * query string. If supplied, these headers remain in the presigned request's
64 * header.
65 * All headers in the provided request will have their names converted to
66 * lower case and then checked for existence in the unhoistableHeaders set.
67 */
68 unhoistableHeaders?: Set<string>;
69}
70/**
71 * @public
72 */
73export interface EventSigningArguments extends SigningArguments {
74 priorSignature: string;
75}
76/**
77 * @public
78 */
79export interface RequestPresigner {
80 /**
81 * Signs a request for future use.
82 *
83 * The request will be valid until either the provided `expiration` time has
84 * passed or the underlying credentials have expired.
85 *
86 * @param requestToSign - The request that should be signed.
87 * @param options - Additional signing options.
88 */
89 presign(requestToSign: HttpRequest, options?: RequestPresigningArguments): Promise<HttpRequest>;
90}
91/**
92 * @public
93 *
94 * An object that signs request objects with AWS credentials using one of the
95 * AWS authentication protocols.
96 */
97export interface RequestSigner {
98 /**
99 * Sign the provided request for immediate dispatch.
100 */
101 sign(requestToSign: HttpRequest, options?: RequestSigningArguments): Promise<HttpRequest>;
102}
103/**
104 * @public
105 */
106export interface StringSigner {
107 /**
108 * Sign the provided `stringToSign` for use outside of the context of
109 * request signing. Typical uses include signed policy generation.
110 */
111 sign(stringToSign: string, options?: SigningArguments): Promise<string>;
112}
113/**
114 * @public
115 */
116export interface FormattedEvent {
117 headers: Uint8Array;
118 payload: Uint8Array;
119}
120/**
121 * @public
122 */
123export interface EventSigner {
124 /**
125 * Sign the individual event of the event stream.
126 */
127 sign(event: FormattedEvent, options: EventSigningArguments): Promise<string>;
128}