|
| 1 | +import {Credentials} from './credentials'; |
| 2 | +import {HttpRequest} from './http'; |
| 3 | + |
| 4 | +/** |
| 5 | + * An object that signs request objects with AWS credentials using one of the |
| 6 | + * AWS authentication protocols. |
| 7 | + */ |
| 8 | +export interface RequestSigner<StreamType> { |
| 9 | + /** |
| 10 | + * Use the provided `request` and `credentials` to create a pre-signed URL |
| 11 | + * that will be valid until the provided `expires` time. This method will |
| 12 | + * move all values that would normally be sent as headers to the query |
| 13 | + * string of the URL so that the returned value can be used in contexts that |
| 14 | + * do not allow specifying additional headers, such as <img> tags or <a> |
| 15 | + * links. |
| 16 | + * |
| 17 | + * The URL will be valid until either the provided `expires` time has passed |
| 18 | + * or the underlying credentials have expired. |
| 19 | + * |
| 20 | + * @param request The request from which the URL should be derived. |
| 21 | + * @param credentials The credentials with which the URL should be signed. |
| 22 | + * @param expires The time at which the signed URL should no longer be |
| 23 | + * honored. This value should be a Date object, a unix |
| 24 | + * (epoch) timestamp, or a string that can be |
| 25 | + * understood by the JavaScript `Date` constructor. |
| 26 | + * |
| 27 | + * @see RequestSigner::presign |
| 28 | + */ |
| 29 | + createPresignedUrl( |
| 30 | + request: HttpRequest<StreamType>, |
| 31 | + credentials: Credentials, |
| 32 | + expires: number|string|Date |
| 33 | + ): Promise<string>; |
| 34 | + |
| 35 | + /** |
| 36 | + * Sign the provided `request` with the provided `credentials` for future |
| 37 | + * use. The request must be sent along with the headers with which it was |
| 38 | + * signed. |
| 39 | + * |
| 40 | + * The URL will be valid until either the provided `expires` time has passed |
| 41 | + * or the underlying credentials have expired. |
| 42 | + * |
| 43 | + * @param request The request from which the URL should be derived. |
| 44 | + * @param credentials The credentials with which the URL should be signed. |
| 45 | + * @param expires The time at which the signed URL should no longer be |
| 46 | + * honored. This value should be a Date object, a unix |
| 47 | + * (epoch) timestamp, or a string that can be |
| 48 | + * understood by the JavaScript `Date` constructor. |
| 49 | + * |
| 50 | + * @see RequestSigner::createPresignedUrl |
| 51 | + */ |
| 52 | + presignRequest( |
| 53 | + request: HttpRequest<StreamType>, |
| 54 | + credentials: Credentials, |
| 55 | + expires: number|string|Date |
| 56 | + ): Promise<HttpRequest<StreamType>>; |
| 57 | + |
| 58 | + /** |
| 59 | + * Sign the provided `request` with the provided `credentials` for immediate |
| 60 | + * dispatch. |
| 61 | + * |
| 62 | + * @param request The request from which the URL should be derived. |
| 63 | + * @param credentials The credentials with which the URL should be signed. |
| 64 | + */ |
| 65 | + signRequest( |
| 66 | + request: HttpRequest<StreamType>, |
| 67 | + credentials: Credentials |
| 68 | + ): Promise<HttpRequest<StreamType>>; |
| 69 | +} |
0 commit comments