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.
@@ -1570,9 +1570,11 @@ var FileInitItemSchema = z2.object({
1570
1570
  expectedHash: z2.string().regex(/^[a-f0-9]{64}$/i).optional(),
1571
1571
  meta: z2.record(z2.unknown()).optional()
1572
1572
  }).strict();
1573
- var SmartInitBodySchema = z2.object({
1574
- files: z2.array(FileInitItemSchema).min(1).max(50)
1575
- }).strict();
1573
+ function makeSmartInitBodySchema(maxFiles) {
1574
+ return z2.object({
1575
+ files: z2.array(FileInitItemSchema).min(1).max(maxFiles)
1576
+ }).strict();
1577
+ }
1576
1578
  async function processOneFile(req, rt, file, index) {
1577
1579
  try {
1578
1580
  const { userId } = await resolveSession(req, file.isPublic, rt.validateSession);
@@ -1686,7 +1688,8 @@ async function registerSmartRoutes(app, rt) {
1686
1688
  "\u{1F527} smart-routes: \u6CE8\u518C smart \u4E0A\u4F20\u8DEF\u7531(part/complete/abort/status \u590D\u7528 multipart/*)..."
1687
1689
  );
1688
1690
  app.post(`${base}/init`, async (req) => {
1689
- const body = SmartInitBodySchema.parse(req.body ?? {});
1691
+ const schema = makeSmartInitBodySchema(rt.config.smartMaxFiles);
1692
+ const body = schema.parse(req.body ?? {});
1690
1693
  if (body.files.length > rt.config.smartMaxFiles) {
1691
1694
  throw new SecureError(
1692
1695
  1511 /* BATCH_TOO_MANY_FILES */,
@@ -1927,7 +1930,7 @@ async function secureUploadPluginImpl(app, options) {
1927
1930
  initRateLimit: options.rateLimit?.initPerMin ?? DEFAULTS.initRateLimit,
1928
1931
  partRateLimit: options.rateLimit?.partPerMin ?? DEFAULTS.partRateLimit,
1929
1932
  smartMaxFiles: options.rateLimit?.smartMaxFilesPerInit ?? DEFAULTS.smartMaxFiles,
1930
- smartInitRateLimit: DEFAULTS.smartInitRateLimit,
1933
+ smartInitRateLimit: options.rateLimit?.smartInitRateLimit ?? DEFAULTS.smartInitRateLimit,
1931
1934
  multipartPath: options.pathPrefix?.multipart ?? DEFAULTS.multipartPath,
1932
1935
  smartPath: options.pathPrefix?.smart ?? DEFAULTS.smartPath,
1933
1936
  fileUrlPrefix: options.fileUrlPrefix ?? DEFAULTS.fileUrlPrefix,