Skip to content

Commit c5f624a

Browse files
committed
fix(cloudfront-signer): changing the type of dateLessThan and dateGreaterThan
1 parent c4f8c7e commit c5f624a

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

packages/cloudfront-signer/src/sign.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -638,14 +638,14 @@ describe("getSignedUrl- when signing a URL with a date range", () => {
638638
const resultUrl = getSignedUrl({
639639
url,
640640
keyPairId,
641-
dateLessThan: dateNumber as unknown as string,
641+
dateLessThan: dateNumber,
642642
privateKey,
643643
passphrase,
644644
});
645645
const resultCookies = getSignedCookies({
646646
url,
647647
keyPairId,
648-
dateLessThan: dateNumber as unknown as string,
648+
dateLessThan: dateNumber,
649649
privateKey,
650650
passphrase,
651651
});
@@ -658,14 +658,14 @@ describe("getSignedUrl- when signing a URL with a date range", () => {
658658
const resultUrl = getSignedUrl({
659659
url,
660660
keyPairId,
661-
dateLessThan: dateObject as unknown as string,
661+
dateLessThan: dateObject,
662662
privateKey,
663663
passphrase,
664664
});
665665
const resultCookies = getSignedCookies({
666666
url,
667667
keyPairId,
668-
dateLessThan: dateObject as unknown as string,
668+
dateLessThan: dateObject,
669669
privateKey,
670670
passphrase,
671671
});
@@ -709,8 +709,8 @@ describe("getSignedUrl- when signing a URL with a date range", () => {
709709
const result = getSignedUrl({
710710
url,
711711
keyPairId,
712-
dateLessThan: dateNumber as unknown as string,
713-
dateGreaterThan: dateGreaterThanNumber as unknown as string,
712+
dateLessThan: dateNumber,
713+
dateGreaterThan: dateGreaterThanNumber,
714714
privateKey,
715715
passphrase,
716716
});
@@ -740,8 +740,8 @@ describe("getSignedUrl- when signing a URL with a date range", () => {
740740
const result = getSignedUrl({
741741
url,
742742
keyPairId,
743-
dateLessThan: dateObject as unknown as string,
744-
dateGreaterThan: dateGreaterThanObject as unknown as string,
743+
dateLessThan: dateObject,
744+
dateGreaterThan: dateGreaterThanObject,
745745
privateKey,
746746
passphrase,
747747
});

packages/cloudfront-signer/src/sign.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export type CloudfrontSignInputWithParameters = CloudfrontSignerCredentials & {
2525
/** The URL string to sign. */
2626
url: string;
2727
/** The date string for when the signed URL or cookie can no longer be accessed */
28-
dateLessThan: string;
28+
dateLessThan: string | number | Date;
2929
/** The date string for when the signed URL or cookie can start to be accessed. */
30-
dateGreaterThan?: string;
30+
dateGreaterThan?: string | number | Date;
3131
/** The IP address string to restrict signed URL access to. */
3232
ipAddress?: string;
3333
/**
@@ -367,7 +367,7 @@ class CloudfrontSignBuilder {
367367
return isNaN(parsedDate.getTime()) ? undefined : this.epochTime(parsedDate);
368368
}
369369

370-
private parseDateWindow(expiration: string, start?: string): PolicyDates {
370+
private parseDateWindow(expiration: string | number | Date, start?: string | number | Date): PolicyDates {
371371
const dateLessThan = this.parseDate(expiration);
372372
if (!dateLessThan) {
373373
throw new Error("dateLessThan is invalid. Ensure the date string is compatible with the Date constructor.");
@@ -400,8 +400,8 @@ class CloudfrontSignBuilder {
400400
ipAddress,
401401
}: {
402402
url?: string;
403-
dateLessThan?: string;
404-
dateGreaterThan?: string;
403+
dateLessThan?: string | number | Date;
404+
dateGreaterThan?: string | number | Date;
405405
ipAddress?: string;
406406
}) {
407407
if (!url || !dateLessThan) {

0 commit comments

Comments
 (0)