secure-upload-fastify-sdk 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -964,10 +964,6 @@ async function resolveSession(req, isPublic, validate) {
964
964
  const sessionKey = session ?? "anonymous";
965
965
  return { userId: userId ?? null, sessionKey };
966
966
  }
967
- function resolveSessionKey(req) {
968
- const sr = req.secureRequest;
969
- return sr?.session ?? req.headers["x-secure-session"] ?? "anonymous";
970
- }
971
967
  async function resolveUserId(req, isPublic, validate) {
972
968
  const sr = req.secureRequest;
973
969
  const session = sr?.session ?? req.headers["x-secure-session"];
@@ -1309,8 +1305,7 @@ async function registerMultipartRoutes(app, rt) {
1309
1305
  );
1310
1306
  }
1311
1307
  const { uploadId, partNumber, partHash } = resolvePartBiz(req);
1312
- const sessionKey = resolveSessionKey(req);
1313
- const rlKey = `rl:mp:part:${sessionKey.slice(0, 64)}`;
1308
+ const rlKey = `rl:mp:part:${uploadId}`;
1314
1309
  const rl = await rateLimit(rt, rlKey, 6e4, rt.config.partRateLimit);
1315
1310
  if (!rl.ok) {
1316
1311
  throw new SecureError(
@@ -1975,7 +1970,7 @@ async function secureUploadPluginImpl(app, options) {
1975
1970
  initRateLimit: options.rateLimit?.initPerMin ?? DEFAULTS.initRateLimit,
1976
1971
  partRateLimit: options.rateLimit?.partPerMin ?? DEFAULTS.partRateLimit,
1977
1972
  smartMaxFiles: options.rateLimit?.smartMaxFilesPerInit ?? DEFAULTS.smartMaxFiles,
1978
- smartInitRateLimit: DEFAULTS.smartInitRateLimit,
1973
+ smartInitRateLimit: options.rateLimit?.smartInitRateLimit ?? DEFAULTS.smartInitRateLimit,
1979
1974
  multipartPath: options.pathPrefix?.multipart ?? DEFAULTS.multipartPath,
1980
1975
  smartPath: options.pathPrefix?.smart ?? DEFAULTS.smartPath,
1981
1976
  fileUrlPrefix: options.fileUrlPrefix ?? DEFAULTS.fileUrlPrefix,