signer.d.ts (1830B)
1 export 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: SignerOptions): CustomPolicy|CannedPolicy; 14 getSignedCookie(options: SignerOptions, callback: (err: Error, cookie: CustomPolicy|CannedPolicy) => void): void; 15 /** 16 * Create a signed Amazon CloudFront URL. 17 * 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). 18 */ 19 getSignedUrl(options: SignerOptions): string; 20 getSignedUrl(options: SignerOptions, callback: (err: Error, url: string) => void): void; 21 } 22 23 interface SignerOptions { 24 /** 25 * The URL to which the signature will grant access. Required unless you pass in a full policy. 26 */ 27 url?: string; 28 /** 29 * A Unix UTC timestamp indicating when the signature should expire. Required unless you pass in a full policy. 30 */ 31 expires?: number; 32 /** 33 * A CloudFront JSON policy. Required unless you pass in a url and an expiry time. 34 */ 35 policy?: string; 36 } 37 38 interface CustomPolicy { 39 "CloudFront-Policy": string; 40 "CloudFront-Key-Pair-Id": string; 41 "CloudFront-Signature": string; 42 } 43 44 interface CannedPolicy { 45 "CloudFront-Expires": number; 46 "CloudFront-Key-Pair-Id": string; 47 "CloudFront-Signature": string; 48 }