Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloudfront-signer no longer accepts milliseconds for dateLessThan / dateGreaterThan #4540

Open
darioackermann opened this issue Nov 29, 2023 · 1 comment
Assignees
Labels
bug This issue is a bug. p3 This is a minor priority issue queued

Comments

@darioackermann
Copy link

darioackermann commented Nov 29, 2023

Describe the bug

When using miliseconds to define the expiry of a cloudfront signed url, i.e. specifying dateLessThan, the cloudfront signer throws

Error: dateLessThan is invalid. Ensure the date string is compatible with the Date constructor.

Expected Behavior

Milliseconds should be accepted as they are accepted by the Date constructor
This works in SDK v2 and breaks when upgrading from SDK v2 to SDK v3

Current Behavior

The cloudfront signer throws the above mentioned error because it uses Date.parse and not new Date()
However it is perfectly valid to call the Date constructor with a value in miliseconds

new Date(1000000000000) // Sun Sep 09 2001 03:46:40 GMT+0200 

However Date.parse does not support milliseconds

Date.parse(1000000000000) // NaN

Reproduction Steps

Call

import { getSignedUrl } from "@aws-sdk/cloudfront-signer";
// ...
getSignedUrl({
  url,
  privateKey: privateKeyContents,
  keyPairId: accessKeyID,
  dateLessThan: 10000000000,
});

Possible Solution

Either of this would suffice

  1. Change the error message to Ensure the date string is compatible with Date.parse() - note that this would be breaking from SDK v2 and needs to be added to Upgrading Guide
  2. Handle milliseconds correctly (swap Date.parse() with new Date()? unsure if it breaks formats accepted by Date.parse but then it would at least align with docs)

Additional Information/Context

No response

SDK version used

3.451.0

Environment details (OS name and version, etc.)

not applicable

@darioackermann darioackermann added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 29, 2023
@RanVaknin RanVaknin self-assigned this Nov 29, 2023
@RanVaknin RanVaknin added p3 This is a minor priority issue queued and removed needs-triage This issue or PR still needs to be triaged. labels Nov 29, 2023
@RanVaknin
Copy link
Contributor

Looks right. Adding to queue.

@darioackermann darioackermann changed the title Misleading error message from cloudfront-signer (Date constructor) cloudfront-signer no longer accepts milliseconds for dateLessThan / dateGreaterThan Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p3 This is a minor priority issue queued
Projects
None yet
Development

No branches or pull requests

2 participants