signer.d.ts
2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
export class Signer {
/**
* A signer object can be used to generate signed URLs and cookies for granting access to content on restricted CloudFront distributions.
*
* @param {string} keyPairId - The ID of the CloudFront key pair being used.
* @param {string} privateKey - A private key in RSA format.
*/
constructor(keyPairId: string, privateKey: string);
/**
* Create a signed Amazon CloudFront Cookie.
*/
getSignedCookie(options: Signer.SignerOptionsWithPolicy): Signer.CustomPolicy;
/**
* Create a signed Amazon CloudFront Cookie.
*/
getSignedCookie(options: Signer.SignerOptionsWithoutPolicy): Signer.CannedPolicy;
/**
* Create a signed Amazon CloudFront Cookie.
*/
getSignedCookie(options: Signer.SignerOptionsWithPolicy, callback: (err: Error, cookie: Signer.CustomPolicy) => void): void;
/**
* Create a signed Amazon CloudFront Cookie.
*/
getSignedCookie(options: Signer.SignerOptionsWithoutPolicy, callback: (err: Error, cookie: Signer.CannedPolicy) => void): void;
/**
* Create a signed Amazon CloudFront URL.
* Keep in mind that URLs meant for use in media/flash players may have different requirements for URL formats (e.g. some require that the extension be removed, some require the file name to be prefixed - mp4:, some require you to add "/cfx/st" into your URL).
*/
getSignedUrl(options: Signer.SignerOptionsWithPolicy | Signer.SignerOptionsWithoutPolicy): string;
/**
* Create a signed Amazon CloudFront URL.
* Keep in mind that URLs meant for use in media/flash players may have different requirements for URL formats (e.g. some require that the extension be removed, some require the file name to be prefixed - mp4:, some require you to add "/cfx/st" into your URL).
*/
getSignedUrl(options: Signer.SignerOptionsWithPolicy| Signer.SignerOptionsWithoutPolicy, callback: (err: Error, url: string) => void): void;
}
declare namespace Signer {
export interface SignerOptionsWithPolicy {
/**
* A CloudFront JSON policy. Required unless you pass in a url and an expiry time.
*/
policy: string;
}
export interface SignerOptionsWithoutPolicy {
/**
* The URL to which the signature will grant access. Required unless you pass in a full policy.
*/
url: string
/**
* A Unix UTC timestamp indicating when the signature should expire. Required unless you pass in a full policy.
*/
expires: number
}
export interface CustomPolicy {
"CloudFront-Policy": string;
"CloudFront-Key-Pair-Id": string;
"CloudFront-Signature": string;
}
export interface CannedPolicy {
"CloudFront-Expires": number;
"CloudFront-Key-Pair-Id": string;
"CloudFront-Signature": string;
}
}