@payloadcms/plugin-cloud-storage 3.82.0-canary.6 → 3.82.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"afterRead.d.ts","sourceRoot":"","sources":["../../src/hooks/afterRead.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAErE,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAEpE,UAAU,IAAI;IACZ,OAAO,EAAE,gBAAgB,CAAA;IACzB,UAAU,EAAE,gBAAgB,CAAA;IAC5B,2BAA2B,CAAC,EAAE,OAAO,CAAA;IACrC,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB;AAED,eAAO,MAAM,gBAAgB,gFACmD,IAAI,KAAG,SAyBpF,CAAA"}
1
+ {"version":3,"file":"afterRead.d.ts","sourceRoot":"","sources":["../../src/hooks/afterRead.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAErE,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAEpE,UAAU,IAAI;IACZ,OAAO,EAAE,gBAAgB,CAAA;IACzB,UAAU,EAAE,gBAAgB,CAAA;IAC5B,2BAA2B,CAAC,EAAE,OAAO,CAAA;IACrC,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB;AAED,eAAO,MAAM,gBAAgB,gFACmD,IAAI,KAAG,SA4BpF,CAAA"}
@@ -17,6 +17,9 @@ export const getAfterReadHook = ({ adapter, collection, disablePayloadAccessCont
17
17
  filename,
18
18
  prefix
19
19
  });
20
+ } else if (url && prefix) {
21
+ const separator = url.includes('?') ? '&' : '?';
22
+ url = `${url}${separator}prefix=${encodeURIComponent(prefix)}`;
20
23
  }
21
24
  }
22
25
  return url;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/afterRead.ts"],"sourcesContent":["import type { CollectionConfig, FieldHook, ImageSize } from 'payload'\n\nimport type { GeneratedAdapter, GenerateFileURL } from '../types.js'\n\ninterface Args {\n adapter: GeneratedAdapter\n collection: CollectionConfig\n disablePayloadAccessControl?: boolean\n generateFileURL?: GenerateFileURL\n size?: ImageSize\n}\n\nexport const getAfterReadHook =\n ({ adapter, collection, disablePayloadAccessControl, generateFileURL, size }: Args): FieldHook =>\n async ({ data, value }) => {\n const filename = size ? data?.sizes?.[size.name]?.filename : data?.filename\n const prefix = data?.prefix\n let url = value\n\n if (filename) {\n if (generateFileURL) {\n url = await generateFileURL({\n collection,\n filename,\n prefix,\n size,\n })\n } else if (disablePayloadAccessControl && adapter.generateURL) {\n url = await adapter.generateURL({\n collection,\n data,\n filename,\n prefix,\n })\n }\n }\n\n return url\n }\n"],"names":["getAfterReadHook","adapter","collection","disablePayloadAccessControl","generateFileURL","size","data","value","filename","sizes","name","prefix","url","generateURL"],"mappings":"AAYA,OAAO,MAAMA,mBACX,CAAC,EAAEC,OAAO,EAAEC,UAAU,EAAEC,2BAA2B,EAAEC,eAAe,EAAEC,IAAI,EAAQ,GAClF,OAAO,EAAEC,IAAI,EAAEC,KAAK,EAAE;QACpB,MAAMC,WAAWH,OAAOC,MAAMG,OAAO,CAACJ,KAAKK,IAAI,CAAC,EAAEF,WAAWF,MAAME;QACnE,MAAMG,SAASL,MAAMK;QACrB,IAAIC,MAAML;QAEV,IAAIC,UAAU;YACZ,IAAIJ,iBAAiB;gBACnBQ,MAAM,MAAMR,gBAAgB;oBAC1BF;oBACAM;oBACAG;oBACAN;gBACF;YACF,OAAO,IAAIF,+BAA+BF,QAAQY,WAAW,EAAE;gBAC7DD,MAAM,MAAMX,QAAQY,WAAW,CAAC;oBAC9BX;oBACAI;oBACAE;oBACAG;gBACF;YACF;QACF;QAEA,OAAOC;IACT,EAAC"}
