payload 3.89.0 → 3.90.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.
- package/dist/admin/forms/Field.d.ts +2 -0
- package/dist/admin/forms/Field.d.ts.map +1 -1
- package/dist/admin/forms/Field.js.map +1 -1
- package/dist/admin/forms/Form.d.ts +2 -0
- package/dist/admin/forms/Form.d.ts.map +1 -1
- package/dist/admin/forms/Form.js.map +1 -1
- package/dist/admin/functions/index.d.ts +3 -1
- package/dist/admin/functions/index.d.ts.map +1 -1
- package/dist/admin/functions/index.js.map +1 -1
- package/dist/admin/views/dashboard.d.ts +1 -1
- package/dist/admin/views/dashboard.d.ts.map +1 -1
- package/dist/admin/views/dashboard.js.map +1 -1
- package/dist/auth/applyUserReadAccess.d.ts +15 -0
- package/dist/auth/applyUserReadAccess.d.ts.map +1 -0
- package/dist/auth/applyUserReadAccess.js +41 -0
- package/dist/auth/applyUserReadAccess.js.map +1 -0
- package/dist/auth/baseFields/apiKey/canCreateOrUpdateAPIKey.d.ts +4 -0
- package/dist/auth/baseFields/apiKey/canCreateOrUpdateAPIKey.d.ts.map +1 -0
- package/dist/auth/baseFields/apiKey/canCreateOrUpdateAPIKey.js +20 -0
- package/dist/auth/baseFields/apiKey/canCreateOrUpdateAPIKey.js.map +1 -0
- package/dist/auth/baseFields/apiKey/encryptAPIKey.d.ts +4 -0
- package/dist/auth/baseFields/apiKey/encryptAPIKey.d.ts.map +1 -0
- package/dist/auth/baseFields/apiKey/encryptAPIKey.js +16 -0
- package/dist/auth/baseFields/apiKey/encryptAPIKey.js.map +1 -0
- package/dist/auth/baseFields/apiKey/index.d.ts +6 -0
- package/dist/auth/baseFields/apiKey/index.d.ts.map +1 -0
- package/dist/auth/baseFields/apiKey/index.js +112 -0
- package/dist/auth/baseFields/apiKey/index.js.map +1 -0
- package/dist/auth/baseFields/apiKey/omitAPIKey.d.ts +4 -0
- package/dist/auth/baseFields/apiKey/omitAPIKey.d.ts.map +1 -0
- package/dist/auth/baseFields/apiKey/omitAPIKey.js +8 -0
- package/dist/auth/baseFields/apiKey/omitAPIKey.js.map +1 -0
- package/dist/auth/baseFields/apiKey/omitAPIKeyIndex.d.ts +4 -0
- package/dist/auth/baseFields/apiKey/omitAPIKeyIndex.d.ts.map +1 -0
- package/dist/auth/baseFields/apiKey/omitAPIKeyIndex.js +5 -0
- package/dist/auth/baseFields/apiKey/omitAPIKeyIndex.js.map +1 -0
- package/dist/auth/baseFields/apiKey/omitEncryptedAPIKey.d.ts +4 -0
- package/dist/auth/baseFields/apiKey/omitEncryptedAPIKey.d.ts.map +1 -0
- package/dist/auth/baseFields/apiKey/omitEncryptedAPIKey.js +5 -0
- package/dist/auth/baseFields/apiKey/omitEncryptedAPIKey.js.map +1 -0
- package/dist/auth/baseFields/apiKey/setAPIKeyIndex.d.ts +4 -0
- package/dist/auth/baseFields/apiKey/setAPIKeyIndex.d.ts.map +1 -0
- package/dist/auth/baseFields/apiKey/setAPIKeyIndex.js +17 -0
- package/dist/auth/baseFields/apiKey/setAPIKeyIndex.js.map +1 -0
- package/dist/auth/baseFields/auth.d.ts +1 -0
- package/dist/auth/baseFields/auth.d.ts.map +1 -1
- package/dist/auth/baseFields/auth.js +9 -0
- package/dist/auth/baseFields/auth.js.map +1 -1
- package/dist/auth/defaultUnlockAccess.d.ts +3 -0
- package/dist/auth/defaultUnlockAccess.d.ts.map +1 -0
- package/dist/auth/defaultUnlockAccess.js +8 -0
- package/dist/auth/defaultUnlockAccess.js.map +1 -0
- package/dist/auth/endpoints/index.d.ts +1 -0
- package/dist/auth/endpoints/index.d.ts.map +1 -1
- package/dist/auth/endpoints/index.js +8 -0
- package/dist/auth/endpoints/index.js.map +1 -1
- package/dist/auth/endpoints/revealAPIKey.d.ts +7 -0
- package/dist/auth/endpoints/revealAPIKey.d.ts.map +1 -0
- package/dist/auth/endpoints/revealAPIKey.js +120 -0
- package/dist/auth/endpoints/revealAPIKey.js.map +1 -0
- package/dist/auth/executeAccess.d.ts +3 -1
- package/dist/auth/executeAccess.d.ts.map +1 -1
- package/dist/auth/executeAccess.js +2 -1
- package/dist/auth/executeAccess.js.map +1 -1
- package/dist/auth/getAuthFields.d.ts +1 -1
- package/dist/auth/getAuthFields.d.ts.map +1 -1
- package/dist/auth/getAuthFields.js +7 -4
- package/dist/auth/getAuthFields.js.map +1 -1
- package/dist/auth/getFieldsToSign.d.ts.map +1 -1
- package/dist/auth/getFieldsToSign.js +17 -10
- package/dist/auth/getFieldsToSign.js.map +1 -1
- package/dist/auth/getFieldsToSign.spec.js +114 -0
- package/dist/auth/getFieldsToSign.spec.js.map +1 -0
- package/dist/auth/jwt.d.ts.map +1 -1
- package/dist/auth/jwt.js +2 -0
- package/dist/auth/jwt.js.map +1 -1
- package/dist/auth/jwt.spec.js +24 -0
- package/dist/auth/jwt.spec.js.map +1 -0
- package/dist/auth/jwtAuth.d.ts +9 -0
- package/dist/auth/jwtAuth.d.ts.map +1 -0
- package/dist/auth/jwtAuth.js +8 -0
- package/dist/auth/jwtAuth.js.map +1 -0
- package/dist/auth/operations/auth.d.ts.map +1 -1
- package/dist/auth/operations/auth.js +2 -1
- package/dist/auth/operations/auth.js.map +1 -1
- package/dist/auth/operations/forgotPassword.d.ts.map +1 -1
- package/dist/auth/operations/forgotPassword.js +95 -7
- package/dist/auth/operations/forgotPassword.js.map +1 -1
- package/dist/auth/operations/local/auth.js +3 -1
- package/dist/auth/operations/local/auth.js.map +1 -1
- package/dist/auth/operations/login.d.ts.map +1 -1
- package/dist/auth/operations/login.js +48 -26
- package/dist/auth/operations/login.js.map +1 -1
- package/dist/auth/operations/refresh.d.ts.map +1 -1
- package/dist/auth/operations/refresh.js +32 -9
- package/dist/auth/operations/refresh.js.map +1 -1
- package/dist/auth/operations/registerFirstUser.d.ts.map +1 -1
- package/dist/auth/operations/registerFirstUser.js +3 -4
- package/dist/auth/operations/registerFirstUser.js.map +1 -1
- package/dist/auth/operations/resetPassword.d.ts.map +1 -1
- package/dist/auth/operations/resetPassword.js +31 -22
- package/dist/auth/operations/resetPassword.js.map +1 -1
- package/dist/auth/operations/unlock.d.ts.map +1 -1
- package/dist/auth/operations/unlock.js +1 -0
- package/dist/auth/operations/unlock.js.map +1 -1
- package/dist/auth/strategies/apiKey.d.ts.map +1 -1
- package/dist/auth/strategies/apiKey.js +15 -1
- package/dist/auth/strategies/apiKey.js.map +1 -1
- package/dist/auth/strategies/jwt.d.ts.map +1 -1
- package/dist/auth/strategies/jwt.js +61 -10
- package/dist/auth/strategies/jwt.js.map +1 -1
- package/dist/auth/strategies/jwt.spec.js +281 -0
- package/dist/auth/strategies/jwt.spec.js.map +1 -0
- package/dist/auth/strategies/local/authenticate.d.ts +5 -1
- package/dist/auth/strategies/local/authenticate.d.ts.map +1 -1
- package/dist/auth/strategies/local/authenticate.js +8 -3
- package/dist/auth/strategies/local/authenticate.js.map +1 -1
- package/dist/auth/strategies/local/authenticate.spec.js +37 -10
- package/dist/auth/strategies/local/authenticate.spec.js.map +1 -1
- package/dist/auth/strategies/local/generatePasswordSaltHash.d.ts +9 -1
- package/dist/auth/strategies/local/generatePasswordSaltHash.d.ts.map +1 -1
- package/dist/auth/strategies/local/generatePasswordSaltHash.js +61 -34
- package/dist/auth/strategies/local/generatePasswordSaltHash.js.map +1 -1
- package/dist/auth/types.d.ts +16 -1
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/collections/config/client.d.ts +1 -0
- package/dist/collections/config/client.d.ts.map +1 -1
- package/dist/collections/config/client.js +3 -0
- package/dist/collections/config/client.js.map +1 -1
- package/dist/collections/config/defaults.d.ts.map +1 -1
- package/dist/collections/config/defaults.js +4 -2
- package/dist/collections/config/defaults.js.map +1 -1
- package/dist/collections/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js +17 -6
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/collections/endpoints/index.d.ts +1 -0
- package/dist/collections/endpoints/index.d.ts.map +1 -1
- package/dist/collections/endpoints/index.js +6 -5
- package/dist/collections/endpoints/index.js.map +1 -1
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +105 -8
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/deleteByID.js +13 -13
- package/dist/collections/operations/deleteByID.js.map +1 -1
- package/dist/collections/operations/findDistinct.d.ts.map +1 -1
- package/dist/collections/operations/findDistinct.js +96 -18
- package/dist/collections/operations/findDistinct.js.map +1 -1
- package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/restoreVersion.js +47 -13
- package/dist/collections/operations/restoreVersion.js.map +1 -1
- package/dist/collections/operations/update.d.ts.map +1 -1
- package/dist/collections/operations/update.js +118 -18
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/collections/operations/updateByID.d.ts.map +1 -1
- package/dist/collections/operations/updateByID.js +62 -2
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/collections/operations/utilities/update.d.ts.map +1 -1
- package/dist/collections/operations/utilities/update.js +71 -15
- package/dist/collections/operations/utilities/update.js.map +1 -1
- package/dist/config/orderable/index.d.ts.map +1 -1
- package/dist/config/orderable/index.js +67 -14
- package/dist/config/orderable/index.js.map +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +1 -1
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/types.d.ts +13 -1
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/database/getLocalizedPaths.d.ts +2 -1
- package/dist/database/getLocalizedPaths.d.ts.map +1 -1
- package/dist/database/getLocalizedPaths.js +12 -3
- package/dist/database/getLocalizedPaths.js.map +1 -1
- package/dist/database/isNestedRelationshipQuery.d.ts +9 -0
- package/dist/database/isNestedRelationshipQuery.d.ts.map +1 -0
- package/dist/database/isNestedRelationshipQuery.js +14 -0
- package/dist/database/isNestedRelationshipQuery.js.map +1 -0
- package/dist/database/prefixWherePaths.d.ts +6 -0
- package/dist/database/prefixWherePaths.d.ts.map +1 -0
- package/dist/database/prefixWherePaths.js +19 -0
- package/dist/database/prefixWherePaths.js.map +1 -0
- package/dist/database/prefixWherePaths.spec.js +46 -0
- package/dist/database/prefixWherePaths.spec.js.map +1 -0
- package/dist/database/queryValidation/validateQueryPaths.d.ts +2 -1
- package/dist/database/queryValidation/validateQueryPaths.d.ts.map +1 -1
- package/dist/database/queryValidation/validateQueryPaths.js +4 -1
- package/dist/database/queryValidation/validateQueryPaths.js.map +1 -1
- package/dist/database/queryValidation/validateSearchParams.d.ts +2 -1
- package/dist/database/queryValidation/validateSearchParams.d.ts.map +1 -1
- package/dist/database/queryValidation/validateSearchParams.js +82 -4
- package/dist/database/queryValidation/validateSearchParams.js.map +1 -1
- package/dist/database/types.d.ts +5 -0
- package/dist/database/types.d.ts.map +1 -1
- package/dist/database/types.js.map +1 -1
- package/dist/email/normalizeSendEmailOptions.js.map +1 -1
- package/dist/email/types.d.ts +4 -1
- package/dist/email/types.d.ts.map +1 -1
- package/dist/email/types.js.map +1 -1
- package/dist/exports/internal.d.ts +7 -0
- package/dist/exports/internal.d.ts.map +1 -1
- package/dist/exports/internal.js +7 -1
- package/dist/exports/internal.js.map +1 -1
- package/dist/exports/shared.d.ts +3 -0
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +3 -0
- package/dist/exports/shared.js.map +1 -1
- package/dist/fields/config/types.d.ts +7 -5
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/hooks/beforeChange/index.d.ts +7 -1
- package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/index.js +4 -2
- package/dist/fields/hooks/beforeChange/index.js.map +1 -1
- package/dist/fields/hooks/beforeChange/index.spec.js +206 -0
- package/dist/fields/hooks/beforeChange/index.spec.js.map +1 -0
- package/dist/fields/hooks/beforeChange/promise.d.ts +2 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.js +51 -9
- package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts +2 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.js +3 -2
- package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/promise.js +4 -0
- package/dist/fields/hooks/beforeDuplicate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/getFallbackValue.d.ts +2 -1
- package/dist/fields/hooks/beforeValidate/getFallbackValue.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/getFallbackValue.js +2 -2
- package/dist/fields/hooks/beforeValidate/getFallbackValue.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.d.ts +6 -1
- package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.js +3 -1
- package/dist/fields/hooks/beforeValidate/index.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.spec.js +90 -0
- package/dist/fields/hooks/beforeValidate/index.spec.js.map +1 -0
- package/dist/fields/hooks/beforeValidate/promise.d.ts +6 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.js +23 -8
- package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +6 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.js +3 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/fields/validations.js +3 -1
- package/dist/fields/validations.js.map +1 -1
- package/dist/globals/operations/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/restoreVersion.js +45 -11
- package/dist/globals/operations/restoreVersion.js.map +1 -1
- package/dist/globals/operations/update.d.ts.map +1 -1
- package/dist/globals/operations/update.js +95 -16
- package/dist/globals/operations/update.js.map +1 -1
- package/dist/index.bundled.d.ts +102 -24
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/preferences/config.d.ts.map +1 -1
- package/dist/preferences/config.js +2 -1
- package/dist/preferences/config.js.map +1 -1
- package/dist/query-presets/access.d.ts.map +1 -1
- package/dist/query-presets/access.js +2 -1
- package/dist/query-presets/access.js.map +1 -1
- package/dist/queues/config/types/index.d.ts +2 -1
- package/dist/queues/config/types/index.d.ts.map +1 -1
- package/dist/queues/config/types/index.js.map +1 -1
- package/dist/uploads/assertClientUploadAccess.d.ts +7 -0
- package/dist/uploads/assertClientUploadAccess.d.ts.map +1 -0
- package/dist/uploads/assertClientUploadAccess.js +27 -0
- package/dist/uploads/assertClientUploadAccess.js.map +1 -0
- package/dist/uploads/assertClientUploadAllowed.d.ts +11 -0
- package/dist/uploads/assertClientUploadAllowed.d.ts.map +1 -0
- package/dist/uploads/assertClientUploadAllowed.js +46 -0
- package/dist/uploads/assertClientUploadAllowed.js.map +1 -0
- package/dist/uploads/assertClientUploadAllowed.spec.js +91 -0
- package/dist/uploads/assertClientUploadAllowed.spec.js.map +1 -0
- package/dist/uploads/checkFileRestrictions.d.ts +4 -1
- package/dist/uploads/checkFileRestrictions.d.ts.map +1 -1
- package/dist/uploads/checkFileRestrictions.js +66 -26
- package/dist/uploads/checkFileRestrictions.js.map +1 -1
- package/dist/uploads/clientUploadReceipt.d.ts +23 -0
- package/dist/uploads/clientUploadReceipt.d.ts.map +1 -0
- package/dist/uploads/clientUploadReceipt.js +55 -0
- package/dist/uploads/clientUploadReceipt.js.map +1 -0
- package/dist/uploads/deleteAssociatedFiles.d.ts.map +1 -1
- package/dist/uploads/deleteAssociatedFiles.js +33 -8
- package/dist/uploads/deleteAssociatedFiles.js.map +1 -1
- package/dist/uploads/deleteAssociatedFiles.spec.js +124 -0
- package/dist/uploads/deleteAssociatedFiles.spec.js.map +1 -0
- package/dist/uploads/detectSvgFromXml.d.ts +1 -3
- package/dist/uploads/detectSvgFromXml.d.ts.map +1 -1
- package/dist/uploads/detectSvgFromXml.js +3 -40
- package/dist/uploads/detectSvgFromXml.js.map +1 -1
- package/dist/uploads/endpoints/getFile.d.ts.map +1 -1
- package/dist/uploads/endpoints/getFile.js +5 -3
- package/dist/uploads/endpoints/getFile.js.map +1 -1
- package/dist/uploads/fetchAPI-multipart/handlers.d.ts +2 -2
- package/dist/uploads/fetchAPI-multipart/handlers.d.ts.map +1 -1
- package/dist/uploads/fetchAPI-multipart/handlers.js +18 -5
- package/dist/uploads/fetchAPI-multipart/handlers.js.map +1 -1
- package/dist/uploads/fetchAPI-multipart/index.d.ts.map +1 -1
- package/dist/uploads/fetchAPI-multipart/index.js +24 -2
- package/dist/uploads/fetchAPI-multipart/index.js.map +1 -1
- package/dist/uploads/fetchAPI-multipart/processMultipart.d.ts +0 -6
- package/dist/uploads/fetchAPI-multipart/processMultipart.d.ts.map +1 -1
- package/dist/uploads/fetchAPI-multipart/processMultipart.js +146 -126
- package/dist/uploads/fetchAPI-multipart/processMultipart.js.map +1 -1
- package/dist/uploads/fetchAPI-multipart/processMultipart.spec.js +663 -0
- package/dist/uploads/fetchAPI-multipart/processMultipart.spec.js.map +1 -0
- package/dist/uploads/generateFileData.d.ts +3 -1
- package/dist/uploads/generateFileData.d.ts.map +1 -1
- package/dist/uploads/generateFileData.js +29 -16
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/getBaseFields.d.ts.map +1 -1
- package/dist/uploads/getBaseFields.js +3 -1
- package/dist/uploads/getBaseFields.js.map +1 -1
- package/dist/uploads/getExternalFile.d.ts +1 -1
- package/dist/uploads/getExternalFile.d.ts.map +1 -1
- package/dist/uploads/getExternalFile.js +60 -15
- package/dist/uploads/getExternalFile.js.map +1 -1
- package/dist/uploads/getFileTypeFallback.d.ts.map +1 -1
- package/dist/uploads/getFileTypeFallback.js +3 -1
- package/dist/uploads/getFileTypeFallback.js.map +1 -1
- package/dist/uploads/getFileTypeIdentity.d.ts +19 -0
- package/dist/uploads/getFileTypeIdentity.d.ts.map +1 -0
- package/dist/uploads/getFileTypeIdentity.js +34 -0
- package/dist/uploads/getFileTypeIdentity.js.map +1 -0
- package/dist/uploads/getFileTypeIdentity.spec.js +43 -0
- package/dist/uploads/getFileTypeIdentity.spec.js.map +1 -0
- package/dist/uploads/isProcessableImage.d.ts +2 -0
- package/dist/uploads/isProcessableImage.d.ts.map +1 -0
- package/dist/uploads/isProcessableImage.js +7 -0
- package/dist/uploads/isProcessableImage.js.map +1 -0
- package/dist/uploads/safeFetch.d.ts.map +1 -1
- package/dist/uploads/safeFetch.js +3 -2
- package/dist/uploads/safeFetch.js.map +1 -1
- package/dist/uploads/sanitizeUploadData.d.ts +26 -0
- package/dist/uploads/sanitizeUploadData.d.ts.map +1 -0
- package/dist/uploads/sanitizeUploadData.js +159 -0
- package/dist/uploads/sanitizeUploadData.js.map +1 -0
- package/dist/uploads/sanitizeUploadData.spec.js +255 -0
- package/dist/uploads/sanitizeUploadData.spec.js.map +1 -0
- package/dist/uploads/types.d.ts +11 -3
- package/dist/uploads/types.d.ts.map +1 -1
- package/dist/uploads/types.js.map +1 -1
- package/dist/uploads/uploadContentSecurityPolicy.d.ts +2 -0
- package/dist/uploads/uploadContentSecurityPolicy.d.ts.map +1 -0
- package/dist/uploads/uploadContentSecurityPolicy.js +3 -0
- package/dist/uploads/uploadContentSecurityPolicy.js.map +1 -0
- package/dist/uploads/validateISOBaseMediaFile.d.ts +4 -0
- package/dist/uploads/validateISOBaseMediaFile.d.ts.map +1 -0
- package/dist/uploads/validateISOBaseMediaFile.js +91 -0
- package/dist/uploads/validateISOBaseMediaFile.js.map +1 -0
- package/dist/uploads/validateISOBaseMediaFile.spec.js +130 -0
- package/dist/uploads/validateISOBaseMediaFile.spec.js.map +1 -0
- package/dist/uploads/validateSvg.d.ts +10 -4
- package/dist/uploads/validateSvg.d.ts.map +1 -1
- package/dist/uploads/validateSvg.js +280 -40
- package/dist/uploads/validateSvg.js.map +1 -1
- package/dist/uploads/validateSvg.spec.js +123 -0
- package/dist/uploads/validateSvg.spec.js.map +1 -0
- package/dist/uploads/validateUploadFilename.d.ts +3 -0
- package/dist/uploads/validateUploadFilename.d.ts.map +1 -0
- package/dist/uploads/validateUploadFilename.js +13 -0
- package/dist/uploads/validateUploadFilename.js.map +1 -0
- package/dist/uploads/validateUploadFilename.spec.js +24 -0
- package/dist/uploads/validateUploadFilename.spec.js.map +1 -0
- package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.js +28 -1
- package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.spec.js +158 -0
- package/dist/utilities/addDataAndFileToRequest.spec.js.map +1 -1
- package/dist/utilities/createPayloadRequest.d.ts.map +1 -1
- package/dist/utilities/createPayloadRequest.js +2 -1
- package/dist/utilities/createPayloadRequest.js.map +1 -1
- package/dist/utilities/deepCopyObject.d.ts.map +1 -1
- package/dist/utilities/deepCopyObject.js +110 -19
- package/dist/utilities/deepCopyObject.js.map +1 -1
- package/dist/utilities/deepCopyObject.spec.js +216 -0
- package/dist/utilities/deepCopyObject.spec.js.map +1 -0
- package/dist/utilities/fieldPath.d.ts +13 -0
- package/dist/utilities/fieldPath.d.ts.map +1 -0
- package/dist/utilities/fieldPath.js +51 -0
- package/dist/utilities/fieldPath.js.map +1 -0
- package/dist/utilities/fieldPath.spec.js +155 -0
- package/dist/utilities/fieldPath.spec.js.map +1 -0
- package/dist/utilities/getEntityPermissions/getEntityPermissions.d.ts.map +1 -1
- package/dist/utilities/getEntityPermissions/getEntityPermissions.js +2 -0
- package/dist/utilities/getEntityPermissions/getEntityPermissions.js.map +1 -1
- package/dist/utilities/getObjectDotNotation.d.ts.map +1 -1
- package/dist/utilities/getObjectDotNotation.js +7 -1
- package/dist/utilities/getObjectDotNotation.js.map +1 -1
- package/dist/utilities/getObjectDotNotation.spec.js +33 -0
- package/dist/utilities/getObjectDotNotation.spec.js.map +1 -0
- package/dist/utilities/getSafeRedirect.spec.js +14 -0
- package/dist/utilities/getSafeRedirect.spec.js.map +1 -1
- package/dist/utilities/getTopLevelFieldNames.d.ts +2 -0
- package/dist/utilities/getTopLevelFieldNames.d.ts.map +1 -0
- package/dist/utilities/getTopLevelFieldNames.js +3 -0
- package/dist/utilities/getTopLevelFieldNames.js.map +1 -0
- package/dist/utilities/getTopLevelFieldNames.spec.js +18 -0
- package/dist/utilities/getTopLevelFieldNames.spec.js.map +1 -0
- package/dist/utilities/handleEndpoints.js +1 -1
- package/dist/utilities/handleEndpoints.js.map +1 -1
- package/dist/utilities/parseParams/index.d.ts.map +1 -1
- package/dist/utilities/parseParams/index.js +3 -1
- package/dist/utilities/parseParams/index.js.map +1 -1
- package/dist/utilities/parseParams/index.spec.js +8 -0
- package/dist/utilities/parseParams/index.spec.js.map +1 -1
- package/dist/utilities/traverseFields.d.ts.map +1 -1
- package/dist/utilities/traverseFields.js +5 -14
- package/dist/utilities/traverseFields.js.map +1 -1
- package/dist/utilities/unflatten.d.ts.map +1 -1
- package/dist/utilities/unflatten.js +21 -9
- package/dist/utilities/unflatten.js.map +1 -1
- package/dist/utilities/unflatten.spec.js +38 -0
- package/dist/utilities/unflatten.spec.js.map +1 -0
- package/dist/versions/allLocalesPublicationStatus.d.ts +38 -0
- package/dist/versions/allLocalesPublicationStatus.d.ts.map +1 -0
- package/dist/versions/allLocalesPublicationStatus.js +57 -0
- package/dist/versions/allLocalesPublicationStatus.js.map +1 -0
- package/dist/versions/getLatestGlobalVersion.d.ts.map +1 -1
- package/dist/versions/getLatestGlobalVersion.js +10 -2
- package/dist/versions/getLatestGlobalVersion.js.map +1 -1
- package/dist/versions/getRestoredStatusesToAuthorize.d.ts +9 -0
- package/dist/versions/getRestoredStatusesToAuthorize.d.ts.map +1 -0
- package/dist/versions/getRestoredStatusesToAuthorize.js +22 -0
- package/dist/versions/getRestoredStatusesToAuthorize.js.map +1 -0
- package/dist/versions/getRestoredStatusesToAuthorize.spec.js +50 -0
- package/dist/versions/getRestoredStatusesToAuthorize.spec.js.map +1 -0
- package/dist/versions/schedule/job.d.ts +2 -2
- package/dist/versions/schedule/job.d.ts.map +1 -1
- package/dist/versions/schedule/job.js +11 -7
- package/dist/versions/schedule/job.js.map +1 -1
- package/dist/versions/schedule/types.d.ts +5 -1
- package/dist/versions/schedule/types.d.ts.map +1 -1
- package/dist/versions/schedule/types.js.map +1 -1
- package/package.json +4 -2
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { getExternalUploadSource, getLocalizedUploadProperties, getUploadDestination, mergeUploadDataWithDocument, restoreUploadDataFromDocument, sanitizeUploadData } from './sanitizeUploadData.js';
|
|
3
|
+
import { flattenAllFields } from '../utilities/flattenAllFields.js';
|
|
4
|
+
describe('sanitizeUploadData', ()=>{
|
|
5
|
+
it('should preserve only the temporary external upload source', ()=>{
|
|
6
|
+
expect(getExternalUploadSource({
|
|
7
|
+
alt: 'Alternative text',
|
|
8
|
+
filename: 'remote.png',
|
|
9
|
+
sizes: {
|
|
10
|
+
thumbnail: {
|
|
11
|
+
filename: 'submitted-thumbnail.png'
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
url: 'https://example.com/remote.png'
|
|
15
|
+
})).toEqual({
|
|
16
|
+
filename: 'remote.png',
|
|
17
|
+
url: 'https://example.com/remote.png'
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
it('should remove submitted generated file data on update', ()=>{
|
|
21
|
+
expect(sanitizeUploadData({
|
|
22
|
+
alt: 'Updated alternative text',
|
|
23
|
+
filename: 'submitted.png',
|
|
24
|
+
prefix: 'articles',
|
|
25
|
+
sizes: {
|
|
26
|
+
thumbnail: {
|
|
27
|
+
filename: 'submitted-thumbnail.png',
|
|
28
|
+
height: 100,
|
|
29
|
+
width: 100
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
url: '/api/media/file/submitted.png'
|
|
33
|
+
}, 'update')).toEqual({
|
|
34
|
+
alt: 'Updated alternative text'
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
it('should preserve a submitted prefix on create', ()=>{
|
|
38
|
+
expect(sanitizeUploadData({
|
|
39
|
+
filename: 'submitted.png',
|
|
40
|
+
prefix: 'articles'
|
|
41
|
+
}, 'create')).toEqual({
|
|
42
|
+
prefix: 'articles'
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
it('should use a submitted prefix when writing a new file', ()=>{
|
|
46
|
+
expect(getUploadDestination({
|
|
47
|
+
data: {
|
|
48
|
+
prefix: 'articles'
|
|
49
|
+
},
|
|
50
|
+
file: {}
|
|
51
|
+
})).toEqual({
|
|
52
|
+
prefix: 'articles'
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
it('should use the destination bound to a client upload context', ()=>{
|
|
56
|
+
expect(getUploadDestination({
|
|
57
|
+
data: {
|
|
58
|
+
prefix: 'submitted'
|
|
59
|
+
},
|
|
60
|
+
file: {
|
|
61
|
+
clientUploadContext: {
|
|
62
|
+
_objectKey: 'abc123',
|
|
63
|
+
prefix: 'provider'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
})).toEqual({
|
|
67
|
+
objectKey: 'abc123',
|
|
68
|
+
prefix: 'provider'
|
|
69
|
+
});
|
|
70
|
+
expect(getUploadDestination({
|
|
71
|
+
data: {
|
|
72
|
+
prefix: 'submitted'
|
|
73
|
+
},
|
|
74
|
+
file: {
|
|
75
|
+
clientUploadContext: {
|
|
76
|
+
key: 'provider/file.png'
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
})).toEqual({});
|
|
80
|
+
});
|
|
81
|
+
it('should not preserve a submitted prefix without a new file', ()=>{
|
|
82
|
+
expect(getUploadDestination({
|
|
83
|
+
data: {
|
|
84
|
+
prefix: 'articles'
|
|
85
|
+
},
|
|
86
|
+
file: undefined
|
|
87
|
+
})).toEqual({});
|
|
88
|
+
});
|
|
89
|
+
it.each([
|
|
90
|
+
{
|
|
91
|
+
filename: '../submitted.png'
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
filename: '/submitted.png'
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
filename: 'C:\\submitted.png'
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
filename: '\\\\server\\submitted.png'
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
filename: 'images/../submitted.png'
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
sizes: {
|
|
107
|
+
thumbnail: {
|
|
108
|
+
filename: '..\\submitted-thumbnail.png'
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
])('should reject an invalid submitted filename', (data)=>{
|
|
113
|
+
expect(()=>sanitizeUploadData(data, 'update')).toThrow('Invalid filename.');
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
describe('mergeUploadDataWithDocument', ()=>{
|
|
117
|
+
it('should add stored generated file data to an update', ()=>{
|
|
118
|
+
expect(mergeUploadDataWithDocument({
|
|
119
|
+
alt: 'Updated alternative text'
|
|
120
|
+
}, {
|
|
121
|
+
filename: 'stored.png',
|
|
122
|
+
prefix: 'articles',
|
|
123
|
+
sizes: {
|
|
124
|
+
thumbnail: {
|
|
125
|
+
filename: 'stored-thumbnail.png',
|
|
126
|
+
height: 100,
|
|
127
|
+
width: 100
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
url: '/api/media/file/stored.png'
|
|
131
|
+
})).toEqual({
|
|
132
|
+
alt: 'Updated alternative text',
|
|
133
|
+
filename: 'stored.png',
|
|
134
|
+
prefix: 'articles',
|
|
135
|
+
sizes: {
|
|
136
|
+
thumbnail: {
|
|
137
|
+
filename: 'stored-thumbnail.png',
|
|
138
|
+
height: 100,
|
|
139
|
+
width: 100
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
url: '/api/media/file/stored.png'
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
it('should preserve generated file data supplied by a trusted hook', ()=>{
|
|
146
|
+
expect(mergeUploadDataWithDocument({
|
|
147
|
+
filename: 'hook.png',
|
|
148
|
+
prefix: 'hook-prefix',
|
|
149
|
+
sizes: {
|
|
150
|
+
thumbnail: {
|
|
151
|
+
filename: 'hook-thumbnail.png'
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
url: '/api/media/file/hook.png'
|
|
155
|
+
}, {
|
|
156
|
+
filename: 'stored.png',
|
|
157
|
+
prefix: 'stored-prefix',
|
|
158
|
+
sizes: {
|
|
159
|
+
thumbnail: {
|
|
160
|
+
filename: 'stored-thumbnail.png',
|
|
161
|
+
height: 100,
|
|
162
|
+
width: 100
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
url: '/api/media/file/stored.png'
|
|
166
|
+
})).toEqual({
|
|
167
|
+
filename: 'hook.png',
|
|
168
|
+
prefix: 'hook-prefix',
|
|
169
|
+
sizes: {
|
|
170
|
+
thumbnail: {
|
|
171
|
+
filename: 'hook-thumbnail.png',
|
|
172
|
+
height: 100,
|
|
173
|
+
width: 100
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
url: '/api/media/file/hook.png'
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
it('should merge the selected value for localized generated file data', ()=>{
|
|
180
|
+
expect(mergeUploadDataWithDocument({
|
|
181
|
+
alt: 'Updated alternative text'
|
|
182
|
+
}, {
|
|
183
|
+
prefix: {
|
|
184
|
+
en: 'current-prefix',
|
|
185
|
+
es: 'prefijo-actual'
|
|
186
|
+
}
|
|
187
|
+
}, {
|
|
188
|
+
locale: 'en',
|
|
189
|
+
localizedProperties: new Set([
|
|
190
|
+
'prefix'
|
|
191
|
+
])
|
|
192
|
+
})).toEqual({
|
|
193
|
+
alt: 'Updated alternative text',
|
|
194
|
+
prefix: 'current-prefix'
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
describe('getLocalizedUploadProperties', ()=>{
|
|
199
|
+
it('should identify localized flattened fields', ()=>{
|
|
200
|
+
expect(getLocalizedUploadProperties(flattenAllFields({
|
|
201
|
+
fields: [
|
|
202
|
+
{
|
|
203
|
+
fields: [
|
|
204
|
+
{
|
|
205
|
+
localized: true,
|
|
206
|
+
name: 'prefix',
|
|
207
|
+
type: 'text'
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: 'url',
|
|
211
|
+
type: 'text'
|
|
212
|
+
}
|
|
213
|
+
],
|
|
214
|
+
type: 'row'
|
|
215
|
+
}
|
|
216
|
+
]
|
|
217
|
+
}))).toEqual(new Set([
|
|
218
|
+
'prefix'
|
|
219
|
+
]));
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
describe('restoreUploadDataFromDocument', ()=>{
|
|
223
|
+
it('should replace the complete generated file tuple and preserve missing values', ()=>{
|
|
224
|
+
expect(restoreUploadDataFromDocument({
|
|
225
|
+
filename: 'version.png',
|
|
226
|
+
focalX: 10,
|
|
227
|
+
thumbnailURL: '/version-thumbnail.png'
|
|
228
|
+
}, {
|
|
229
|
+
filename: 'current.png',
|
|
230
|
+
thumbnailURL: null
|
|
231
|
+
})).toEqual({
|
|
232
|
+
filename: 'current.png',
|
|
233
|
+
thumbnailURL: null
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
it('should restore the selected value for localized generated file data', ()=>{
|
|
237
|
+
expect(restoreUploadDataFromDocument({
|
|
238
|
+
prefix: 'version-prefix'
|
|
239
|
+
}, {
|
|
240
|
+
prefix: {
|
|
241
|
+
en: 'current-prefix',
|
|
242
|
+
es: 'prefijo-actual'
|
|
243
|
+
}
|
|
244
|
+
}, {
|
|
245
|
+
locale: 'en',
|
|
246
|
+
localizedProperties: new Set([
|
|
247
|
+
'prefix'
|
|
248
|
+
])
|
|
249
|
+
})).toEqual({
|
|
250
|
+
prefix: 'current-prefix'
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
//# sourceMappingURL=sanitizeUploadData.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/uploads/sanitizeUploadData.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport {\n getExternalUploadSource,\n getLocalizedUploadProperties,\n getUploadDestination,\n mergeUploadDataWithDocument,\n restoreUploadDataFromDocument,\n sanitizeUploadData,\n} from './sanitizeUploadData.js'\nimport { flattenAllFields } from '../utilities/flattenAllFields.js'\n\ndescribe('sanitizeUploadData', () => {\n it('should preserve only the temporary external upload source', () => {\n expect(\n getExternalUploadSource({\n alt: 'Alternative text',\n filename: 'remote.png',\n sizes: { thumbnail: { filename: 'submitted-thumbnail.png' } },\n url: 'https://example.com/remote.png',\n }),\n ).toEqual({\n filename: 'remote.png',\n url: 'https://example.com/remote.png',\n })\n })\n\n it('should remove submitted generated file data on update', () => {\n expect(\n sanitizeUploadData(\n {\n alt: 'Updated alternative text',\n filename: 'submitted.png',\n prefix: 'articles',\n sizes: {\n thumbnail: {\n filename: 'submitted-thumbnail.png',\n height: 100,\n width: 100,\n },\n },\n url: '/api/media/file/submitted.png',\n },\n 'update',\n ),\n ).toEqual({\n alt: 'Updated alternative text',\n })\n })\n\n it('should preserve a submitted prefix on create', () => {\n expect(\n sanitizeUploadData(\n {\n filename: 'submitted.png',\n prefix: 'articles',\n },\n 'create',\n ),\n ).toEqual({\n prefix: 'articles',\n })\n })\n\n it('should use a submitted prefix when writing a new file', () => {\n expect(getUploadDestination({ data: { prefix: 'articles' }, file: {} })).toEqual({\n prefix: 'articles',\n })\n })\n\n it('should use the destination bound to a client upload context', () => {\n expect(\n getUploadDestination({\n data: { prefix: 'submitted' },\n file: { clientUploadContext: { _objectKey: 'abc123', prefix: 'provider' } },\n }),\n ).toEqual({ objectKey: 'abc123', prefix: 'provider' })\n expect(\n getUploadDestination({\n data: { prefix: 'submitted' },\n file: { clientUploadContext: { key: 'provider/file.png' } },\n }),\n ).toEqual({})\n })\n\n it('should not preserve a submitted prefix without a new file', () => {\n expect(getUploadDestination({ data: { prefix: 'articles' }, file: undefined })).toEqual({})\n })\n\n it.each([\n { filename: '../submitted.png' },\n { filename: '/submitted.png' },\n { filename: 'C:\\\\submitted.png' },\n { filename: '\\\\\\\\server\\\\submitted.png' },\n { filename: 'images/../submitted.png' },\n { sizes: { thumbnail: { filename: '..\\\\submitted-thumbnail.png' } } },\n ])('should reject an invalid submitted filename', (data) => {\n expect(() => sanitizeUploadData(data, 'update')).toThrow('Invalid filename.')\n })\n})\n\ndescribe('mergeUploadDataWithDocument', () => {\n it('should add stored generated file data to an update', () => {\n expect(\n mergeUploadDataWithDocument(\n { alt: 'Updated alternative text' },\n {\n filename: 'stored.png',\n prefix: 'articles',\n sizes: {\n thumbnail: {\n filename: 'stored-thumbnail.png',\n height: 100,\n width: 100,\n },\n },\n url: '/api/media/file/stored.png',\n },\n ),\n ).toEqual({\n alt: 'Updated alternative text',\n filename: 'stored.png',\n prefix: 'articles',\n sizes: {\n thumbnail: {\n filename: 'stored-thumbnail.png',\n height: 100,\n width: 100,\n },\n },\n url: '/api/media/file/stored.png',\n })\n })\n\n it('should preserve generated file data supplied by a trusted hook', () => {\n expect(\n mergeUploadDataWithDocument(\n {\n filename: 'hook.png',\n prefix: 'hook-prefix',\n sizes: { thumbnail: { filename: 'hook-thumbnail.png' } },\n url: '/api/media/file/hook.png',\n },\n {\n filename: 'stored.png',\n prefix: 'stored-prefix',\n sizes: {\n thumbnail: { filename: 'stored-thumbnail.png', height: 100, width: 100 },\n },\n url: '/api/media/file/stored.png',\n },\n ),\n ).toEqual({\n filename: 'hook.png',\n prefix: 'hook-prefix',\n sizes: {\n thumbnail: { filename: 'hook-thumbnail.png', height: 100, width: 100 },\n },\n url: '/api/media/file/hook.png',\n })\n })\n\n it('should merge the selected value for localized generated file data', () => {\n expect(\n mergeUploadDataWithDocument(\n { alt: 'Updated alternative text' },\n { prefix: { en: 'current-prefix', es: 'prefijo-actual' } },\n { locale: 'en', localizedProperties: new Set(['prefix']) },\n ),\n ).toEqual({ alt: 'Updated alternative text', prefix: 'current-prefix' })\n })\n})\n\ndescribe('getLocalizedUploadProperties', () => {\n it('should identify localized flattened fields', () => {\n expect(\n getLocalizedUploadProperties(\n flattenAllFields({\n fields: [\n {\n fields: [\n { localized: true, name: 'prefix', type: 'text' },\n { name: 'url', type: 'text' },\n ],\n type: 'row',\n },\n ],\n }),\n ),\n ).toEqual(new Set(['prefix']))\n })\n})\n\ndescribe('restoreUploadDataFromDocument', () => {\n it('should replace the complete generated file tuple and preserve missing values', () => {\n expect(\n restoreUploadDataFromDocument(\n { filename: 'version.png', focalX: 10, thumbnailURL: '/version-thumbnail.png' },\n { filename: 'current.png', thumbnailURL: null },\n ),\n ).toEqual({ filename: 'current.png', thumbnailURL: null })\n })\n\n it('should restore the selected value for localized generated file data', () => {\n expect(\n restoreUploadDataFromDocument(\n { prefix: 'version-prefix' },\n { prefix: { en: 'current-prefix', es: 'prefijo-actual' } },\n { locale: 'en', localizedProperties: new Set(['prefix']) },\n ),\n ).toEqual({ prefix: 'current-prefix' })\n })\n})\n"],"names":["describe","expect","it","getExternalUploadSource","getLocalizedUploadProperties","getUploadDestination","mergeUploadDataWithDocument","restoreUploadDataFromDocument","sanitizeUploadData","flattenAllFields","alt","filename","sizes","thumbnail","url","toEqual","prefix","height","width","data","file","clientUploadContext","_objectKey","objectKey","key","undefined","each","toThrow","en","es","locale","localizedProperties","Set","fields","localized","name","type","focalX","thumbnailURL"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SACEC,uBAAuB,EACvBC,4BAA4B,EAC5BC,oBAA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,OACEK,4BACE;YAAEI,KAAK;QAA2B,GAClC;YAAEM,QAAQ;gBAAEY,IAAI;gBAAkBC,IAAI;YAAiB;QAAE,GACzD;YAAEC,QAAQ;YAAMC,qBAAqB,IAAIC,IAAI;gBAAC;aAAS;QAAE,IAE3DjB,OAAO,CAAC;YAAEL,KAAK;YAA4BM,QAAQ;QAAiB;IACxE;AACF;AAEAhB,SAAS,gCAAgC;IACvCE,GAAG,8CAA8C;QAC/CD,OACEG,6BACEK,iBAAiB;YACfwB,QAAQ;gBACN;oBACEA,QAAQ;wBACN;4BAAEC,WAAW;4BAAMC,MAAM;4BAAUC,MAAM;wBAAO;wBAChD;4BAAED,MAAM;4BAAOC,MAAM;wBAAO;qBAC7B;oBACDA,MAAM;gBACR;aACD;QACH,KAEFrB,OAAO,CAAC,IAAIiB,IAAI;YAAC;SAAS;IAC9B;AACF;AAEAhC,SAAS,iCAAiC;IACxCE,GAAG,gFAAgF;QACjFD,OACEM,8BACE;YAAEI,UAAU;YAAe0B,QAAQ;YAAIC,cAAc;QAAyB,GAC9E;YAAE3B,UAAU;YAAe2B,cAAc;QAAK,IAEhDvB,OAAO,CAAC;YAAEJ,UAAU;YAAe2B,cAAc;QAAK;IAC1D;IAEApC,GAAG,uEAAuE;QACxED,OACEM,8BACE;YAAES,QAAQ;QAAiB,GAC3B;YAAEA,QAAQ;gBAAEY,IAAI;gBAAkBC,IAAI;YAAiB;QAAE,GACzD;YAAEC,QAAQ;YAAMC,qBAAqB,IAAIC,IAAI;gBAAC;aAAS;QAAE,IAE3DjB,OAAO,CAAC;YAAEC,QAAQ;QAAiB;IACvC;AACF"}
|
package/dist/uploads/types.d.ts
CHANGED
|
@@ -130,6 +130,10 @@ type Admin = {
|
|
|
130
130
|
controls?: PayloadComponent[];
|
|
131
131
|
};
|
|
132
132
|
};
|
|
133
|
+
export type ExternalFileHeaderFilterContext = {
|
|
134
|
+
isSameOrigin: boolean;
|
|
135
|
+
url: string;
|
|
136
|
+
};
|
|
133
137
|
export type UploadConfig = {
|
|
134
138
|
/**
|
|
135
139
|
* The adapter name to use for uploads. Used for storage adapter telemetry.
|
|
@@ -187,8 +191,10 @@ export type UploadConfig = {
|
|
|
187
191
|
*/
|
|
188
192
|
displayPreview?: boolean;
|
|
189
193
|
/**
|
|
190
|
-
*
|
|
191
|
-
*
|
|
194
|
+
* Accepts existing headers and returns the headers after filtering or modifying. The optional
|
|
195
|
+
* context identifies the destination for the current request, including each redirect hop.
|
|
196
|
+
* `isSameOrigin` is true only when that destination matches a trusted origin established for a
|
|
197
|
+
* relative file URL.
|
|
192
198
|
* If using this option, you should handle the removal of any sensitive cookies
|
|
193
199
|
* (like payload-prefixed cookies) to prevent leaking session information to external
|
|
194
200
|
* services. By default, Payload automatically filters out payload-prefixed cookies
|
|
@@ -197,7 +203,7 @@ export type UploadConfig = {
|
|
|
197
203
|
* Useful for adding custom headers to fetch from external providers.
|
|
198
204
|
* @default undefined
|
|
199
205
|
*/
|
|
200
|
-
externalFileHeaderFilter?: (headers: Record<string, string
|
|
206
|
+
externalFileHeaderFilter?: (headers: Record<string, string>, context?: ExternalFileHeaderFilterContext) => Record<string, string>;
|
|
201
207
|
/**
|
|
202
208
|
* Field slugs to use for a compound index instead of the default filename index.
|
|
203
209
|
*/
|
|
@@ -268,6 +274,8 @@ export type UploadConfig = {
|
|
|
268
274
|
pasteURL?: {
|
|
269
275
|
allowList: AllowList;
|
|
270
276
|
} | false;
|
|
277
|
+
/** @internal Require a server-issued receipt before invoking client-upload handlers. */
|
|
278
|
+
requiresClientUploadReceipt?: boolean;
|
|
271
279
|
/**
|
|
272
280
|
* Sharp resize options for the original image.
|
|
273
281
|
* @link https://sharp.pixelplumbing.com/api-resize#resize
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/uploads/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,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KAAK,EAAE,MAAM,CAAA;IACb,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/uploads/types.ts"],"sourcesContent":["import type { ResizeOptions, Sharp, SharpOptions } from 'sharp'\n\nimport type { CollectionConfig, TypeWithID } from '../collections/config/types.js'\nimport type { PayloadComponent } from '../config/types.js'\nimport type { PayloadRequest } from '../types/index.js'\nimport type { WithMetadata } from './optionallyAppendMetadata.js'\n\nexport type FileSize = {\n filename: null | string\n filesize: null | number\n height: null | number\n mimeType: null | string\n url?: null | string // TODO V4: make non-optional\n width: null | number\n}\n\n// TODO: deprecate in Payload v4.\n/**\n * FileSizeImproved is a more precise type, and will replace FileSize in Payload v4.\n * This type is for internal use only as it will be deprecated in the future.\n * @internal\n */\nexport type FileSizeImproved = {\n url: null | string\n} & FileSize\n\nexport type FileSizes = {\n [size: string]: FileSize\n}\n\nexport type FileData = {\n filename: string\n filesize: number\n focalX?: number\n focalY?: number\n height: number\n mimeType: string\n sizes: FileSizes\n tempFilePath?: string\n url?: string\n width: number\n}\n\nexport type ProbedImageSize = {\n height: number\n width: number\n}\n\n/**\n * Params sent to the sharp `toFormat()` function\n * @link https://sharp.pixelplumbing.com/api-output#toformat\n */\nexport type ImageUploadFormatOptions = {\n format: Parameters<Sharp['toFormat']>[0]\n options?: Parameters<Sharp['toFormat']>[1]\n}\n\n/**\n * Params sent to the sharp trim() function\n * @link https://sharp.pixelplumbing.com/api-resize#trim\n */\nexport type ImageUploadTrimOptions = Parameters<Sharp['trim']>[0]\n\nexport type GenerateImageName = (args: {\n extension: string\n height: number\n originalName: string\n sizeName: string\n width: number\n}) => string\n\nexport type ImageSize = {\n /**\n * Admin UI options that control how this image size appears in list views.\n *\n * NOTE: In Payload v4, these options (`disableGroupBy`, `disableListColumn` and `disableListFilter`)\n * should default to `true` so image size subfields are hidden from list columns\n * and filters by default, reducing noise in the admin UI.\n */\n admin?: {\n /**\n * If set to true, this image size will not be available\n * as a selectable groupBy option in the collection list view.\n * @default false\n */\n disableGroupBy?: boolean\n /**\n * If set to true, this image size will not be available\n * as a selectable column in the collection list view.\n * @default false\n */\n disableListColumn?: boolean\n /**\n * If set to true, this image size will not be available\n * as a filter option in the collection list view.\n * @default false\n */\n disableListFilter?: boolean\n }\n /**\n * @deprecated prefer position\n */\n crop?: string // comes from sharp package\n formatOptions?: ImageUploadFormatOptions\n /**\n * Generate a custom name for the file of this image size.\n */\n generateImageName?: GenerateImageName\n name: string\n trimOptions?: ImageUploadTrimOptions\n /**\n * When an uploaded image is smaller than the defined image size, we have 3 options:\n *\n * `undefined | false | true`\n *\n * 1. `undefined` [default]: uploading images with smaller width AND height than the image size will return null\n * 2. `false`: always enlarge images to the image size\n * 3. `true`: if the image is smaller than the image size, return the original image\n */\n withoutEnlargement?: ResizeOptions['withoutEnlargement']\n} & Omit<ResizeOptions, 'withoutEnlargement'>\n\nexport type GetAdminThumbnail = (args: { doc: Record<string, unknown> }) => false | null | string\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 FileAllowList = Array<{\n extensions: string[]\n mimeType: string\n}>\n\ntype Admin = {\n components?: {\n /**\n * The Controls component to extend the upload controls in the admin panel.\n */\n controls?: PayloadComponent[]\n }\n}\n\nexport type UploadConfig = {\n /**\n * The adapter name to use for uploads. Used for storage adapter telemetry.\n * @default undefined\n */\n adapter?: string\n /**\n * The admin configuration for the upload field.\n */\n admin?: Admin\n /**\n * Represents an admin thumbnail, which can be either a React component or a string.\n * - If a string, it should be one of the image size names.\n * - A function that generates a fully qualified URL for the thumbnail, receives the doc as the only argument.\n **/\n adminThumbnail?: GetAdminThumbnail | string\n /**\n * Allow restricted file types known to be problematic.\n * - If set to `true`, it will allow all file types.\n * - If set to `false`, it will not allow file types and extensions known to be problematic.\n * - This setting is overriden by the `mimeTypes` option.\n * @default false\n */\n allowRestrictedFileTypes?: boolean\n /**\n * Enables bulk upload of files from the list view.\n * @default true\n */\n bulkUpload?: boolean\n /**\n * Appends a cache tag to the image URL when fetching the thumbnail in the admin panel. It may be desirable to disable this when hosting via CDNs with strict parameters.\n *\n * @default true\n */\n cacheTags?: boolean\n /**\n * Sharp constructor options to be passed to the uploaded file.\n * @link https://sharp.pixelplumbing.com/api-constructor/#sharp\n */\n constructorOptions?: SharpOptions\n /**\n * Enables cropping of images.\n * @default true\n */\n crop?: boolean\n /**\n * Disable the ability to save files to disk.\n * @default false\n */\n disableLocalStorage?: boolean\n /**\n * Enable displaying preview of the uploaded file in Upload fields related to this Collection.\n * Can be locally overridden by `displayPreview` option in Upload field.\n * @default false\n */\n displayPreview?: boolean\n /**\n *\n * Accepts existing headers and returns the headers after filtering or modifying.\n * If using this option, you should handle the removal of any sensitive cookies\n * (like payload-prefixed cookies) to prevent leaking session information to external\n * services. By default, Payload automatically filters out payload-prefixed cookies\n * when this option is NOT defined.\n *\n * Useful for adding custom headers to fetch from external providers.\n * @default undefined\n */\n externalFileHeaderFilter?: (headers: Record<string, string>) => Record<string, string>\n /**\n * Field slugs to use for a compound index instead of the default filename index.\n */\n filenameCompoundIndex?: string[]\n /**\n * Require files to be uploaded when creating a document.\n * @default true\n */\n filesRequiredOnCreate?: boolean\n /**\n * Enables focal point positioning for image manipulation.\n * @default true\n */\n focalPoint?: boolean\n /**\n * Format options for the uploaded file. Formatting image sizes needs to be done within each formatOptions individually.\n */\n formatOptions?: ImageUploadFormatOptions\n /**\n * Custom handlers to run when a file is fetched.\n *\n * - If a handler returns a Response, the response will be sent to the client and no further handlers will be run.\n * - If a handler returns null, the next handler will be run.\n * - If no handlers return a response the file will be returned by default.\n *\n * @link https://sharp.pixelplumbing.com/api-output/#toformat\n * @default undefined\n */\n handlers?: ((\n req: PayloadRequest,\n args: {\n doc: TypeWithID\n headers?: Headers\n params: {\n clientUploadContext?: unknown\n collection: string\n filename: string\n prefix?: string\n }\n },\n ) => Promise<Response> | Promise<void> | Response | void)[]\n /**\n * Set to `true` to prevent the admin UI from showing file inputs during document creation, useful for programmatic file generation.\n */\n hideFileInputOnCreate?: boolean\n /**\n * Set to `true` to prevent the admin UI having a way to remove an existing file while editing.\n */\n hideRemoveFile?: boolean\n imageSizes?: ImageSize[]\n /**\n * Restrict mimeTypes in the file picker. Array of valid mime types or mimetype wildcards\n * @example ['image/*', 'application/pdf']\n * @default undefined\n */\n mimeTypes?: string[]\n /**\n * Ability to modify the response headers fetching a file.\n * @default undefined\n */\n modifyResponseHeaders?: ({ headers }: { headers: Headers }) => Headers | void\n /**\n * Controls the behavior of pasting/uploading files from URLs.\n * If set to `false`, fetching from remote URLs is disabled.\n * If an `allowList` is provided, server-side fetching will be enabled for specified URLs.\n *\n * @default true (client-side fetching enabled)\n */\n pasteURL?:\n | {\n allowList: AllowList\n }\n | false\n /**\n * Sharp resize options for the original image.\n * @link https://sharp.pixelplumbing.com/api-resize#resize\n * @default undefined\n */\n resizeOptions?: ResizeOptions\n /**\n * Skip safe fetch when using server-side fetching for external files from these URLs.\n * @default false\n */\n skipSafeFetch?: AllowList | boolean\n /**\n * The directory to serve static files from. Defaults to collection slug.\n * @default undefined\n */\n staticDir?: string\n trimOptions?: ImageUploadTrimOptions\n /**\n * Optionally append metadata to the image during processing.\n *\n * Can be a boolean or a function.\n *\n * If true, metadata will be appended to the image.\n * If false, no metadata will be appended.\n * If a function, it will receive an object containing the metadata and should return a boolean indicating whether to append the metadata.\n * @default false\n */\n withMetadata?: WithMetadata\n}\nexport type checkFileRestrictionsParams = {\n collection: CollectionConfig\n file: File\n req: PayloadRequest\n}\n\nexport type SanitizedUploadConfig = {\n staticDir: UploadConfig['staticDir']\n} & UploadConfig\n\nexport type File = {\n /**\n * The buffer of the file.\n */\n data: Buffer\n /**\n * The mimetype of the file.\n */\n mimetype: string\n /**\n * The name of the file.\n */\n name: string\n /**\n * The size of the file in bytes.\n */\n size: number\n /**\n * Path to the temp file on disk when useTempFiles is enabled. In this case file.data will be an empty buffer.\n */\n tempFilePath?: string\n}\n\nexport type FileToSave =\n | {\n /**\n * The buffer of the file.\n */\n buffer: Buffer\n /**\n * The path to save the file.\n */\n path: string\n }\n | {\n /**\n * The path to save the file.\n */\n path: string\n /**\n * An existing file on disk to copy to `path`, instead of `buffer` - avoids loading a file\n * that's already on disk (e.g. a temp file) fully into memory just to write it back out.\n */\n sourcePath: string\n }\n\ntype Crop = {\n height: number\n unit: '%' | 'px'\n width: number\n x: number\n y: number\n}\n\nexport type FocalPoint = {\n x: number\n y: number\n}\n\nexport type UploadEdits = {\n crop?: Crop\n focalPoint?: FocalPoint\n heightInPixels?: number\n widthInPixels?: number\n}\n"],"names":[],"mappings":"AAiYA,WAKC"}
|
|
1
|
+
{"version":3,"sources":["../../src/uploads/types.ts"],"sourcesContent":["import type { ResizeOptions, Sharp, SharpOptions } from 'sharp'\n\nimport type { CollectionConfig, TypeWithID } from '../collections/config/types.js'\nimport type { PayloadComponent } from '../config/types.js'\nimport type { PayloadRequest } from '../types/index.js'\nimport type { WithMetadata } from './optionallyAppendMetadata.js'\n\nexport type FileSize = {\n filename: null | string\n filesize: null | number\n height: null | number\n mimeType: null | string\n url?: null | string // TODO V4: make non-optional\n width: null | number\n}\n\n// TODO: deprecate in Payload v4.\n/**\n * FileSizeImproved is a more precise type, and will replace FileSize in Payload v4.\n * This type is for internal use only as it will be deprecated in the future.\n * @internal\n */\nexport type FileSizeImproved = {\n url: null | string\n} & FileSize\n\nexport type FileSizes = {\n [size: string]: FileSize\n}\n\nexport type FileData = {\n filename: string\n filesize: number\n focalX?: number\n focalY?: number\n height: number\n mimeType: string\n sizes: FileSizes\n tempFilePath?: string\n url?: string\n width: number\n}\n\nexport type ProbedImageSize = {\n height: number\n width: number\n}\n\n/**\n * Params sent to the sharp `toFormat()` function\n * @link https://sharp.pixelplumbing.com/api-output#toformat\n */\nexport type ImageUploadFormatOptions = {\n format: Parameters<Sharp['toFormat']>[0]\n options?: Parameters<Sharp['toFormat']>[1]\n}\n\n/**\n * Params sent to the sharp trim() function\n * @link https://sharp.pixelplumbing.com/api-resize#trim\n */\nexport type ImageUploadTrimOptions = Parameters<Sharp['trim']>[0]\n\nexport type GenerateImageName = (args: {\n extension: string\n height: number\n originalName: string\n sizeName: string\n width: number\n}) => string\n\nexport type ImageSize = {\n /**\n * Admin UI options that control how this image size appears in list views.\n *\n * NOTE: In Payload v4, these options (`disableGroupBy`, `disableListColumn` and `disableListFilter`)\n * should default to `true` so image size subfields are hidden from list columns\n * and filters by default, reducing noise in the admin UI.\n */\n admin?: {\n /**\n * If set to true, this image size will not be available\n * as a selectable groupBy option in the collection list view.\n * @default false\n */\n disableGroupBy?: boolean\n /**\n * If set to true, this image size will not be available\n * as a selectable column in the collection list view.\n * @default false\n */\n disableListColumn?: boolean\n /**\n * If set to true, this image size will not be available\n * as a filter option in the collection list view.\n * @default false\n */\n disableListFilter?: boolean\n }\n /**\n * @deprecated prefer position\n */\n crop?: string // comes from sharp package\n formatOptions?: ImageUploadFormatOptions\n /**\n * Generate a custom name for the file of this image size.\n */\n generateImageName?: GenerateImageName\n name: string\n trimOptions?: ImageUploadTrimOptions\n /**\n * When an uploaded image is smaller than the defined image size, we have 3 options:\n *\n * `undefined | false | true`\n *\n * 1. `undefined` [default]: uploading images with smaller width AND height than the image size will return null\n * 2. `false`: always enlarge images to the image size\n * 3. `true`: if the image is smaller than the image size, return the original image\n */\n withoutEnlargement?: ResizeOptions['withoutEnlargement']\n} & Omit<ResizeOptions, 'withoutEnlargement'>\n\nexport type GetAdminThumbnail = (args: { doc: Record<string, unknown> }) => false | null | string\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 FileAllowList = Array<{\n extensions: string[]\n mimeType: string\n}>\n\ntype Admin = {\n components?: {\n /**\n * The Controls component to extend the upload controls in the admin panel.\n */\n controls?: PayloadComponent[]\n }\n}\n\nexport type ExternalFileHeaderFilterContext = {\n isSameOrigin: boolean\n url: string\n}\n\nexport type UploadConfig = {\n /**\n * The adapter name to use for uploads. Used for storage adapter telemetry.\n * @default undefined\n */\n adapter?: string\n /**\n * The admin configuration for the upload field.\n */\n admin?: Admin\n /**\n * Represents an admin thumbnail, which can be either a React component or a string.\n * - If a string, it should be one of the image size names.\n * - A function that generates a fully qualified URL for the thumbnail, receives the doc as the only argument.\n **/\n adminThumbnail?: GetAdminThumbnail | string\n /**\n * Allow restricted file types known to be problematic.\n * - If set to `true`, it will allow all file types.\n * - If set to `false`, it will not allow file types and extensions known to be problematic.\n * - This setting is overriden by the `mimeTypes` option.\n * @default false\n */\n allowRestrictedFileTypes?: boolean\n /**\n * Enables bulk upload of files from the list view.\n * @default true\n */\n bulkUpload?: boolean\n /**\n * Appends a cache tag to the image URL when fetching the thumbnail in the admin panel. It may be desirable to disable this when hosting via CDNs with strict parameters.\n *\n * @default true\n */\n cacheTags?: boolean\n /**\n * Sharp constructor options to be passed to the uploaded file.\n * @link https://sharp.pixelplumbing.com/api-constructor/#sharp\n */\n constructorOptions?: SharpOptions\n /**\n * Enables cropping of images.\n * @default true\n */\n crop?: boolean\n /**\n * Disable the ability to save files to disk.\n * @default false\n */\n disableLocalStorage?: boolean\n /**\n * Enable displaying preview of the uploaded file in Upload fields related to this Collection.\n * Can be locally overridden by `displayPreview` option in Upload field.\n * @default false\n */\n displayPreview?: boolean\n /**\n * Accepts existing headers and returns the headers after filtering or modifying. The optional\n * context identifies the destination for the current request, including each redirect hop.\n * `isSameOrigin` is true only when that destination matches a trusted origin established for a\n * relative file URL.\n * If using this option, you should handle the removal of any sensitive cookies\n * (like payload-prefixed cookies) to prevent leaking session information to external\n * services. By default, Payload automatically filters out payload-prefixed cookies\n * when this option is NOT defined.\n *\n * Useful for adding custom headers to fetch from external providers.\n * @default undefined\n */\n externalFileHeaderFilter?: (\n headers: Record<string, string>,\n context?: ExternalFileHeaderFilterContext,\n ) => Record<string, string>\n /**\n * Field slugs to use for a compound index instead of the default filename index.\n */\n filenameCompoundIndex?: string[]\n /**\n * Require files to be uploaded when creating a document.\n * @default true\n */\n filesRequiredOnCreate?: boolean\n /**\n * Enables focal point positioning for image manipulation.\n * @default true\n */\n focalPoint?: boolean\n /**\n * Format options for the uploaded file. Formatting image sizes needs to be done within each formatOptions individually.\n */\n formatOptions?: ImageUploadFormatOptions\n /**\n * Custom handlers to run when a file is fetched.\n *\n * - If a handler returns a Response, the response will be sent to the client and no further handlers will be run.\n * - If a handler returns null, the next handler will be run.\n * - If no handlers return a response the file will be returned by default.\n *\n * @link https://sharp.pixelplumbing.com/api-output/#toformat\n * @default undefined\n */\n handlers?: ((\n req: PayloadRequest,\n args: {\n doc: TypeWithID\n headers?: Headers\n params: {\n clientUploadContext?: unknown\n collection: string\n filename: string\n prefix?: string\n }\n },\n ) => Promise<Response> | Promise<void> | Response | void)[]\n /**\n * Set to `true` to prevent the admin UI from showing file inputs during document creation, useful for programmatic file generation.\n */\n hideFileInputOnCreate?: boolean\n /**\n * Set to `true` to prevent the admin UI having a way to remove an existing file while editing.\n */\n hideRemoveFile?: boolean\n imageSizes?: ImageSize[]\n /**\n * Restrict mimeTypes in the file picker. Array of valid mime types or mimetype wildcards\n * @example ['image/*', 'application/pdf']\n * @default undefined\n */\n mimeTypes?: string[]\n /**\n * Ability to modify the response headers fetching a file.\n * @default undefined\n */\n modifyResponseHeaders?: ({ headers }: { headers: Headers }) => Headers | void\n /**\n * Controls the behavior of pasting/uploading files from URLs.\n * If set to `false`, fetching from remote URLs is disabled.\n * If an `allowList` is provided, server-side fetching will be enabled for specified URLs.\n *\n * @default true (client-side fetching enabled)\n */\n pasteURL?:\n | {\n allowList: AllowList\n }\n | false\n /** @internal Require a server-issued receipt before invoking client-upload handlers. */\n requiresClientUploadReceipt?: boolean\n /**\n * Sharp resize options for the original image.\n * @link https://sharp.pixelplumbing.com/api-resize#resize\n * @default undefined\n */\n resizeOptions?: ResizeOptions\n /**\n * Skip safe fetch when using server-side fetching for external files from these URLs.\n * @default false\n */\n skipSafeFetch?: AllowList | boolean\n /**\n * The directory to serve static files from. Defaults to collection slug.\n * @default undefined\n */\n staticDir?: string\n trimOptions?: ImageUploadTrimOptions\n /**\n * Optionally append metadata to the image during processing.\n *\n * Can be a boolean or a function.\n *\n * If true, metadata will be appended to the image.\n * If false, no metadata will be appended.\n * If a function, it will receive an object containing the metadata and should return a boolean indicating whether to append the metadata.\n * @default false\n */\n withMetadata?: WithMetadata\n}\nexport type checkFileRestrictionsParams = {\n collection: CollectionConfig\n file: File\n req: PayloadRequest\n}\n\nexport type SanitizedUploadConfig = {\n staticDir: UploadConfig['staticDir']\n} & UploadConfig\n\nexport type File = {\n /**\n * The buffer of the file.\n */\n data: Buffer\n /**\n * The mimetype of the file.\n */\n mimetype: string\n /**\n * The name of the file.\n */\n name: string\n /**\n * The size of the file in bytes.\n */\n size: number\n /**\n * Path to the temp file on disk when useTempFiles is enabled. In this case file.data will be an empty buffer.\n */\n tempFilePath?: string\n}\n\nexport type FileToSave =\n | {\n /**\n * The buffer of the file.\n */\n buffer: Buffer\n /**\n * The path to save the file.\n */\n path: string\n }\n | {\n /**\n * The path to save the file.\n */\n path: string\n /**\n * An existing file on disk to copy to `path`, instead of `buffer` - avoids loading a file\n * that's already on disk (e.g. a temp file) fully into memory just to write it back out.\n */\n sourcePath: string\n }\n\ntype Crop = {\n height: number\n unit: '%' | 'px'\n width: number\n x: number\n y: number\n}\n\nexport type FocalPoint = {\n x: number\n y: number\n}\n\nexport type UploadEdits = {\n crop?: Crop\n focalPoint?: FocalPoint\n heightInPixels?: number\n widthInPixels?: number\n}\n"],"names":[],"mappings":"AA6YA,WAKC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadContentSecurityPolicy.d.ts","sourceRoot":"","sources":["../../src/uploads/uploadContentSecurityPolicy.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,8BAA8B,2DACe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/uploads/uploadContentSecurityPolicy.ts"],"sourcesContent":["export const UPLOAD_CONTENT_SECURITY_POLICY =\n \"script-src 'none'; frame-src 'none'; object-src 'none'\"\n"],"names":["UPLOAD_CONTENT_SECURITY_POLICY"],"mappings":"AAAA,OAAO,MAAMA,iCACX,yDAAwD"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const isISOBaseMediaMimeType: (mimeType: string) => boolean;
|
|
2
|
+
export declare const validateISOBaseMediaBuffer: (buffer: Buffer) => Promise<boolean>;
|
|
3
|
+
export declare const validateISOBaseMediaFile: (filePath: string) => Promise<boolean>;
|
|
4
|
+
//# sourceMappingURL=validateISOBaseMediaFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateISOBaseMediaFile.d.ts","sourceRoot":"","sources":["../../src/uploads/validateISOBaseMediaFile.ts"],"names":[],"mappings":"AAuBA,eAAO,MAAM,sBAAsB,aAAc,MAAM,KAAG,OACjB,CAAA;AA8DzC,eAAO,MAAM,0BAA0B,WAAkB,MAAM,KAAG,OAAO,CAAC,OAAO,CAG9E,CAAA;AAEH,eAAO,MAAM,wBAAwB,aAAoB,MAAM,KAAG,OAAO,CAAC,OAAO,CAiBhF,CAAA"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
const MAX_BOX_COUNT = 10_000;
|
|
3
|
+
const QUICKTIME_FIRST_BOX_TYPES = new Set([
|
|
4
|
+
'free',
|
|
5
|
+
'mdat',
|
|
6
|
+
'moov',
|
|
7
|
+
'wide'
|
|
8
|
+
]);
|
|
9
|
+
const ISO_BASE_MEDIA_MIME_TYPES = new Set([
|
|
10
|
+
'audio/mp4',
|
|
11
|
+
'audio/x-m4a',
|
|
12
|
+
'image/avif',
|
|
13
|
+
'image/heic',
|
|
14
|
+
'image/heic-sequence',
|
|
15
|
+
'image/heif',
|
|
16
|
+
'image/heif-sequence',
|
|
17
|
+
'image/x-canon-cr3',
|
|
18
|
+
'video/3gpp',
|
|
19
|
+
'video/3gpp2',
|
|
20
|
+
'video/mp4',
|
|
21
|
+
'video/quicktime',
|
|
22
|
+
'video/x-m4v'
|
|
23
|
+
]);
|
|
24
|
+
export const isISOBaseMediaMimeType = (mimeType)=>ISO_BASE_MEDIA_MIME_TYPES.has(mimeType);
|
|
25
|
+
const validateBoxStructure = async (size, readAt)=>{
|
|
26
|
+
if (!Number.isSafeInteger(size) || size < 24) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
let boxCount = 0;
|
|
30
|
+
let position = 0;
|
|
31
|
+
while(position < size){
|
|
32
|
+
if (++boxCount > MAX_BOX_COUNT || size - position < 8) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const header = await readAt(position, Math.min(16, size - position));
|
|
36
|
+
if (header.length < 8) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const boxType = header.toString('latin1', 4, 8);
|
|
40
|
+
const size32 = header.readUInt32BE(0);
|
|
41
|
+
let boxSize;
|
|
42
|
+
let headerSize = 8;
|
|
43
|
+
if (size32 === 0) {
|
|
44
|
+
boxSize = size - position;
|
|
45
|
+
} else if (size32 === 1) {
|
|
46
|
+
if (header.length < 16) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
const size64 = header.readBigUInt64BE(8);
|
|
50
|
+
if (size64 > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
boxSize = Number(size64);
|
|
54
|
+
headerSize = 16;
|
|
55
|
+
} else {
|
|
56
|
+
boxSize = size32;
|
|
57
|
+
}
|
|
58
|
+
if (boxSize < headerSize || boxSize > size - position) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
if (position === 0 && boxType === 'ftyp') {
|
|
62
|
+
const payloadSize = boxSize - headerSize;
|
|
63
|
+
if (size32 === 0 || payloadSize < 8 || (payloadSize - 8) % 4 !== 0 || boxSize === size) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
} else if (position === 0 && !QUICKTIME_FIRST_BOX_TYPES.has(boxType)) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
position += boxSize;
|
|
70
|
+
}
|
|
71
|
+
return position === size;
|
|
72
|
+
};
|
|
73
|
+
export const validateISOBaseMediaBuffer = async (buffer)=>validateBoxStructure(buffer.length, (position, length)=>Promise.resolve(buffer.subarray(position, position + length)));
|
|
74
|
+
export const validateISOBaseMediaFile = async (filePath)=>{
|
|
75
|
+
let fileHandle;
|
|
76
|
+
try {
|
|
77
|
+
fileHandle = await fs.open(filePath, 'r');
|
|
78
|
+
const { size } = await fileHandle.stat();
|
|
79
|
+
return await validateBoxStructure(size, async (position, length)=>{
|
|
80
|
+
const buffer = Buffer.allocUnsafe(length);
|
|
81
|
+
const { bytesRead } = await fileHandle.read(buffer, 0, length, position);
|
|
82
|
+
return buffer.subarray(0, bytesRead);
|
|
83
|
+
});
|
|
84
|
+
} catch {
|
|
85
|
+
return false;
|
|
86
|
+
} finally{
|
|
87
|
+
await fileHandle?.close();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=validateISOBaseMediaFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/uploads/validateISOBaseMediaFile.ts"],"sourcesContent":["import fs from 'fs/promises'\n\nconst MAX_BOX_COUNT = 10_000\nconst QUICKTIME_FIRST_BOX_TYPES = new Set(['free', 'mdat', 'moov', 'wide'])\n\nconst ISO_BASE_MEDIA_MIME_TYPES = new Set([\n 'audio/mp4',\n 'audio/x-m4a',\n 'image/avif',\n 'image/heic',\n 'image/heic-sequence',\n 'image/heif',\n 'image/heif-sequence',\n 'image/x-canon-cr3',\n 'video/3gpp',\n 'video/3gpp2',\n 'video/mp4',\n 'video/quicktime',\n 'video/x-m4v',\n])\n\ntype ReadAt = (position: number, length: number) => Promise<Buffer>\n\nexport const isISOBaseMediaMimeType = (mimeType: string): boolean =>\n ISO_BASE_MEDIA_MIME_TYPES.has(mimeType)\n\nconst validateBoxStructure = async (size: number, readAt: ReadAt): Promise<boolean> => {\n if (!Number.isSafeInteger(size) || size < 24) {\n return false\n }\n\n let boxCount = 0\n let position = 0\n\n while (position < size) {\n if (++boxCount > MAX_BOX_COUNT || size - position < 8) {\n return false\n }\n\n const header = await readAt(position, Math.min(16, size - position))\n if (header.length < 8) {\n return false\n }\n\n const boxType = header.toString('latin1', 4, 8)\n const size32 = header.readUInt32BE(0)\n let boxSize: number\n let headerSize = 8\n\n if (size32 === 0) {\n boxSize = size - position\n } else if (size32 === 1) {\n if (header.length < 16) {\n return false\n }\n\n const size64 = header.readBigUInt64BE(8)\n if (size64 > BigInt(Number.MAX_SAFE_INTEGER)) {\n return false\n }\n\n boxSize = Number(size64)\n headerSize = 16\n } else {\n boxSize = size32\n }\n\n if (boxSize < headerSize || boxSize > size - position) {\n return false\n }\n\n if (position === 0 && boxType === 'ftyp') {\n const payloadSize = boxSize - headerSize\n if (size32 === 0 || payloadSize < 8 || (payloadSize - 8) % 4 !== 0 || boxSize === size) {\n return false\n }\n } else if (position === 0 && !QUICKTIME_FIRST_BOX_TYPES.has(boxType)) {\n return false\n }\n\n position += boxSize\n }\n\n return position === size\n}\n\nexport const validateISOBaseMediaBuffer = async (buffer: Buffer): Promise<boolean> =>\n validateBoxStructure(buffer.length, (position, length) =>\n Promise.resolve(buffer.subarray(position, position + length)),\n )\n\nexport const validateISOBaseMediaFile = async (filePath: string): Promise<boolean> => {\n let fileHandle: Awaited<ReturnType<typeof fs.open>> | undefined\n\n try {\n fileHandle = await fs.open(filePath, 'r')\n const { size } = await fileHandle.stat()\n\n return await validateBoxStructure(size, async (position, length) => {\n const buffer = Buffer.allocUnsafe(length)\n const { bytesRead } = await fileHandle!.read(buffer, 0, length, position)\n return buffer.subarray(0, bytesRead)\n })\n } catch {\n return false\n } finally {\n await fileHandle?.close()\n }\n}\n"],"names":["fs","MAX_BOX_COUNT","QUICKTIME_FIRST_BOX_TYPES","Set","ISO_BASE_MEDIA_MIME_TYPES","isISOBaseMediaMimeType","mimeType","has","validateBoxStructure","size","readAt","Number","isSafeInteger","boxCount","position","header","Math","min","length","boxType","toString","size32","readUInt32BE","boxSize","headerSize","size64","readBigUInt64BE","BigInt","MAX_SAFE_INTEGER","payloadSize","validateISOBaseMediaBuffer","buffer","Promise","resolve","subarray","validateISOBaseMediaFile","filePath","fileHandle","open","stat","Buffer","allocUnsafe","bytesRead","read","close"],"mappings":"AAAA,OAAOA,QAAQ,cAAa;AAE5B,MAAMC,gBAAgB;AACtB,MAAMC,4BAA4B,IAAIC,IAAI;IAAC;IAAQ;IAAQ;IAAQ;CAAO;AAE1E,MAAMC,4BAA4B,IAAID,IAAI;IACxC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAID,OAAO,MAAME,yBAAyB,CAACC,WACrCF,0BAA0BG,GAAG,CAACD,UAAS;AAEzC,MAAME,uBAAuB,OAAOC,MAAcC;IAChD,IAAI,CAACC,OAAOC,aAAa,CAACH,SAASA,OAAO,IAAI;QAC5C,OAAO;IACT;IAEA,IAAII,WAAW;IACf,IAAIC,WAAW;IAEf,MAAOA,WAAWL,KAAM;QACtB,IAAI,EAAEI,WAAWZ,iBAAiBQ,OAAOK,WAAW,GAAG;YACrD,OAAO;QACT;QAEA,MAAMC,SAAS,MA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