We announced the upcoming end-of-support for AWS SDK for JavaScript v2.
We recommend that you migrate to AWS SDK for JavaScript v3. For dates, additional details, and information on how to migrate, please refer to the linked announcement.

Class: AWS.CloudFront.Signer

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudfront/signer.js

Constructor Summary collapse

Method Summary collapse

Constructor Details

new AWS.CloudFront.Signer(keyPairId, privateKey) ⇒ void

A signer object can be used to generate signed URLs and cookies for granting access to content on restricted CloudFront distributions.

Parameters:

  • keyPairId (String)

    (Required) The ID of the CloudFront key pair being used.

  • privateKey (String)

    (Required) A private key in RSA format.

See Also:

Method Details

getSignedCookie(options, cb) ⇒ Object?

Create a signed Amazon CloudFront Cookie.

Parameters:

  • options (Object)

    The options to create a signed cookie.

  • cb (Function)

    if a callback is provided, this function will pass the hash as the second parameter (after the error parameter) to the callback function.

Options Hash (options):

  • url (String)

    The URL to which the signature will grant access. Required unless you pass in a full policy.

  • expires (Number)

    A Unix UTC timestamp indicating when the signature should expire. Required unless you pass in a full policy.

  • policy (String)

    A CloudFront JSON policy. Required unless you pass in a url and an expiry time.

Returns:

  • (Object)

    if called synchronously (with no callback), returns the signed cookie parameters.

  • (null)

    nothing is returned if a callback is provided.

getSignedUrl(options, cb) ⇒ 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).

Parameters:

  • options (Object)

    The options to create a signed URL.

  • cb (Function)

    if a callback is provided, this function will pass the URL as the second parameter (after the error parameter) to the callback function.

Options Hash (options):

  • url (String)

    The URL to which the signature will grant access. Any query params included with the URL should be encoded. Required.

  • expires (Number)

    A Unix UTC timestamp indicating when the signature should expire. Required unless you pass in a full policy.

  • policy (String)

    A CloudFront JSON policy. Required unless you pass in a url and an expiry time.

Returns:

  • (String)

    if called synchronously (with no callback), returns the signed URL.

  • (null)

    nothing is returned if a callback is provided.