1
+ {"version":3,"sources":["../../src/hooks/afterRead.ts"],"sourcesContent":["import type { CollectionConfig, FieldHook, ImageSize } from 'payload'\n\nimport type { GeneratedAdapter, GenerateFileURL } from '../types.js'\n\ninterface Args {\n adapter: GeneratedAdapter\n collection: CollectionConfig\n disablePayloadAccessControl?: boolean\n generateFileURL?: GenerateFileURL\n size?: ImageSize\n}\n\nexport const getAfterReadHook =\n ({ adapter, collection, disablePayloadAccessControl, generateFileURL, size }: Args): FieldHook =>\n async ({ data, value }) => {\n const filename = size ? data?.sizes?.[size.name]?.filename : data?.filename\n const prefix = data?.prefix\n let url = value\n\n if (filename) {\n if (generateFileURL) {\n url = await generateFileURL({\n collection,\n filename,\n prefix,\n size,\n })\n } else if (disablePayloadAccessControl && adapter.generateURL) {\n url = await adapter.generateURL({\n collection,\n data,\n filename,\n prefix,\n })\n } else if (url && prefix) {\n const separator = url.includes('?') ? '&' : '?'\n url = `${url}${separator}prefix=${encodeURIComponent(prefix)}`\n }\n }\n\n return url\n }\n"],"names":["getAfterReadHook","adapter","collection","disablePayloadAccessControl","generateFileURL","size","data","value","filename","sizes","name","prefix","url","generateURL","separator","includes","encodeURIComponent"],"mappings":"AAYA,OAAO,MAAMA,mBACX,CAAC,EAAEC,OAAO,EAAEC,UAAU,EAAEC,2BAA2B,EAAEC,eAAe,EAAEC,IAAI,EAAQ,GAClF,OAAO,EAAEC,IAAI,EAAEC,KAAK,EAAE;QACpB,MAAMC,WAAWH,OAAOC,MAAMG,OAAO,CAACJ,KAAKK,IAAI,CAAC,EAAEF,WAAWF,MAAME;QACnE,MAAMG,SAASL,MAAMK;QACrB,IAAIC,MAAML;QAEV,IAAIC,UAAU;YACZ,IAAIJ,iBAAiB;gBACnBQ,MAAM,MAAMR,gBAAgB;oBAC1BF;oBACAM;oBACAG;oBACAN;gBACF;YACF,OAAO,IAAIF,+BAA+BF,QAAQY,WAAW,EAAE;gBAC7DD,MAAM,MAAMX,QAAQY,WAAW,CAAC;oBAC9BX;oBACAI;oBACAE;oBACAG;gBACF;YACF,OAAO,IAAIC,OAAOD,QAAQ;gBACxB,MAAMG,YAAYF,IAAIG,QAAQ,CAAC,OAAO,MAAM;gBAC5CH,MAAM,GAAGA,MAAME,UAAU,OAAO,EAAEE,mBAAmBL,SAAS;YAChE;QACF;QAEA,OAAOC;IACT,EAAC"}
package/dist/types.d.ts CHANGED
@@ -43,6 +43,7 @@ export type StaticHandler = (req: PayloadRequest, args: {
43
43
  clientUploadContext?: unknown;
44
44
  collection: string;
45
45
  filename: string;
46
+ prefix?: string;
46
47
  };
47
48
  }) => Promise<Response> | Response;
