@payloadcms/storage-azure 3.78.0-internal-debug.f663370 → 3.78.0-internal.5219978
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":"generateSignedURL.d.ts","sourceRoot":"","sources":["../src/generateSignedURL.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAA8B,MAAM,qBAAqB,CAAA;AACtF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"generateSignedURL.d.ts","sourceRoot":"","sources":["../src/generateSignedURL.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAA8B,MAAM,qBAAqB,CAAA;AACtF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAO7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAErD,UAAU,IAAI;IACZ,MAAM,CAAC,EAAE,mBAAmB,CAAA;IAC5B,WAAW,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAA;IAC/C,aAAa,EAAE,MAAM,CAAA;IACrB,gBAAgB,EAAE,MAAM,eAAe,CAAA;CACxC;AAID,eAAO,MAAM,2BAA2B,8DAKrC,IAAI,KAAG,cA0CT,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BlobSASPermissions, generateBlobSASQueryParameters } from '@azure/storage-blob';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { APIError, Forbidden } from 'payload';
|
|
4
|
+
import { sanitizeFilename } from 'payload/shared';
|
|
4
5
|
const defaultAccess = ({ req })=>!!req.user;
|
|
5
6
|
export const getGenerateSignedURLHandler = ({ access = defaultAccess, collections, containerName, getStorageClient })=>{
|
|
6
7
|
return async (req)=>{
|
|
@@ -19,7 +20,8 @@ export const getGenerateSignedURLHandler = ({ access = defaultAccess, collection
|
|
|
19
20
|
})) {
|
|
20
21
|
throw new Forbidden();
|
|
21
22
|
}
|
|
22
|
-
const
|
|
23
|
+
const sanitizedFilename = sanitizeFilename(filename);
|
|
24
|
+
const fileKey = path.posix.join(prefix, sanitizedFilename);
|
|
23
25
|
const blobClient = getStorageClient().getBlobClient(fileKey);
|
|
24
26
|
const sasToken = generateBlobSASQueryParameters({
|
|
25
27
|
blobName: fileKey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/generateSignedURL.ts"],"sourcesContent":["import type { ContainerClient, StorageSharedKeyCredential } from '@azure/storage-blob'\nimport type { ClientUploadsAccess } from '@payloadcms/plugin-cloud-storage/types'\nimport type { PayloadHandler } from 'payload'\n\nimport { BlobSASPermissions, generateBlobSASQueryParameters } from '@azure/storage-blob'\nimport path from 'path'\nimport { APIError, Forbidden } from 'payload'\n\nimport type { AzureStorageOptions } from './index.js'\n\ninterface Args {\n access?: ClientUploadsAccess\n collections: AzureStorageOptions['collections']\n containerName: string\n getStorageClient: () => ContainerClient\n}\n\nconst defaultAccess: Args['access'] = ({ req }) => !!req.user\n\nexport const getGenerateSignedURLHandler = ({\n access = defaultAccess,\n collections,\n containerName,\n getStorageClient,\n}: Args): PayloadHandler => {\n return async (req) => {\n if (!req.json) {\n throw new APIError('Unreachable')\n }\n\n const { collectionSlug, filename, mimeType } = (await req.json()) as {\n collectionSlug: string\n filename: string\n mimeType: string\n }\n\n const collectionS3Config = collections[collectionSlug]\n if (!collectionS3Config) {\n throw new APIError(`Collection ${collectionSlug} was not found in S3 options`)\n }\n\n const prefix = (typeof collectionS3Config === 'object' && collectionS3Config.prefix) || ''\n\n if (!(await access({ collectionSlug, req }))) {\n throw new Forbidden()\n }\n\n const fileKey = path.posix.join(prefix,
|
|
1
|
+
{"version":3,"sources":["../src/generateSignedURL.ts"],"sourcesContent":["import type { ContainerClient, StorageSharedKeyCredential } from '@azure/storage-blob'\nimport type { ClientUploadsAccess } from '@payloadcms/plugin-cloud-storage/types'\nimport type { PayloadHandler } from 'payload'\n\nimport { BlobSASPermissions, generateBlobSASQueryParameters } from '@azure/storage-blob'\nimport path from 'path'\nimport { APIError, Forbidden } from 'payload'\nimport { sanitizeFilename } from 'payload/shared'\n\nimport type { AzureStorageOptions } from './index.js'\n\ninterface Args {\n access?: ClientUploadsAccess\n collections: AzureStorageOptions['collections']\n containerName: string\n getStorageClient: () => ContainerClient\n}\n\nconst defaultAccess: Args['access'] = ({ req }) => !!req.user\n\nexport const getGenerateSignedURLHandler = ({\n access = defaultAccess,\n collections,\n containerName,\n getStorageClient,\n}: Args): PayloadHandler => {\n return async (req) => {\n if (!req.json) {\n throw new APIError('Unreachable')\n }\n\n const { collectionSlug, filename, mimeType } = (await req.json()) as {\n collectionSlug: string\n filename: string\n mimeType: string\n }\n\n const collectionS3Config = collections[collectionSlug]\n if (!collectionS3Config) {\n throw new APIError(`Collection ${collectionSlug} was not found in S3 options`)\n }\n\n const prefix = (typeof collectionS3Config === 'object' && collectionS3Config.prefix) || ''\n\n if (!(await access({ collectionSlug, req }))) {\n throw new Forbidden()\n }\n\n const sanitizedFilename = sanitizeFilename(filename)\n const fileKey = path.posix.join(prefix, sanitizedFilename)\n\n const blobClient = getStorageClient().getBlobClient(fileKey)\n\n const sasToken = generateBlobSASQueryParameters(\n {\n blobName: fileKey,\n containerName,\n contentType: mimeType,\n expiresOn: new Date(Date.now() + 30 * 60 * 1000),\n permissions: BlobSASPermissions.parse('w'),\n startsOn: new Date(),\n },\n getStorageClient().credential as StorageSharedKeyCredential,\n )\n\n return Response.json({ url: `${blobClient.url}?${sasToken.toString()}` })\n }\n}\n"],"names":["BlobSASPermissions","generateBlobSASQueryParameters","path","APIError","Forbidden","sanitizeFilename","defaultAccess","req","user","getGenerateSignedURLHandler","access","collections","containerName","getStorageClient","json","collectionSlug","filename","mimeType","collectionS3Config","prefix","sanitizedFilename","fileKey","posix","join","blobClient","getBlobClient","sasToken","blobName","contentType","expiresOn","Date","now","permissions","parse","startsOn","credential","Response","url","toString"],"mappings":"AAIA,SAASA,kBAAkB,EAAEC,8BAA8B,QAAQ,sBAAqB;AACxF,OAAOC,UAAU,OAAM;AACvB,SAASC,QAAQ,EAAEC,SAAS,QAAQ,UAAS;AAC7C,SAASC,gBAAgB,QAAQ,iBAAgB;AAWjD,MAAMC,gBAAgC,CAAC,EAAEC,GAAG,EAAE,GAAK,CAAC,CAACA,IAAIC,IAAI;AAE7D,OAAO,MAAMC,8BAA8B,CAAC,EAC1CC,SAASJ,aAAa,EACtBK,WAAW,EACXC,aAAa,EACbC,gBAAgB,EACX;IACL,OAAO,OAAON;QACZ,IAAI,CAACA,IAAIO,IAAI,EAAE;YACb,MAAM,IAAIX,SAAS;QACrB;QAEA,MAAM,EAAEY,cAAc,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAI,MAAMV,IAAIO,IAAI;QAM9D,MAAMI,qBAAqBP,WAAW,CAACI,eAAe;QACtD,IAAI,CAACG,oBAAoB;YACvB,MAAM,IAAIf,SAAS,CAAC,WAAW,EAAEY,eAAe,4BAA4B,CAAC;QAC/E;QAEA,MAAMI,SAAS,AAAC,OAAOD,uBAAuB,YAAYA,mBAAmBC,MAAM,IAAK;QAExF,IAAI,CAAE,MAAMT,OAAO;YAAEK;YAAgBR;QAAI,IAAK;YAC5C,MAAM,IAAIH;QACZ;QAEA,MAAMgB,oBAAoBf,iBAAiBW;QAC3C,MAAMK,UAAUnB,KAAKoB,KAAK,CAACC,IAAI,CAACJ,QAAQC;QAExC,MAAMI,aAAaX,mBAAmBY,aAAa,CAACJ;QAEpD,MAAMK,WAAWzB,+BACf;YACE0B,UAAUN;YACVT;YACAgB,aAAaX;YACbY,WAAW,IAAIC,KAAKA,KAAKC,GAAG,KAAK,KAAK,KAAK;YAC3CC,aAAahC,mBAAmBiC,KAAK,CAAC;YACtCC,UAAU,IAAIJ;QAChB,GACAjB,mBAAmBsB,UAAU;QAG/B,OAAOC,SAAStB,IAAI,CAAC;YAAEuB,KAAK,GAAGb,WAAWa,GAAG,CAAC,CAAC,EAAEX,SAASY,QAAQ,IAAI;QAAC;IACzE;AACF,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/storage-azure",
|
|
3
|
-
"version": "3.78.0-internal
|
|
3
|
+
"version": "3.78.0-internal.5219978",
|
|
4
4
|
"description": "Payload storage adapter for Azure Blob Storage",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@azure/abort-controller": "^1.1.0",
|
|
41
41
|
"@azure/storage-blob": "^12.11.0",
|
|
42
|
-
"@payloadcms/plugin-cloud-storage": "3.78.0-internal
|
|
42
|
+
"@payloadcms/plugin-cloud-storage": "3.78.0-internal.5219978"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"payload": "3.78.0-internal
|
|
45
|
+
"payload": "3.78.0-internal.5219978"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"payload": "3.78.0-internal
|
|
48
|
+
"payload": "3.78.0-internal.5219978"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": "^18.20.2 || >=20.9.0"
|