secure-upload-fastify-sdk 1.0.1 → 1.0.3

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.
@@ -1616,9 +1616,11 @@ var FileInitItemSchema = import_zod2.z.object({
1616
1616
  expectedHash: import_zod2.z.string().regex(/^[a-f0-9]{64}$/i).optional(),
1617
1617
  meta: import_zod2.z.record(import_zod2.z.unknown()).optional()
1618
1618
  }).strict();
1619
- var SmartInitBodySchema = import_zod2.z.object({
1620
- files: import_zod2.z.array(FileInitItemSchema).min(1).max(50)
1621
- }).strict();
1619
+ function makeSmartInitBodySchema(maxFiles) {
1620
+ return import_zod2.z.object({
1621
+ files: import_zod2.z.array(FileInitItemSchema).min(1).max(maxFiles)
1622
+ }).strict();
1623
+ }
1622
1624
  async function processOneFile(req, rt, file, index) {
1623
1625
  try {
1624
1626
  const { userId } = await resolveSession(req, file.isPublic, rt.validateSession);
@@ -1732,7 +1734,8 @@ async function registerSmartRoutes(app, rt) {
1732
1734
  "\u{1F527} smart-routes: \u6CE8\u518C smart \u4E0A\u4F20\u8DEF\u7531(part/complete/abort/status \u590D\u7528 multipart/*)..."
1733
1735
  );
1734
1736
  app.post(`${base}/init`, async (req) => {
1735
- const body = SmartInitBodySchema.parse(req.body ?? {});
1737
+ const schema = makeSmartInitBodySchema(rt.config.smartMaxFiles);
1738
+ const body = schema.parse(req.body ?? {});
1736
1739
  if (body.files.length > rt.config.smartMaxFiles) {
1737
1740
  throw new SecureError(
1738
1741
  1511 /* BATCH_TOO_MANY_FILES */,
@@ -1973,7 +1976,7 @@ async function secureUploadPluginImpl(app, options) {
1973
1976
  initRateLimit: options.rateLimit?.initPerMin ?? DEFAULTS.initRateLimit,
1974
1977
  partRateLimit: options.rateLimit?.partPerMin ?? DEFAULTS.partRateLimit,
1975
1978
  smartMaxFiles: options.rateLimit?.smartMaxFilesPerInit ?? DEFAULTS.smartMaxFiles,
1976
- smartInitRateLimit: DEFAULTS.smartInitRateLimit,
1979
+ smartInitRateLimit: options.rateLimit?.smartInitRateLimit ?? DEFAULTS.smartInitRateLimit,
1977
1980
  multipartPath: options.pathPrefix?.multipart ?? DEFAULTS.multipartPath,
1978
1981
  smartPath: options.pathPrefix?.smart ?? DEFAULTS.smartPath,
1979
1982
  fileUrlPrefix: options.fileUrlPrefix ?? DEFAULTS.fileUrlPrefix,