48
49
  export interface GeneratedAdapter {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,KAAK,EACL,QAAQ,EACR,SAAS,EACT,cAAc,EACd,UAAU,EACV,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAEhB,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,IAAI,EAAE;IACvC,cAAc,EAAE,oBAAoB,CAAA;IACpC,GAAG,EAAE,cAAc,CAAA;CACpB,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAEhC,MAAM,MAAM,mBAAmB,GAC3B;IACE,MAAM,CAAC,EAAE,mBAAmB,CAAA;CAC7B,GACD,OAAO,CAAA;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE;IAChC,mBAAmB,EA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M,OAAO,GAAG,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,gBAAgB,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,gBAAgB,CAAA;AAEnG,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAC,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE;IACnC,UAAU,EAAE,gBAAgB,CAAA;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;AAE9B,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,2BAA2B,CAAC,EAAE,IAAI,CAAA;IAClC,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,oBAAoB,EAAE,iBAAiB,CAAC,CAAC,CAAA;IACrE;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CollectionConfig,\n Field,\n FileData,\n ImageSize,\n PayloadRequest,\n TypeWithID,\n UploadCollectionSlug,\n} from 'payload'\n\nexport interface File {\n buffer: Buffer\n clientUploadContext?: unknown\n filename: string\n filesize: number\n mimeType: string\n tempFilePath?: string\n}\n\nexport type ClientUploadsAccess = (args: {\n collectionSlug: UploadCollectionSlug\n req: PayloadRequest\n}) => boolean | Promise<boolean>\n\nexport type ClientUploadsConfig =\n | {\n access?: ClientUploadsAccess\n }\n | boolean\n\nexport type HandleUpload = (args: {\n clientUploadContext: unknown\n collection: CollectionConfig\n data: any\n file: File\n req: PayloadRequest\n}) =>\n | Partial<FileData & TypeWithID>\n | Promise<Partial<FileData & TypeWithID>>\n | Promise<void>\n | void\n\nexport interface TypeWithPrefix {\n prefix?: string\n}\n\nexport type HandleDelete = (args: {\n collection: CollectionConfig\n doc: FileData & TypeWithID & TypeWithPrefix\n filename: string\n req: PayloadRequest\n}) => Promise<void> | void\n\nexport type GenerateURL = (args: {\n collection: CollectionConfig\n data: any\n filename: string\n prefix?: string\n}) => Promise<string> | string\n\nexport type StaticHandler = (\n req: PayloadRequest,\n args: {\n doc?: TypeWithID\n headers?: Headers\n params: { clientUploadContext?: unknown; collection: string; filename: string }\n },\n) => Promise<Response> | Response\n\nexport interface GeneratedAdapter {\n clientUploads?: ClientUploadsConfig\n /**\n * Additional fields to be injected into the base collection and image sizes\n */\n fields?: Field[]\n /**\n * Generates the public URL for a file\n */\n generateURL?: GenerateURL\n handleDelete: HandleDelete\n handleUpload: HandleUpload\n name: string\n onInit?: () => void\n staticHandler: StaticHandler\n}\n\nexport type Adapter = (args: { collection: CollectionConfig; prefix?: string }) => GeneratedAdapter\n\nexport type AllowList = Array<{\n hostname: string\n pathname?: string\n port?: string\n protocol?: 'http' | 'https'\n search?: string\n}>\n\nexport type GenerateFileURL = (args: {\n collection: CollectionConfig\n filename: string\n prefix?: string\n size?: ImageSize\n}) => Promise<string> | string\n\nexport interface CollectionOptions {\n adapter: Adapter | null\n disableLocalStorage?: boolean\n disablePayloadAccessControl?: true\n generateFileURL?: GenerateFileURL\n prefix?: string\n}\n\nexport interface PluginOptions {\n /**\n * When enabled, fields (like the prefix field) will always be inserted into\n * the collection schema regardless of whether the plugin is enabled. This\n * ensures a consistent schema across all environments.\n *\n * This will be enabled by default in Payload v4.\n *\n * @default false\n */\n alwaysInsertFields?: boolean\n collections: Partial<Record<UploadCollectionSlug, CollectionOptions>>\n /**\n * Whether or not to enable the plugin\n *\n * Default: true\n */\n enabled?: boolean\n}\n"],"names":[],"mappings":"AA+GA,WAkBC"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CollectionConfig,\n Field,\n FileData,\n ImageSize,\n PayloadRequest,\n TypeWithID,\n UploadCollectionSlug,\n} from 'payload'\n\nexport interface File {\n buffer: Buffer\n clientUploadContext?: unknown\n filename: string\n filesize: number\n mimeType: string\n tempFilePath?: string\n}\n\nexport type ClientUploadsAccess = (args: {\n collectionSlug: UploadCollectionSlug\n req: PayloadRequest\n}) => boolean | Promise<boolean>\n\nexport type ClientUploadsConfig =\n | {\n access?: ClientUploadsAccess\n }\n | boolean\n\nexport type HandleUpload = (args: {\n clientUploadContext: unknown\n collection: CollectionConfig\n data: any\n file: File\n req: PayloadRequest\n}) =>\n | Partial<FileData & TypeWithID>\n | Promise<Partial<FileData & TypeWithID>>\n | Promise<void>\n | void\n\nexport interface TypeWithPrefix {\n prefix?: string\n}\n\nexport type HandleDelete = (args: {\n collection: CollectionConfig\n doc: FileData & TypeWithID & TypeWithPrefix\n filename: string\n req: PayloadRequest\n}) => Promise<void> | void\n\nexport type GenerateURL = (args: {\n collection: CollectionConfig\n data: any\n filename: string\n prefix?: string\n}) => Promise<string> | string\n\nexport type StaticHandler = (\n req: PayloadRequest,\n args: {\n doc?: TypeWithID\n headers?: Headers\n params: { clientUploadContext?: unknown; collection: string; filename: string; prefix?: string }\n },\n) => Promise<Response> | Response\n\nexport interface GeneratedAdapter {\n clientUploads?: ClientUploadsConfig\n /**\n * Additional fields to be injected into the base collection and image sizes\n */\n fields?: Field[]\n /**\n * Generates the public URL for a file\n */\n generateURL?: GenerateURL\n handleDelete: HandleDelete\n handleUpload: HandleUpload\n name: string\n onInit?: () => void\n staticHandler: StaticHandler\n}\n\nexport type Adapter = (args: { collection: CollectionConfig; prefix?: string }) => GeneratedAdapter\n\nexport type AllowList = Array<{\n hostname: string\n pathname?: string\n port?: string\n protocol?: 'http' | 'https'\n search?: string\n}>\n\nexport type GenerateFileURL = (args: {\n collection: CollectionConfig\n filename: string\n prefix?: string\n size?: ImageSize\n}) => Promise<string> | string\n\nexport interface CollectionOptions {\n adapter: Adapter | null\n disableLocalStorage?: boolean\n disablePayloadAccessControl?: true\n generateFileURL?: GenerateFileURL\n prefix?: string\n}\n\nexport interface PluginOptions {\n /**\n * When enabled, fields (like the prefix field) will always be inserted into\n * the collection schema regardless of whether the plugin is enabled. This\n * ensures a consistent schema across all environments.\n *\n * This will be enabled by default in Payload v4.\n *\n * @default false\n */\n alwaysInsertFields?: boolean\n collections: Partial<Record<UploadCollectionSlug, CollectionOptions>>\n /**\n * Whether or not to enable the plugin\n *\n * Default: true\n */\n enabled?: boolean\n}\n"],"names":[],"mappings":"AA+GA,WAkBC"}
