mhart / aws4

Signs and prepares Node.js requests using AWS Signature Version 4
MIT License
703 stars 176 forks source link

Extend the time of a signed url #156

Open AElbert opened 1 year ago

AElbert commented 1 year ago

I am signing a url for iot core as follows:

const aws = new aws4.RequestSigner(
    {
      host: AWS_IOT_ENDPOINT,
      path: "/mqtt",
      service: "iotdevicegateway",
      region: "",
      signQuery: true,
    },
    {
      accessKeyId: "",
      secretAccessKey: "",
    }
  );

let { path } = aws.sign();

const url = wss://${AWS_IOT_ENDPOINT}${path}

But I need to lengthen the time in which the url expires to be able to connect again to the socket, I have tried some things like:

const awsDate = new Date();
awsDate.setMinutes(awsDate.getMinutes() + 20);
const isoDate = awsDate.toISOString().replace(/[:\-]|\.\d{3}/g, "");

aws.datetime = isoDate;

Change path parameter:

path: "/mqtt?X-Amz-Expires=3600",

And it hasn't worked, any ideas?