UNPKG

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