@@ -1,8 +1,22 @@
1
1
  import type { CollectionConfig, PayloadRequest } from 'payload';
2
- export declare function getFilePrefix({ clientUploadContext, collection, filename, req, }: {
2
+ /**
3
+ * Resolves the file prefix from the highest-priority available source and
4
+ * always returns a sanitized value.
5
+ *
6
+ * Resolution order:
7
+ * 1. `prefixQueryParam`
8
+ * 2. `clientUploadContext.prefix`
9
+ * 3. Stored document `prefix` from the database
10
+ *
11
+ * Query / client input is decoded once; malformed and multi-encoded values are
12
+ * rejected. Sanitization then normalizes slashes, removes `.` / `..` path
13
+ * traversal segments, strips leading slashes, and removes control characters.
14
+ */
15
+ export declare function getFilePrefix({ clientUploadContext, collection, filename, prefixQueryParam, req, }: {
3
16
  clientUploadContext?: unknown;
4
17
  collection: CollectionConfig;
5
18
  filename: string;
19
+ prefixQueryParam?: string;
6
20
  req: PayloadRequest;
7
21
  }): Promise<string>;
8
22
  //# sourceMappingURL=getFilePrefix.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getFilePrefix.d.ts","sourceRoot":"","sources":["../../src/utilities/getFilePrefix.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAgB,MAAM,SAAS,CAAA;AAkB7E,wBAAsB,aAAa,CAAC,EAClC,mBAAmB,EACnB,UAAU,EACV,QAAQ,EACR,GAAG,GACJ,EAAE;IACD,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,UAAU,EAAE,gBAAgB,CAAA;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,cAAc,CAAA;CACpB,GAAG,OAAO,CAAC,MAAM,CAAC,CAgClB"}
1
+ {"version":3,"file":"getFilePrefix.d.ts","sourceRoot":"","sources":["../../src/utilities/getFilePrefix.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAgB,MAAM,SAAS,CAAA;AA+B7E;;;;;;;;;;;;GAYG;AACH,wBAAsB,aAAa,CAAC,EAClC,mBAAmB,EACnB,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,GAAG,GACJ,EAAE;IACD,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,UAAU,EAAE,gBAAgB,CAAA;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,GAAG,EAAE,cAAc,CAAA;CACpB,GAAG,OAAO,CAAC,MAAM,CAAC,CAoClB"}
@@ -1,10 +1,35 @@
1
1
  /**
2
2
  * Normalizes a storage prefix to ensure only valid path segments are included.
3
3
  */ function sanitizePrefix(prefix) {
4
- return prefix.replace(/\\/g, '/').split('/').filter((segment)=>segment !== '..' && segment !== '.').join('/').replace(/^\/+/, '')// eslint-disable-next-line no-control-regex
4
+ let decodedPrefix;
5
+ try {
6
+ decodedPrefix = decodeURIComponent(prefix);
7
+ } catch {
8
+ return '';
9
+ }
10
+ // Reject multi-encoded values (e.g. `%252f`) by allowing only a single decode pass.
11
+ if (/%[0-9a-f]{2}/i.test(decodedPrefix)) {
12
+ return '';
13
+ }
14
+ return decodedPrefix.replace(/\\/g, '/').split('/').filter((segment)=>segment !== '..' && segment !== '.').join('/').replace(/^\/+/, '')// eslint-disable-next-line no-control-regex
5
15
  .replace(/[\x00-\x1f\x80-\x9f]/g, '');
6
16
  }
7
- export async function getFilePrefix({ clientUploadContext, collection, filename, req }) {
17
+ /**
18
+ * Resolves the file prefix from the highest-priority available source and
19
+ * always returns a sanitized value.
20
+ *
21
+ * Resolution order:
22
+ * 1. `prefixQueryParam`
23
+ * 2. `clientUploadContext.prefix`
24
+ * 3. Stored document `prefix` from the database
25
+ *
26
+ * Query / client input is decoded once; malformed and multi-encoded values are
27
+ * rejected. Sanitization then normalizes slashes, removes `.` / `..` path
28
+ * traversal segments, strips leading slashes, and removes control characters.
29
+ */ export async function getFilePrefix({ clientUploadContext, collection, filename, prefixQueryParam, req }) {
30
+ if (typeof prefixQueryParam === 'string') {
31
+ return sanitizePrefix(prefixQueryParam);
32
+ }
8
33
  // Prioritize from clientUploadContext if there is:
9
34
  if (clientUploadContext && typeof clientUploadContext === 'object' && 'prefix' in clientUploadContext && typeof clientUploadContext.prefix === 'string') {
10
35
  return sanitizePrefix(clientUploadContext.prefix);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getFilePrefix.ts"],"sourcesContent":["import type { CollectionConfig, PayloadRequest, UploadConfig } from 'payload'\n\n/**\n * Normalizes a storage prefix to ensure only valid path segments are included.\n */\nfunction sanitizePrefix(prefix: string): string {\n return (\n prefix\n .replace(/\\\\/g, '/')\n .split('/')\n .filter((segment) => segment !== '..' && segment !== '.')\n .join('/')\n .replace(/^\\/+/, '')\n // eslint-disable-next-line no-control-regex\n .replace(/[\\x00-\\x1f\\x80-\\x9f]/g, '')\n )\n}\n\nexport async function getFilePrefix({\n clientUploadContext,\n collection,\n filename,\n req,\n}: {\n clientUploadContext?: unknown\n collection: CollectionConfig\n filename: string\n req: PayloadRequest\n}): Promise<string> {\n // Prioritize from clientUploadContext if there is:\n if (\n clientUploadContext &&\n typeof clientUploadContext === 'object' &&\n 'prefix' in clientUploadContext &&\n typeof clientUploadContext.prefix === 'string'\n ) {\n return sanitizePrefix(clientUploadContext.prefix)\n }\n\n const imageSizes = (collection?.upload as UploadConfig)?.imageSizes || []\n\n const files = await req.payload.find({\n collection: collection.slug,\n depth: 0,\n draft: true,\n limit: 1,\n pagination: false,\n where: {\n or: [\n {\n filename: { equals: filename },\n },\n ...imageSizes.map((imageSize) => ({\n [`sizes.${imageSize.name}.filename`]: { equals: filename },\n })),\n ],\n },\n })\n const prefix = files?.docs?.[0]?.prefix\n return prefix ? sanitizePrefix(prefix as string) : ''\n}\n"],"names":["sanitizePrefix","prefix","replace","split","filter","segment","join","getFilePrefix","clientUploadContext","collection","filename","req","imageSizes","upload","files","payload","find","slug","depth","draft","limit","pagination","where","or","equals","map","imageSize","name","docs"],"mappings":"AAEA;;CAEC,GACD,SAASA,eAAeC,MAAc;IACpC,OACEA,OACGC,OAAO,CAAC,OAAO,KACfC,KAAK,CAAC,KACNC,MAAM,CAAC,CAACC,UAAYA,YAAY,QAAQA,YAAY,KACpDC,IAAI,CAAC,KACLJ,OAAO,CAAC,QAAQ,GACjB,4CAA4C;KAC3CA,OAAO,CAAC,yBAAyB;AAExC;AAEA,OAAO,eAAeK,cAAc,EAClCC,mBAAmB,EACnBC,UAAU,EACVC,QAAQ,EACRC,GAAG,EAMJ;IACC,mDAAmD;IACnD,IACEH,uBACA,OAAOA,wBAAwB,YAC/B,YAAYA,uBACZ,OAAOA,oBAAoBP,MAAM,KAAK,UACtC;QACA,OAAOD,eAAeQ,oBAAoBP,MAAM;IAClD;IAEA,MAAMW,aAAa,AAACH,YAAYI,QAAyBD,cAAc,EAAE;IAEzE,MAAME,QAAQ,MAAMH,IAAII,OAAO,CAACC,IAAI,CAAC;QACnCP,YAAYA,WAAWQ,IAAI;QAC3BC,OAAO;QACPC,OAAO;QACPC,OAAO;QACPC,YAAY;QACZC,OAAO;YACLC,IAAI;gBACF;oBACEb,UAAU;wBAAEc,QAAQd;oBAAS;gBAC/B;mBACGE,WAAWa,GAAG,CAAC,CAACC,YAAe,CAAA;wBAChC,CAAC,CAAC,MAAM,EAAEA,UAAUC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE;4BAAEH,QAAQd;wBAAS;oBAC3D,CAAA;aACD;QACH;IACF;IACA,MAAMT,SAASa,OAAOc,MAAM,CAAC,EAAE,EAAE3B;IACjC,OAAOA,SAASD,eAAeC,UAAoB;AACrD"}
1
+ {"version":3,"sources":["../../src/utilities/getFilePrefix.ts"],"sourcesContent":["import type { CollectionConfig, PayloadRequest, UploadConfig } from 'payload'\n\n/**\n * Normalizes a storage prefix to ensure only valid path segments are included.\n */\nfunction sanitizePrefix(prefix: string): string {\n let decodedPrefix: string\n\n try {\n decodedPrefix = decodeURIComponent(prefix)\n } catch {\n return ''\n }\n\n // Reject multi-encoded values (e.g. `%252f`) by allowing only a single decode pass.\n if (/%[0-9a-f]{2}/i.test(decodedPrefix)) {\n return ''\n }\n\n return (\n decodedPrefix\n .replace(/\\\\/g, '/')\n .split('/')\n .filter((segment) => segment !== '..' && segment !== '.')\n .join('/')\n .replace(/^\\/+/, '')\n // eslint-disable-next-line no-control-regex\n .replace(/[\\x00-\\x1f\\x80-\\x9f]/g, '')\n )\n}\n\n/**\n * Resolves the file prefix from the highest-priority available source and\n * always returns a sanitized value.\n *\n * Resolution order:\n * 1. `prefixQueryParam`\n * 2. `clientUploadContext.prefix`\n * 3. Stored document `prefix` from the database\n *\n * Query / client input is decoded once; malformed and multi-encoded values are\n * rejected. Sanitization then normalizes slashes, removes `.` / `..` path\n * traversal segments, strips leading slashes, and removes control characters.\n */\nexport async function getFilePrefix({\n clientUploadContext,\n collection,\n filename,\n prefixQueryParam,\n req,\n}: {\n clientUploadContext?: unknown\n collection: CollectionConfig\n filename: string\n prefixQueryParam?: string\n req: PayloadRequest\n}): Promise<string> {\n if (typeof prefixQueryParam === 'string') {\n return sanitizePrefix(prefixQueryParam)\n }\n\n // Prioritize from clientUploadContext if there is:\n if (\n clientUploadContext &&\n typeof clientUploadContext === 'object' &&\n 'prefix' in clientUploadContext &&\n typeof clientUploadContext.prefix === 'string'\n ) {\n return sanitizePrefix(clientUploadContext.prefix)\n }\n\n const imageSizes = (collection?.upload as UploadConfig)?.imageSizes || []\n\n const files = await req.payload.find({\n collection: collection.slug,\n depth: 0,\n draft: true,\n limit: 1,\n pagination: false,\n where: {\n or: [\n {\n filename: { equals: filename },\n },\n ...imageSizes.map((imageSize) => ({\n [`sizes.${imageSize.name}.filename`]: { equals: filename },\n })),\n ],\n },\n })\n const prefix = files?.docs?.[0]?.prefix\n return prefix ? sanitizePrefix(prefix as string) : ''\n}\n"],"names":["sanitizePrefix","prefix","decodedPrefix","decodeURIComponent","test","replace","split","filter","segment","join","getFilePrefix","clientUploadContext","collection","filename","prefixQueryParam","req","imageSizes","upload","files","payload","find","slug","depth","draft","limit","pagination","where","or","equals","map","imageSize","name","docs"],"mappings":"AAEA;;CAEC,GACD,SAASA,eAAeC,MAAc;IACpC,IAAIC;IAEJ,IAAI;QACFA,gBAAgBC,mBAAmBF;IACrC,EAAE,OAAM;QACN,OAAO;IACT;IAEA,oFAAoF;IACpF,IAAI,gBAAgBG,IAAI,CAACF,gBAAgB;QACvC,OAAO;IACT;IAEA,OACEA,cACGG,OAAO,CAAC,OAAO,KACfC,KAAK,CAAC,KACNC,MAAM,CAAC,CAACC,UAAYA,YAAY,QAAQA,YAAY,KACpDC,IAAI,CAAC,KACLJ,OAAO,CAAC,QAAQ,GACjB,4CAA4C;KAC3CA,OAAO,CAAC,yBAAyB;AAExC;AAEA;;;;;;;;;;;;CAYC,GACD,OAAO,eAAeK,cAAc,EAClCC,mBAAmB,EACnBC,UAAU,EACVC,QAAQ,EACRC,gBAAgB,EAChBC,GAAG,EAOJ;IACC,IAAI,OAAOD,qBAAqB,UAAU;QACxC,OAAOd,eAAec;IACxB;IAEA,mDAAmD;IACnD,IACEH,uBACA,OAAOA,wBAAwB,YAC/B,YAAYA,uBACZ,OAAOA,oBAAoBV,MAAM,KAAK,UACtC;QACA,OAAOD,eAAeW,oBAAoBV,MAAM;IAClD;IAEA,MAAMe,aAAa,AAACJ,YAAYK,QAAyBD,cAAc,EAAE;IAEzE,MAAME,QAAQ,MAAMH,IAAII,OAAO,CAACC,IAAI,CAAC;QACnCR,YAAYA,WAAWS,IAAI;QAC3BC,OAAO;QACPC,OAAO;QACPC,OAAO;QACPC,YAAY;QACZC,OAAO;YACLC,IAAI;gBACF;oBACEd,UAAU;wBAAEe,QAAQf;oBAAS;gBAC/B;mBACGG,WAAWa,GAAG,CAAC,CAACC,YAAe,CAAA;wBAChC,CAAC,CAAC,MAAM,EAAEA,UAAUC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE;4BAAEH,QAAQf;wBAAS;oBAC3D,CAAA;aACD;QACH;IACF;IACA,MAAMZ,SAASiB,OAAOc,MAAM,CAAC,EAAE,EAAE/B;IACjC,OAAOA,SAASD,eAAeC,UAAoB;AACrD"}
@@ -0,0 +1,105 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { getFilePrefix } from './getFilePrefix.js';
3
+ const makeReq = (docs = [])=>({
4
+ payload: {
5
+ find: vi.fn().mockResolvedValue({
6
+ docs
7
+ })
8
+ }
9
+ });
10
+ const makeCollection = ()=>({
11
+ slug: 'media',
12
+ upload: {}
13
+ });
14
+ describe('getFilePrefix', ()=>{
15
+ describe('prefixQueryParam shortcut', ()=>{
16
+ it('should return prefixQueryParam immediately without querying the database', async ()=>{
17
+ const req = makeReq();
18
+ const result = await getFilePrefix({
19
+ collection: makeCollection(),
20
+ prefixQueryParam: 'uuid-prefix',
21
+ filename: 'logo.png',
22
+ req
23
+ });
24
+ expect(result).toBe('uuid-prefix');
25
+ expect(req.payload.find).not.toHaveBeenCalled();
26
+ });
27
+ it('should return an empty string when prefixQueryParam is an empty string', async ()=>{
28
+ const req = makeReq();
29
+ const result = await getFilePrefix({
30
+ collection: makeCollection(),
31
+ prefixQueryParam: '',
32
+ filename: 'logo.png',
33
+ req
34
+ });
35
+ expect(result).toBe('');
36
+ expect(req.payload.find).not.toHaveBeenCalled();
37
+ });
38
+ it('should reject multi-encoded values', async ()=>{
39
+ const req = makeReq();
40
+ const result = await getFilePrefix({
41
+ collection: makeCollection(),
42
+ prefixQueryParam: '%252e%252e%252fsecret%252f..%252fok',
43
+ filename: 'logo.png',
44
+ req
45
+ });
46
+ expect(result).toBe('');
47
+ expect(req.payload.find).not.toHaveBeenCalled();
48
+ });
49
+ it('should reject malformed percent-encoding', async ()=>{
50
+ const req = makeReq();
51
+ const result = await getFilePrefix({
52
+ collection: makeCollection(),
53
+ prefixQueryParam: '%E0%A4%A',
54
+ filename: 'logo.png',
55
+ req
56
+ });
57
+ expect(result).toBe('');
58
+ expect(req.payload.find).not.toHaveBeenCalled();
59
+ });
60
+ });
61
+ describe('database fallback', ()=>{
62
+ it('should query the database when prefixQueryParam is not provided', async ()=>{
63
+ const req = makeReq([
64
+ {
65
+ prefix: 'db-prefix'
66
+ }
67
+ ]);
68
+ const result = await getFilePrefix({
69
+ collection: makeCollection(),
70
+ filename: 'logo.png',
71
+ req
72
+ });
73
+ expect(result).toBe('db-prefix');
74
+ expect(req.payload.find).toHaveBeenCalledOnce();
75
+ });
76
+ it('should return empty string when no document is found', async ()=>{
77
+ const req = makeReq([]);
78
+ const result = await getFilePrefix({
79
+ collection: makeCollection(),
80
+ filename: 'logo.png',
81
+ req
82
+ });
83
+ expect(result).toBe('');
84
+ });
85
+ it('should prioritize clientUploadContext prefix over database query', async ()=>{
86
+ const req = makeReq([
87
+ {
88
+ prefix: 'db-prefix'
89
+ }
90
+ ]);
91
+ const result = await getFilePrefix({
92
+ clientUploadContext: {
93
+ prefix: 'context-prefix'
94
+ },
95
+ collection: makeCollection(),
96
+ filename: 'logo.png',
97
+ req
98
+ });
99
+ expect(result).toBe('context-prefix');
100
+ expect(req.payload.find).not.toHaveBeenCalled();
101
+ });
102
+ });
103
+ });
104
+
105
+ //# sourceMappingURL=getFilePrefix.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/getFilePrefix.spec.ts"],"sourcesContent":["import { describe, expect, it, vi } from 'vitest'\n\nimport type { CollectionConfig, PayloadRequest } from 'payload'\n\nimport { getFilePrefix } from './getFilePrefix.js'\n\nconst makeReq = (docs: unknown[] = []) =>\n ({\n payload: {\n find: vi.fn().mockResolvedValue({ docs }),\n },\n }) as unknown as PayloadRequest\n\nconst makeCollection = (): CollectionConfig =>\n ({ slug: 'media', upload: {} }) as unknown as CollectionConfig\n\ndescribe('getFilePrefix', () => {\n describe('prefixQueryParam shortcut', () => {\n it('should return prefixQueryParam immediately without querying the database', async () => {\n const req = makeReq()\n\n const result = await getFilePrefix({\n collection: makeCollection(),\n prefixQueryParam: 'uuid-prefix',\n filename: 'logo.png',\n req,\n })\n\n expect(result).toBe('uuid-prefix')\n expect(req.payload.find).not.toHaveBeenCalled()\n })\n\n it('should return an empty string when prefixQueryParam is an empty string', async () => {\n const req = makeReq()\n\n const result = await getFilePrefix({\n collection: makeCollection(),\n prefixQueryParam: '',\n filename: 'logo.png',\n req,\n })\n\n expect(result).toBe('')\n expect(req.payload.find).not.toHaveBeenCalled()\n })\n\n it('should reject multi-encoded values', async () => {\n const req = makeReq()\n\n const result = await getFilePrefix({\n collection: makeCollection(),\n prefixQueryParam: '%252e%252e%252fsecret%252f..%252fok',\n filename: 'logo.png',\n req,\n })\n\n expect(result).toBe('')\n expect(req.payload.find).not.toHaveBeenCalled()\n })\n\n it('should reject malformed percent-encoding', async () => {\n const req = makeReq()\n\n const result = await getFilePrefix({\n collection: makeCollection(),\n prefixQueryParam: '%E0%A4%A',\n filename: 'logo.png',\n req,\n })\n\n expect(result).toBe('')\n expect(req.payload.find).not.toHaveBeenCalled()\n })\n })\n\n describe('database fallback', () => {\n it('should query the database when prefixQueryParam is not provided', async () => {\n const req = makeReq([{ prefix: 'db-prefix' }])\n\n const result = await getFilePrefix({\n collection: makeCollection(),\n filename: 'logo.png',\n req,\n })\n\n expect(result).toBe('db-prefix')\n expect(req.payload.find).toHaveBeenCalledOnce()\n })\n\n it('should return empty string when no document is found', async () => {\n const req = makeReq([])\n\n const result = await getFilePrefix({\n collection: makeCollection(),\n filename: 'logo.png',\n req,\n })\n\n expect(result).toBe('')\n })\n\n it('should prioritize clientUploadContext prefix over database query', async () => {\n const req = makeReq([{ prefix: 'db-prefix' }])\n\n const result = await getFilePrefix({\n clientUploadContext: { prefix: 'context-prefix' },\n collection: makeCollection(),\n filename: 'logo.png',\n req,\n })\n\n expect(result).toBe('context-prefix')\n expect(req.payload.find).not.toHaveBeenCalled()\n })\n })\n})\n"],"names":["describe","expect","it","vi","getFilePrefix","makeReq","docs","payload","find","fn","mockResolvedValue","makeCollection","slug","upload","req","result","collection","prefixQueryParam","filename","toBe","not","toHaveBeenCalled","prefix","toHaveBeenCalledOnce","clientUploadContext"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,SAAQ;AAIjD,SAASC,aAAa,QAAQ,qBAAoB;AAElD,MAAMC,UAAU,CAACC,OAAkB,EAAE,GAClC,CAAA;QACCC,SAAS;YACPC,MAAML,GAAGM,EAAE,GAAGC,iBAAiB,CAAC;gBAAEJ;YAAK;QACzC;IACF,CAAA;AAEF,MAAMK,iBAAiB,IACpB,CAAA;QAAEC,MAAM;QAASC,QAAQ,CAAC;IAAE,CAAA;AAE/Bb,SAAS,iBAAiB;IACxBA,SAAS,6BAA6B;QACpCE,GAAG,4EAA4E;YAC7E,MAAMY,MAAMT;YAEZ,MAAMU,SAAS,MAAMX,cAAc;gBACjCY,YAAYL;gBACZM,kBAAkB;gBAClBC,UAAU;gBACVJ;YACF;YAE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AYL;gBACZO,UAAU;gBACVJ;YACF;YAEAb,OAAOc,QAAQI,IAAI,CAAC;QACtB;QAEAjB,GAAG,oEAAoE;YACrE,MAAMY,MAAMT,QAAQ;gBAAC;oBAAEiB,QAAQ;gBAAY;aAAE;YAE7C,MAAMP,SAAS,MAAMX,cAAc;gBACjCoB,qBAAqB;oBAAEF,QAAQ;gBAAiB;gBAChDN,YAAYL;gBACZO,UAAU;gBACVJ;YACF;YAEAb,OAAOc,QAAQI,IAAI,CAAC;YACpBlB,OAAOa,IAAIP,OAAO,CAACC,IAAI,EAAEY,GAAG,CAACC,gBAAgB;QAC/C;IACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-cloud-storage",
3
- "version": "3.82.0-canary.6",
3
+ "version": "3.82.0",
4
4
  "description": "The official cloud storage plugin for Payload CMS",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -51,18 +51,18 @@
51
51
  "dependencies": {
52
52
  "find-node-modules": "^2.1.3",
53
53
  "range-parser": "^1.2.1",
54
- "@payloadcms/ui": "3.82.0-canary.6"
54
+ "@payloadcms/ui": "3.82.0"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@types/find-node-modules": "^2.1.2",
58
58
  "@types/react": "19.2.9",
59
59
  "@types/react-dom": "19.2.3",
60
- "payload": "3.82.0-canary.6"
60
+ "payload": "3.82.0"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "react": "^19.0.1 || ^19.1.2 || ^19.2.1",
64
64
  "react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
65
- "payload": "3.82.0-canary.6"
65
+ "payload": "3.82.0"
66
66
  },
67
67
  "publishConfig": {
68
68
  "registry": "https://registry.npmjs.org/"