@nestm/storage 0.1.0-alpha.2 → 0.1.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +111 -13
- package/SECURITY.md +23 -0
- package/dist/files-sdk/files-sdk.driver.d.ts +36 -7
- package/dist/files-sdk/files-sdk.driver.d.ts.map +1 -1
- package/dist/files-sdk/files-sdk.driver.js +141 -20
- package/dist/files-sdk/files-sdk.driver.js.map +1 -1
- package/dist/files-sdk/index.d.ts +1 -1
- package/dist/files-sdk/index.d.ts.map +1 -1
- package/dist/files-sdk/index.js.map +1 -1
- package/dist/files-sdk/s3/index.d.ts +14 -0
- package/dist/files-sdk/s3/index.d.ts.map +1 -0
- package/dist/files-sdk/s3/index.js +108 -0
- package/dist/files-sdk/s3/index.js.map +1 -0
- package/dist/gateway/index.d.ts +1 -1
- package/dist/gateway/index.d.ts.map +1 -1
- package/dist/gateway/index.js.map +1 -1
- package/dist/gateway/storage-gateway.controller.d.ts +12 -11
- package/dist/gateway/storage-gateway.controller.d.ts.map +1 -1
- package/dist/gateway/storage-gateway.controller.js +209 -65
- package/dist/gateway/storage-gateway.controller.js.map +1 -1
- package/dist/gateway/storage-gateway.module.d.ts.map +1 -1
- package/dist/gateway/storage-gateway.module.js +60 -1
- package/dist/gateway/storage-gateway.module.js.map +1 -1
- package/dist/gateway/storage-gateway.tokens.d.ts +1 -0
- package/dist/gateway/storage-gateway.tokens.d.ts.map +1 -1
- package/dist/gateway/storage-gateway.tokens.js +1 -0
- package/dist/gateway/storage-gateway.tokens.js.map +1 -1
- package/dist/gateway/storage-gateway.types.d.ts +43 -0
- package/dist/gateway/storage-gateway.types.d.ts.map +1 -1
- package/dist/gateway/storage-gateway.types.js.map +1 -1
- package/dist/storage.client.d.ts +8 -1
- package/dist/storage.client.d.ts.map +1 -1
- package/dist/storage.client.js +40 -0
- package/dist/storage.client.js.map +1 -1
- package/dist/storage.driver.d.ts +6 -1
- package/dist/storage.driver.d.ts.map +1 -1
- package/dist/storage.driver.js.map +1 -1
- package/dist/storage.error.d.ts +3 -0
- package/dist/storage.error.d.ts.map +1 -1
- package/dist/storage.error.js +33 -1
- package/dist/storage.error.js.map +1 -1
- package/dist/storage.types.d.ts +39 -1
- package/dist/storage.types.d.ts.map +1 -1
- package/dist/storage.types.js.map +1 -1
- package/package.json +25 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-gateway.controller.js","sourceRoot":"","sources":["../../src/gateway/storage-gateway.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EACL,mBAAmB,EACnB,IAAI,EACJ,UAAU,EACV,MAAM,EACN,GAAG,EACH,IAAI,EACJ,aAAa,EACb,UAAU,EACV,MAAM,EACN,IAAI,EACJ,GAAG,EACH,KAAK,EACL,GAAG,EACH,GAAG,EACH,WAAW,EACX,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAQvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,qCAAqC,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EACL,uBAAuB,GAGxB,MAAM,4BAA4B,CAAC;AAiBpC,SAAS,QAAQ,CAAC,KAAc,EAAE,KAAa;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,E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;IADL,IAAI,CAAC,eAAe,CAAC;IAEnB,WAAA,IAAI,EAAE,CAAA;;;;4DA+BR;AAGK;IADL,IAAI,CAAC,aAAa,CAAC;IACF,WAAA,IAAI,EAAE,CAAA;;;;0DAkCvB;AAGK;IADL,IAAI,CAAC,MAAM,CAAC;IAEV,WAAA,IAAI,EAAE,CAAA;;;;oDAUR;AAGK;IADL,IAAI,CAAC,MAAM,CAAC;IAEV,WAAA,IAAI,EAAE,CAAA;;;;oDAUR;AAxYU,wBAAwB;IAFpC,UAAU,CAAC,SAAS,CAAC;IACrB,SAAS,CAAC,mBAAmB,CAAC;IAI1B,WAAA,MAAM,CAAC,uBAAuB,CAAC,CAAA;qCADN,cAAc;GAF/B,wBAAwB,CAsapC","sourcesContent":["import {\n BadRequestException,\n Body,\n Controller,\n Delete,\n Get,\n Head,\n HttpException,\n HttpStatus,\n Inject,\n Post,\n Put,\n Query,\n Req,\n Res,\n SetMetadata,\n UseGuards,\n} from '@nestjs/common';\nimport { ServerResponse } from 'node:http';\nimport { Readable } from 'node:stream';\nimport { pipeline } from 'node:stream/promises';\nimport type { ReadableStream as NodeReadableStream } from 'node:stream/web';\n\nimport { StorageError, StorageErrorCode } from '../storage.error.js';\nimport { StorageService } from '../storage.service.js';\nimport type {\n StorageByteRange,\n StorageObject,\n StorageObjectMetadata,\n StorageSignedDownloadOptions,\n StorageSignedUploadOptions,\n} from '../storage.types.js';\nimport { StorageGatewayGuard } from './storage-gateway.guard.js';\nimport { FASTIFY_STORAGE_UPLOAD_CONFIG } from './storage-gateway-fastify-parser.js';\nimport { STORAGE_GATEWAY_OPTIONS } from './storage-gateway.tokens.js';\nimport {\n StorageGatewayOperation,\n type ResolvedStorageGatewayOptions,\n type StorageGatewayOperation as StorageGatewayOperationName,\n} from './storage-gateway.types.js';\n\ninterface ResponseEnvelope<Result> {\n data: Result;\n}\n\ninterface ResponseWrapper {\n raw?: unknown;\n hijack?: () => void;\n}\n\ninterface RequestWrapper {\n raw?: unknown;\n body?: unknown;\n headers?: Record<string, string | string[] | undefined>;\n}\n\nfunction recordOf(value: unknown, label: string): Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new BadRequestException(`${label} must be a JSON object.`);\n }\n return value as Record<string, unknown>;\n}\n\nfunction requiredString(\n record: Record<string, unknown>,\n field: string,\n): string {\n const value = record[field];\n if (typeof value !== 'string' || value.length === 0) {\n throw new BadRequestException(`${field} must be a non-empty string.`);\n }\n return value;\n}\n\nfunction optionalString(\n record: Record<string, unknown>,\n field: string,\n): string | undefined {\n const value = record[field];\n if (value === undefined) {\n return undefined;\n }\n if (typeof value !== 'string') {\n throw new BadRequestException(`${field} must be a string.`);\n }\n return value;\n}\n\nfunction optionalNumber(\n record: Record<string, unknown>,\n field: string,\n): number | undefined {\n const value = record[field];\n if (value === undefined) {\n return undefined;\n }\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n throw new BadRequestException(`${field} must be a finite number.`);\n }\n return value;\n}\n\nfunction optionalPositiveInteger(\n record: Record<string, unknown>,\n field: string,\n): number | undefined {\n const value = optionalNumber(record, field);\n if (value !== undefined && (!Number.isSafeInteger(value) || value <= 0)) {\n throw new BadRequestException(`${field} must be a positive safe integer.`);\n }\n return value;\n}\n\nfunction optionalNonNegativeInteger(\n record: Record<string, unknown>,\n field: string,\n): number | undefined {\n const value = optionalNumber(record, field);\n if (value !== undefined && (!Number.isSafeInteger(value) || value < 0)) {\n throw new BadRequestException(\n `${field} must be a non-negative safe integer.`,\n );\n }\n return value;\n}\n\nfunction queryInteger(\n value: string | undefined,\n field: string,\n): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (!/^[0-9]+$/u.test(value)) {\n throw new BadRequestException(`${field} must be a non-negative integer.`);\n }\n const parsed = Number(value);\n if (!Number.isSafeInteger(parsed)) {\n throw new BadRequestException(`${field} must be a safe integer.`);\n }\n return parsed;\n}\n\nfunction rawResponseOf(response: unknown): ServerResponse {\n if (response instanceof ServerResponse) {\n return response;\n }\n if (typeof response === 'object' && response !== null) {\n const wrapper = response as ResponseWrapper;\n wrapper.hijack?.();\n if (wrapper.raw instanceof ServerResponse) {\n return wrapper.raw;\n }\n }\n throw new Error('Unsupported Nest HTTP response adapter.');\n}\n\nfunction requestWrapperOf(request: unknown): RequestWrapper {\n if (typeof request !== 'object' || request === null) {\n throw new BadRequestException('Unsupported Nest HTTP request adapter.');\n }\n return request as RequestWrapper;\n}\n\nfunction requestHeader(request: unknown, name: string): string | undefined {\n const headers = requestWrapperOf(request).headers;\n const value = headers?.[name];\n return Array.isArray(value) ? value[0] : value;\n}\n\nfunction uploadSourceOf(request: unknown): Readable {\n const wrapper = requestWrapperOf(request);\n if (wrapper.body instanceof Readable) {\n return wrapper.body;\n }\n if (wrapper.body instanceof Uint8Array) {\n return Readable.from([wrapper.body]);\n }\n if (request instanceof Readable && !request.readableEnded) {\n return request;\n }\n if (wrapper.raw instanceof Readable && !wrapper.raw.readableEnded) {\n return wrapper.raw;\n }\n throw new BadRequestException(\n 'Proxy uploads require an application/octet-stream request body.',\n );\n}\n\nasync function* enforceUploadLimit(\n source: Readable,\n maxBytes: number,\n): AsyncGenerator<Uint8Array> {\n let received = 0;\n for await (const chunk of source) {\n const bytes =\n typeof chunk === 'string'\n ? new TextEncoder().encode(chunk)\n : chunk instanceof Uint8Array\n ? chunk\n : undefined;\n if (bytes === undefined) {\n throw new BadRequestException(\n 'Upload streams must contain byte or string chunks.',\n );\n }\n received += bytes.byteLength;\n if (received > maxBytes) {\n throw new StorageError(\n `Proxy upload exceeds the ${maxBytes}-byte gateway limit.`,\n {\n code: StorageErrorCode.LIMIT_EXCEEDED,\n permanent: true,\n },\n );\n }\n yield bytes;\n }\n}\n\nfunction setObjectHeaders(\n response: ServerResponse,\n object: StorageObject | StorageObjectMetadata,\n): void {\n response.setHeader('content-length', String(object.size));\n response.setHeader('content-type', object.contentType);\n if (object.etag !== undefined) {\n response.setHeader('etag', object.etag);\n }\n if (object.lastModified !== undefined) {\n response.setHeader('last-modified', object.lastModified.toUTCString());\n }\n}\n\nconst publicStorageMessages: Record<StorageErrorCode, string> = {\n [StorageErrorCode.NOT_FOUND]: 'Storage object was not found.',\n [StorageErrorCode.UNAUTHORIZED]: 'Storage operation is not permitted.',\n [StorageErrorCode.CONFLICT]: 'Storage object conflict.',\n [StorageErrorCode.READ_ONLY]: 'Storage operation is not permitted.',\n [StorageErrorCode.INVALID_ARGUMENT]: 'Invalid storage request.',\n [StorageErrorCode.NOT_SUPPORTED]: 'Storage operation is not supported.',\n [StorageErrorCode.ABORTED]: 'Storage operation was aborted.',\n [StorageErrorCode.TIMEOUT]: 'Storage operation timed out.',\n [StorageErrorCode.LIMIT_EXCEEDED]: 'Storage request limit exceeded.',\n [StorageErrorCode.PROVIDER]: 'Storage provider operation failed.',\n};\n\nfunction storageHttpStatus(error: StorageError): number {\n switch (error.code) {\n case StorageErrorCode.NOT_FOUND:\n return HttpStatus.NOT_FOUND;\n case StorageErrorCode.UNAUTHORIZED:\n case StorageErrorCode.READ_ONLY:\n return HttpStatus.FORBIDDEN;\n case StorageErrorCode.CONFLICT:\n return HttpStatus.CONFLICT;\n case StorageErrorCode.INVALID_ARGUMENT:\n return HttpStatus.BAD_REQUEST;\n case StorageErrorCode.NOT_SUPPORTED:\n return HttpStatus.NOT_IMPLEMENTED;\n case StorageErrorCode.LIMIT_EXCEEDED:\n return HttpStatus.PAYLOAD_TOO_LARGE;\n case StorageErrorCode.ABORTED:\n return HttpStatus.REQUEST_TIMEOUT;\n case StorageErrorCode.TIMEOUT:\n return HttpStatus.GATEWAY_TIMEOUT;\n case StorageErrorCode.PROVIDER:\n return HttpStatus.BAD_GATEWAY;\n }\n}\n\nfunction toHttpException(error: unknown): HttpException {\n if (error instanceof HttpException) {\n return error;\n }\n if (error instanceof StorageError) {\n return new HttpException(\n {\n error: {\n code: error.code,\n message: publicStorageMessages[error.code],\n },\n },\n storageHttpStatus(error),\n { cause: error },\n );\n }\n return new HttpException(\n {\n error: {\n code: StorageErrorCode.PROVIDER,\n message: 'Storage gateway operation failed.',\n },\n },\n HttpStatus.BAD_GATEWAY,\n { cause: error },\n );\n}\n\n@Controller('storage')\n@UseGuards(StorageGatewayGuard)\nexport class StorageGatewayController {\n constructor(\n private readonly storage: StorageService,\n @Inject(STORAGE_GATEWAY_OPTIONS)\n private readonly options: ResolvedStorageGatewayOptions,\n ) {}\n\n @Get('object')\n async download(\n @Query('key') key: string | undefined,\n @Query('proxy') proxy: string | undefined,\n @Query('rangeStart') rangeStart: string | undefined,\n @Query('rangeEnd') rangeEnd: string | undefined,\n @Query('disposition') disposition: string | undefined,\n @Res() response: unknown,\n ): Promise<void> {\n await this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.DOWNLOAD);\n const objectKey = this.#key(key);\n const client = this.storage.use(this.options.store);\n const forceProxy = proxy === 'true' || proxy === '1';\n const canSign =\n this.options.operations.has(StorageGatewayOperation.SIGN_DOWNLOAD) &&\n client.capabilities.signedDownload.supported;\n\n if (!forceProxy && this.options.mode !== 'proxy' && canSign) {\n try {\n const url = await client.signDownload(objectKey, {\n expiresIn: this.options.defaultSignedUrlExpiresIn,\n ...(disposition !== undefined && {\n responseContentDisposition: disposition,\n }),\n });\n const raw = rawResponseOf(response);\n raw.statusCode = HttpStatus.TEMPORARY_REDIRECT;\n raw.setHeader('location', url);\n raw.end();\n return;\n } catch (error) {\n if (\n this.options.mode !== 'hybrid' ||\n !(error instanceof StorageError) ||\n error.code !== StorageErrorCode.NOT_SUPPORTED\n ) {\n throw error;\n }\n }\n }\n\n if (this.options.mode === 'signed') {\n throw new StorageError(\n 'Signed downloads are unavailable for this store.',\n {\n code: StorageErrorCode.NOT_SUPPORTED,\n key: objectKey,\n permanent: true,\n },\n );\n }\n\n const start = queryInteger(rangeStart, 'rangeStart');\n const end = queryInteger(rangeEnd, 'rangeEnd');\n if (end !== undefined && start === undefined) {\n throw new BadRequestException(\n 'rangeStart is required when rangeEnd is provided.',\n );\n }\n const range: StorageByteRange | undefined =\n start === undefined\n ? undefined\n : { start, ...(end !== undefined && { end }) };\n const object = await client.downloadStream(objectKey, {\n ...(range !== undefined && { range }),\n });\n const raw = rawResponseOf(response);\n raw.statusCode =\n range === undefined ? HttpStatus.OK : HttpStatus.PARTIAL_CONTENT;\n setObjectHeaders(raw, object);\n const baseContentType = object.contentType\n .split(';', 1)[0]\n ?.trim()\n .toLowerCase();\n raw.setHeader(\n 'content-disposition',\n baseContentType !== undefined &&\n this.options.proxyInlineContentTypes.has(baseContentType)\n ? 'inline'\n : 'attachment',\n );\n raw.setHeader('x-content-type-options', 'nosniff');\n if (range !== undefined) {\n raw.setHeader(\n 'content-range',\n `bytes ${range.start}-${range.start + object.size - 1}/*`,\n );\n }\n if (client.capabilities.rangeRead) {\n raw.setHeader('accept-ranges', 'bytes');\n }\n\n try {\n await pipeline(\n Readable.fromWeb(\n object.body as unknown as NodeReadableStream<Uint8Array>,\n ),\n raw,\n );\n } catch (error) {\n if (raw.headersSent) {\n raw.destroy(error instanceof Error ? error : undefined);\n return;\n }\n throw error;\n }\n });\n }\n\n @SetMetadata('__fastify_route_config__', {\n [FASTIFY_STORAGE_UPLOAD_CONFIG]: true,\n })\n @Put('object')\n async upload(\n @Query('key') key: string | undefined,\n @Req() request: unknown,\n ): Promise<ResponseEnvelope<unknown>> {\n return this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.UPLOAD);\n if (this.options.mode === 'signed') {\n throw new StorageError(\n 'Proxy uploads are disabled in signed gateway mode.',\n {\n code: StorageErrorCode.NOT_SUPPORTED,\n permanent: true,\n },\n );\n }\n const objectKey = this.#key(key);\n const transportContentType = requestHeader(request, 'content-type')\n ?.split(';', 1)[0]\n ?.trim()\n .toLowerCase();\n if (transportContentType !== 'application/octet-stream') {\n throw new BadRequestException(\n 'Proxy uploads require Content-Type: application/octet-stream.',\n );\n }\n const lengthHeader = requestHeader(request, 'content-length');\n const contentLength =\n lengthHeader === undefined\n ? undefined\n : queryInteger(lengthHeader, 'content-length');\n if (\n contentLength !== undefined &&\n contentLength > this.options.maxUploadBytes\n ) {\n throw new StorageError(\n `Proxy upload exceeds the ${this.options.maxUploadBytes}-byte gateway limit.`,\n {\n code: StorageErrorCode.LIMIT_EXCEEDED,\n key: objectKey,\n permanent: true,\n },\n );\n }\n const source = uploadSourceOf(request);\n const body = Readable.toWeb(\n Readable.from(enforceUploadLimit(source, this.options.maxUploadBytes)),\n ) as ReadableStream<Uint8Array>;\n const contentType =\n requestHeader(request, 'x-storage-content-type') ??\n 'application/octet-stream';\n const result = await this.storage\n .use(this.options.store)\n .upload(objectKey, body, { contentType, multipart: true });\n return { data: result };\n });\n }\n\n @Head('metadata')\n async head(\n @Query('key') key: string | undefined,\n @Res() response: unknown,\n ): Promise<void> {\n await this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.HEAD);\n const metadata = await this.storage\n .use(this.options.store)\n .head(this.#key(key));\n const raw = rawResponseOf(response);\n raw.statusCode = HttpStatus.OK;\n setObjectHeaders(raw, metadata);\n raw.end();\n });\n }\n\n @Delete('object')\n async delete(\n @Query('key') key: string | undefined,\n ): Promise<ResponseEnvelope<{ deleted: true }>> {\n return this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.DELETE);\n await this.storage.use(this.options.store).delete(this.#key(key));\n return { data: { deleted: true } };\n });\n }\n\n @Get('list')\n async list(\n @Query('prefix') prefix: string | undefined,\n @Query('cursor') cursor: string | undefined,\n @Query('limit') limit: string | undefined,\n @Query('delimiter') delimiter: string | undefined,\n ): Promise<ResponseEnvelope<unknown>> {\n return this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.LIST);\n const parsedLimit =\n queryInteger(limit, 'limit') ?? this.options.maxListResults;\n if (parsedLimit === 0 || parsedLimit > this.options.maxListResults) {\n throw new BadRequestException(\n `limit must be between 1 and ${this.options.maxListResults}.`,\n );\n }\n const result = await this.storage.use(this.options.store).list({\n ...(cursor !== undefined && { cursor }),\n ...(delimiter !== undefined && { delimiter }),\n limit: parsedLimit,\n ...(prefix !== undefined && { prefix }),\n });\n return { data: result };\n });\n }\n\n @Get('search')\n async search(\n @Query('pattern') pattern: string | undefined,\n @Query('prefix') prefix: string | undefined,\n @Query('limit') limit: string | undefined,\n @Query('maxResults') maxResults: string | undefined,\n @Query('match') match: string | undefined,\n @Query('caseInsensitive') caseInsensitive: string | undefined,\n ): Promise<ResponseEnvelope<unknown>> {\n return this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.SEARCH);\n const searchPattern = this.#key(pattern, 'pattern');\n if (\n match !== undefined &&\n !['glob', 'regex', 'substring', 'exact'].includes(match)\n ) {\n throw new BadRequestException('Invalid search match mode.');\n }\n const parsedLimit =\n limit === undefined ? undefined : queryInteger(limit, 'limit');\n if (\n parsedLimit !== undefined &&\n (parsedLimit === 0 || parsedLimit > this.options.maxSearchResults)\n ) {\n throw new BadRequestException(\n `limit must be between 1 and ${this.options.maxSearchResults}.`,\n );\n }\n const parsedMaxResults =\n queryInteger(maxResults, 'maxResults') ?? this.options.maxSearchResults;\n if (\n parsedMaxResults === 0 ||\n parsedMaxResults > this.options.maxSearchResults\n ) {\n throw new BadRequestException(\n `maxResults must be between 1 and ${this.options.maxSearchResults}.`,\n );\n }\n const objects: StorageObjectMetadata[] = [];\n for await (const object of this.storage\n .use(this.options.store)\n .search(searchPattern, {\n ...(caseInsensitive !== undefined && {\n caseInsensitive:\n caseInsensitive === 'true' || caseInsensitive === '1',\n }),\n ...(parsedLimit !== undefined && { limit: parsedLimit }),\n ...(match !== undefined && {\n match: match as 'glob' | 'regex' | 'substring' | 'exact',\n }),\n maxResults: parsedMaxResults,\n ...(prefix !== undefined && { prefix }),\n })) {\n objects.push(object);\n if (objects.length === parsedMaxResults) {\n break;\n }\n }\n return { data: objects };\n });\n }\n\n @Post('sign-download')\n async signDownload(\n @Body() body: unknown,\n ): Promise<ResponseEnvelope<{ url: string }>> {\n return this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.SIGN_DOWNLOAD);\n if (this.options.mode === 'proxy') {\n throw new StorageError(\n 'Signed downloads are disabled in proxy gateway mode.',\n {\n code: StorageErrorCode.NOT_SUPPORTED,\n permanent: true,\n },\n );\n }\n const input = recordOf(body, 'body');\n const responseContentDisposition = optionalString(\n input,\n 'responseContentDisposition',\n );\n const options: StorageSignedDownloadOptions = {\n expiresIn:\n optionalPositiveInteger(input, 'expiresIn') ??\n this.options.defaultSignedUrlExpiresIn,\n ...(responseContentDisposition !== undefined && {\n responseContentDisposition,\n }),\n };\n const url = await this.storage\n .use(this.options.store)\n .signDownload(requiredString(input, 'key'), options);\n return { data: { url } };\n });\n }\n\n @Post('sign-upload')\n async signUpload(@Body() body: unknown): Promise<ResponseEnvelope<unknown>> {\n return this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.SIGN_UPLOAD);\n if (this.options.mode === 'proxy') {\n throw new StorageError(\n 'Signed uploads are disabled in proxy gateway mode.',\n {\n code: StorageErrorCode.NOT_SUPPORTED,\n permanent: true,\n },\n );\n }\n const input = recordOf(body, 'body');\n const contentType = optionalString(input, 'contentType');\n const maxSize = optionalPositiveInteger(input, 'maxSize');\n const minSize = optionalNonNegativeInteger(input, 'minSize');\n if (maxSize !== undefined && minSize !== undefined && minSize > maxSize) {\n throw new BadRequestException(\n 'minSize cannot be greater than maxSize.',\n );\n }\n const options: StorageSignedUploadOptions = {\n expiresIn:\n optionalPositiveInteger(input, 'expiresIn') ??\n this.options.defaultSignedUrlExpiresIn,\n ...(contentType !== undefined && { contentType }),\n ...(maxSize !== undefined && { maxSize }),\n ...(minSize !== undefined && { minSize }),\n };\n const result = await this.storage\n .use(this.options.store)\n .signUpload(requiredString(input, 'key'), options);\n return { data: result };\n });\n }\n\n @Post('copy')\n async copy(\n @Body() body: unknown,\n ): Promise<ResponseEnvelope<{ copied: true }>> {\n return this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.COPY);\n const input = recordOf(body, 'body');\n await this.storage\n .use(this.options.store)\n .copy(requiredString(input, 'from'), requiredString(input, 'to'));\n return { data: { copied: true } };\n });\n }\n\n @Post('move')\n async move(\n @Body() body: unknown,\n ): Promise<ResponseEnvelope<{ moved: true }>> {\n return this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.MOVE);\n const input = recordOf(body, 'body');\n await this.storage\n .use(this.options.store)\n .move(requiredString(input, 'from'), requiredString(input, 'to'));\n return { data: { moved: true } };\n });\n }\n\n #assertAllowed(operation: StorageGatewayOperationName): void {\n if (!this.options.operations.has(operation)) {\n throw new HttpException(\n {\n error: {\n code: 'OPERATION_NOT_ALLOWED',\n message: `Storage gateway operation \"${operation}\" is disabled.`,\n },\n },\n HttpStatus.FORBIDDEN,\n );\n }\n }\n\n #key(value: string | undefined, label = 'key'): string {\n if (value === undefined || value.length === 0) {\n throw new BadRequestException(`${label} is required.`);\n }\n return value;\n }\n\n async #run<Result>(operation: () => Promise<Result>): Promise<Result> {\n try {\n return await operation();\n } catch (error) {\n throw toHttpException(error);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"storage-gateway.controller.js","sourceRoot":"","sources":["../../src/gateway/storage-gateway.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EACL,mBAAmB,EACnB,IAAI,EACJ,UAAU,EACV,MAAM,EACN,GAAG,EACH,IAAI,EACJ,aAAa,EACb,UAAU,EACV,MAAM,EACN,IAAI,EACJ,GAAG,EACH,KAAK,EACL,GAAG,EACH,GAAG,EACH,WAAW,EACX,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAQvD,OAAO,E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AAA,MAAM,CAAC,uBAAuB,CAAC,CAAA;IAE/B,WAAA,MAAM,CAAC,0BAA0B,CAAC,CAAA;qCAHT,cAAc;GAF/B,wBAAwB,CAmlBpC","sourcesContent":["import {\n BadRequestException,\n Body,\n Controller,\n Delete,\n Get,\n Head,\n HttpException,\n HttpStatus,\n Inject,\n Post,\n Put,\n Query,\n Req,\n Res,\n SetMetadata,\n UseGuards,\n} from '@nestjs/common';\nimport { ServerResponse } from 'node:http';\nimport { Readable } from 'node:stream';\nimport { pipeline } from 'node:stream/promises';\nimport type { ReadableStream as NodeReadableStream } from 'node:stream/web';\n\nimport {\n StorageError,\n StorageErrorCode,\n isStorageError,\n} from '../storage.error.js';\nimport { StorageService } from '../storage.service.js';\nimport type {\n StorageByteRange,\n StorageObject,\n StorageObjectMetadata,\n StorageSignedDownloadOptions,\n StorageSignedUploadOptions,\n} from '../storage.types.js';\nimport { StorageGatewayGuard } from './storage-gateway.guard.js';\nimport { FASTIFY_STORAGE_UPLOAD_CONFIG } from './storage-gateway-fastify-parser.js';\nimport {\n STORAGE_GATEWAY_KEY_POLICY,\n STORAGE_GATEWAY_OPTIONS,\n} from './storage-gateway.tokens.js';\nimport {\n StorageGatewayOperation,\n type ParsedStorageGatewayKey,\n type ResolvedStorageGatewayOptions,\n type StorageGatewayKeyPolicy,\n type StorageGatewayKeyTarget,\n type StorageGatewayOperation as StorageGatewayOperationName,\n} from './storage-gateway.types.js';\n\ninterface ResponseEnvelope<Result> {\n data: Result;\n}\n\ninterface ResponseWrapper {\n raw?: unknown;\n hijack?: () => void;\n}\n\ninterface RequestWrapper {\n raw?: unknown;\n body?: unknown;\n headers?: Record<string, string | string[] | undefined>;\n}\n\nconst MAX_GATEWAY_PATH_LENGTH = 1024;\n\nfunction parseGatewayPath(\n value: string | undefined,\n target: StorageGatewayKeyTarget,\n): ParsedStorageGatewayKey | undefined {\n if (value === undefined) {\n if (target === 'prefix') {\n return undefined;\n }\n throw new BadRequestException(`${target} is required.`);\n }\n if (value.length > MAX_GATEWAY_PATH_LENGTH) {\n throw new BadRequestException(\n `${target} cannot exceed ${MAX_GATEWAY_PATH_LENGTH} characters.`,\n );\n }\n if (value.length === 0) {\n if (target === 'prefix') {\n return Object.freeze({\n segments: Object.freeze([]),\n trailingSlash: false,\n value,\n });\n }\n throw new BadRequestException(`${target} must be a non-empty string.`);\n }\n if (\n [...value].some((character) => {\n const codePoint = character.codePointAt(0);\n return (\n character === '\\\\' ||\n codePoint === undefined ||\n codePoint <= 0x1f ||\n codePoint === 0x7f\n );\n })\n ) {\n throw new BadRequestException(\n `${target} cannot contain control characters or backslashes.`,\n );\n }\n if (target === 'pattern') {\n return Object.freeze({\n segments: Object.freeze(value.split('/')),\n trailingSlash: value.endsWith('/'),\n value,\n });\n }\n if (value.startsWith('/') || value.trim() !== value) {\n throw new BadRequestException(\n `${target} must be a relative object path without surrounding whitespace.`,\n );\n }\n const trailingSlash = value.endsWith('/');\n const segments = value.split('/');\n if (trailingSlash) {\n segments.pop();\n }\n if (\n segments.some(\n (segment) => segment.length === 0 || segment === '.' || segment === '..',\n )\n ) {\n throw new BadRequestException(\n `${target} cannot contain empty, dot, or parent path segments.`,\n );\n }\n return Object.freeze({\n segments: Object.freeze(segments),\n trailingSlash,\n value,\n });\n}\n\nfunction exactContentType(value: string, field: string): string {\n const normalized = value.toLowerCase();\n if (\n value !== normalized ||\n !/^[a-z0-9][a-z0-9!#$&^_.+-]*\\/[a-z0-9][a-z0-9!#$&^_.+-]*$/u.test(value)\n ) {\n throw new BadRequestException(\n `${field} must be a lowercase exact MIME type without parameters.`,\n );\n }\n return normalized;\n}\n\nfunction safeContentDisposition(value: string | undefined): string | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (value !== 'attachment' && value !== 'inline') {\n throw new BadRequestException(\n 'responseContentDisposition must be either \"attachment\" or \"inline\".',\n );\n }\n return value;\n}\n\nfunction recordOf(value: unknown, label: string): Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new BadRequestException(`${label} must be a JSON object.`);\n }\n return value as Record<string, unknown>;\n}\n\nfunction requiredString(\n record: Record<string, unknown>,\n field: string,\n): string {\n const value = record[field];\n if (typeof value !== 'string' || value.length === 0) {\n throw new BadRequestException(`${field} must be a non-empty string.`);\n }\n return value;\n}\n\nfunction optionalString(\n record: Record<string, unknown>,\n field: string,\n): string | undefined {\n const value = record[field];\n if (value === undefined) {\n return undefined;\n }\n if (typeof value !== 'string') {\n throw new BadRequestException(`${field} must be a string.`);\n }\n return value;\n}\n\nfunction optionalNumber(\n record: Record<string, unknown>,\n field: string,\n): number | undefined {\n const value = record[field];\n if (value === undefined) {\n return undefined;\n }\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n throw new BadRequestException(`${field} must be a finite number.`);\n }\n return value;\n}\n\nfunction optionalPositiveInteger(\n record: Record<string, unknown>,\n field: string,\n): number | undefined {\n const value = optionalNumber(record, field);\n if (value !== undefined && (!Number.isSafeInteger(value) || value <= 0)) {\n throw new BadRequestException(`${field} must be a positive safe integer.`);\n }\n return value;\n}\n\nfunction optionalNonNegativeInteger(\n record: Record<string, unknown>,\n field: string,\n): number | undefined {\n const value = optionalNumber(record, field);\n if (value !== undefined && (!Number.isSafeInteger(value) || value < 0)) {\n throw new BadRequestException(\n `${field} must be a non-negative safe integer.`,\n );\n }\n return value;\n}\n\nfunction queryInteger(\n value: string | undefined,\n field: string,\n): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (!/^[0-9]+$/u.test(value)) {\n throw new BadRequestException(`${field} must be a non-negative integer.`);\n }\n const parsed = Number(value);\n if (!Number.isSafeInteger(parsed)) {\n throw new BadRequestException(`${field} must be a safe integer.`);\n }\n return parsed;\n}\n\nfunction rawResponseOf(response: unknown): ServerResponse {\n if (response instanceof ServerResponse) {\n return response;\n }\n if (typeof response === 'object' && response !== null) {\n const wrapper = response as ResponseWrapper;\n wrapper.hijack?.();\n if (wrapper.raw instanceof ServerResponse) {\n return wrapper.raw;\n }\n }\n throw new Error('Unsupported Nest HTTP response adapter.');\n}\n\nfunction requestWrapperOf(request: unknown): RequestWrapper {\n if (typeof request !== 'object' || request === null) {\n throw new BadRequestException('Unsupported Nest HTTP request adapter.');\n }\n return request as RequestWrapper;\n}\n\nfunction requestHeader(request: unknown, name: string): string | undefined {\n const headers = requestWrapperOf(request).headers;\n const value = headers?.[name];\n return Array.isArray(value) ? value[0] : value;\n}\n\nfunction uploadSourceOf(request: unknown): Readable {\n const wrapper = requestWrapperOf(request);\n if (wrapper.body instanceof Readable) {\n return wrapper.body;\n }\n if (wrapper.body instanceof Uint8Array) {\n return Readable.from([wrapper.body]);\n }\n if (request instanceof Readable && !request.readableEnded) {\n return request;\n }\n if (wrapper.raw instanceof Readable && !wrapper.raw.readableEnded) {\n return wrapper.raw;\n }\n throw new BadRequestException(\n 'Proxy uploads require an application/octet-stream request body.',\n );\n}\n\nasync function* enforceUploadLimit(\n source: Readable,\n maxBytes: number,\n): AsyncGenerator<Uint8Array> {\n let received = 0;\n for await (const chunk of source) {\n const bytes =\n typeof chunk === 'string'\n ? new TextEncoder().encode(chunk)\n : chunk instanceof Uint8Array\n ? chunk\n : undefined;\n if (bytes === undefined) {\n throw new BadRequestException(\n 'Upload streams must contain byte or string chunks.',\n );\n }\n received += bytes.byteLength;\n if (received > maxBytes) {\n throw new StorageError(\n `Proxy upload exceeds the ${maxBytes}-byte gateway limit.`,\n {\n code: StorageErrorCode.LIMIT_EXCEEDED,\n permanent: true,\n },\n );\n }\n yield bytes;\n }\n}\n\nfunction setObjectHeaders(\n response: ServerResponse,\n object: StorageObject | StorageObjectMetadata,\n): void {\n response.setHeader('content-length', String(object.size));\n response.setHeader('content-type', object.contentType);\n if (object.etag !== undefined) {\n response.setHeader('etag', object.etag);\n }\n if (object.lastModified !== undefined) {\n response.setHeader('last-modified', object.lastModified.toUTCString());\n }\n}\n\nconst publicStorageMessages: Record<StorageErrorCode, string> = {\n [StorageErrorCode.NOT_FOUND]: 'Storage object was not found.',\n [StorageErrorCode.UNAUTHORIZED]: 'Storage operation is not permitted.',\n [StorageErrorCode.CONFLICT]: 'Storage object conflict.',\n [StorageErrorCode.READ_ONLY]: 'Storage operation is not permitted.',\n [StorageErrorCode.INVALID_ARGUMENT]: 'Invalid storage request.',\n [StorageErrorCode.NOT_SUPPORTED]: 'Storage operation is not supported.',\n [StorageErrorCode.ABORTED]: 'Storage operation was aborted.',\n [StorageErrorCode.TIMEOUT]: 'Storage operation timed out.',\n [StorageErrorCode.LIMIT_EXCEEDED]: 'Storage request limit exceeded.',\n [StorageErrorCode.PROVIDER]: 'Storage provider operation failed.',\n};\n\nfunction storageHttpStatus(error: StorageError): number {\n switch (error.code) {\n case StorageErrorCode.NOT_FOUND:\n return HttpStatus.NOT_FOUND;\n case StorageErrorCode.UNAUTHORIZED:\n case StorageErrorCode.READ_ONLY:\n return HttpStatus.FORBIDDEN;\n case StorageErrorCode.CONFLICT:\n return HttpStatus.CONFLICT;\n case StorageErrorCode.INVALID_ARGUMENT:\n return HttpStatus.BAD_REQUEST;\n case StorageErrorCode.NOT_SUPPORTED:\n return HttpStatus.NOT_IMPLEMENTED;\n case StorageErrorCode.LIMIT_EXCEEDED:\n return HttpStatus.PAYLOAD_TOO_LARGE;\n case StorageErrorCode.ABORTED:\n return HttpStatus.REQUEST_TIMEOUT;\n case StorageErrorCode.TIMEOUT:\n return HttpStatus.GATEWAY_TIMEOUT;\n case StorageErrorCode.PROVIDER:\n return HttpStatus.BAD_GATEWAY;\n }\n}\n\nfunction toHttpException(error: unknown): HttpException {\n if (error instanceof HttpException) {\n return error;\n }\n if (isStorageError(error)) {\n return new HttpException(\n {\n error: {\n code: error.code,\n message: publicStorageMessages[error.code],\n },\n },\n storageHttpStatus(error),\n { cause: error },\n );\n }\n return new HttpException(\n {\n error: {\n code: StorageErrorCode.PROVIDER,\n message: 'Storage gateway operation failed.',\n },\n },\n HttpStatus.BAD_GATEWAY,\n { cause: error },\n );\n}\n\n@Controller('storage')\n@UseGuards(StorageGatewayGuard)\nexport class StorageGatewayController {\n constructor(\n private readonly storage: StorageService,\n @Inject(STORAGE_GATEWAY_OPTIONS)\n private readonly options: ResolvedStorageGatewayOptions,\n @Inject(STORAGE_GATEWAY_KEY_POLICY)\n private readonly keyPolicy: StorageGatewayKeyPolicy,\n ) {}\n\n @Get('object')\n async download(\n @Query('key') key: string | undefined,\n @Query('proxy') proxy: string | undefined,\n @Query('rangeStart') rangeStart: string | undefined,\n @Query('rangeEnd') rangeEnd: string | undefined,\n @Query('disposition') disposition: string | undefined,\n @Req() request: unknown,\n @Res() response: unknown,\n ): Promise<void> {\n await this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.DOWNLOAD);\n const responseContentDisposition = safeContentDisposition(disposition);\n const client = this.storage.use(this.options.store);\n const forceProxy = proxy === 'true' || proxy === '1';\n const canSign =\n this.options.operations.has(StorageGatewayOperation.SIGN_DOWNLOAD) &&\n client.capabilities.signedDownload.supported &&\n client.capabilities.signedDownloadPolicy?.expiresIn === true;\n\n if (!forceProxy && this.options.mode !== 'proxy' && canSign) {\n try {\n const signedObjectKey = await this.#resolvePath(\n request,\n StorageGatewayOperation.SIGN_DOWNLOAD,\n 'key',\n key,\n );\n const url = await client.signDownload(signedObjectKey, {\n expiresIn: this.options.defaultSignedUrlExpiresIn,\n ...(responseContentDisposition !== undefined && {\n responseContentDisposition,\n }),\n });\n const raw = rawResponseOf(response);\n raw.statusCode = HttpStatus.TEMPORARY_REDIRECT;\n raw.setHeader('location', url);\n raw.end();\n return;\n } catch (error) {\n if (\n this.options.mode !== 'hybrid' ||\n !isStorageError(error) ||\n error.code !== StorageErrorCode.NOT_SUPPORTED\n ) {\n throw error;\n }\n }\n }\n\n if (this.options.mode === 'signed') {\n throw new StorageError(\n 'Signed downloads are unavailable for this store.',\n {\n code: StorageErrorCode.NOT_SUPPORTED,\n permanent: true,\n },\n );\n }\n\n const objectKey = await this.#resolvePath(\n request,\n StorageGatewayOperation.DOWNLOAD,\n 'key',\n key,\n );\n\n const start = queryInteger(rangeStart, 'rangeStart');\n const end = queryInteger(rangeEnd, 'rangeEnd');\n if (end !== undefined && start === undefined) {\n throw new BadRequestException(\n 'rangeStart is required when rangeEnd is provided.',\n );\n }\n const range: StorageByteRange | undefined =\n start === undefined\n ? undefined\n : { start, ...(end !== undefined && { end }) };\n const object = await client.downloadStream(objectKey, {\n ...(range !== undefined && { range }),\n });\n const raw = rawResponseOf(response);\n raw.statusCode =\n range === undefined ? HttpStatus.OK : HttpStatus.PARTIAL_CONTENT;\n setObjectHeaders(raw, object);\n const baseContentType = object.contentType\n .split(';', 1)[0]\n ?.trim()\n .toLowerCase();\n raw.setHeader(\n 'content-disposition',\n baseContentType !== undefined &&\n this.options.proxyInlineContentTypes.has(baseContentType)\n ? 'inline'\n : 'attachment',\n );\n raw.setHeader('x-content-type-options', 'nosniff');\n if (range !== undefined) {\n raw.setHeader(\n 'content-range',\n `bytes ${range.start}-${range.start + object.size - 1}/*`,\n );\n }\n if (client.capabilities.rangeRead) {\n raw.setHeader('accept-ranges', 'bytes');\n }\n\n try {\n await pipeline(\n Readable.fromWeb(\n object.body as unknown as NodeReadableStream<Uint8Array>,\n ),\n raw,\n );\n } catch (error) {\n if (raw.headersSent) {\n raw.destroy(error instanceof Error ? error : undefined);\n return;\n }\n throw error;\n }\n });\n }\n\n @SetMetadata('__fastify_route_config__', {\n [FASTIFY_STORAGE_UPLOAD_CONFIG]: true,\n })\n @Put('object')\n async upload(\n @Query('key') key: string | undefined,\n @Req() request: unknown,\n ): Promise<ResponseEnvelope<unknown>> {\n return this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.UPLOAD);\n if (this.options.mode === 'signed') {\n throw new StorageError(\n 'Proxy uploads are disabled in signed gateway mode.',\n {\n code: StorageErrorCode.NOT_SUPPORTED,\n permanent: true,\n },\n );\n }\n const objectKey = await this.#resolvePath(\n request,\n StorageGatewayOperation.UPLOAD,\n 'key',\n key,\n );\n const transportContentType = requestHeader(request, 'content-type')\n ?.split(';', 1)[0]\n ?.trim()\n .toLowerCase();\n if (transportContentType !== 'application/octet-stream') {\n throw new BadRequestException(\n 'Proxy uploads require Content-Type: application/octet-stream.',\n );\n }\n const lengthHeader = requestHeader(request, 'content-length');\n const contentLength =\n lengthHeader === undefined\n ? undefined\n : queryInteger(lengthHeader, 'content-length');\n if (\n contentLength !== undefined &&\n contentLength > this.options.maxUploadBytes\n ) {\n throw new StorageError(\n `Proxy upload exceeds the ${this.options.maxUploadBytes}-byte gateway limit.`,\n {\n code: StorageErrorCode.LIMIT_EXCEEDED,\n key: objectKey,\n permanent: true,\n },\n );\n }\n const source = uploadSourceOf(request);\n const body = Readable.toWeb(\n Readable.from(enforceUploadLimit(source, this.options.maxUploadBytes)),\n ) as ReadableStream<Uint8Array>;\n const contentType = exactContentType(\n requestHeader(request, 'x-storage-content-type') ??\n 'application/octet-stream',\n 'x-storage-content-type',\n );\n const result = await this.storage\n .use(this.options.store)\n .upload(objectKey, body, { contentType, multipart: true });\n return { data: result };\n });\n }\n\n @Head('metadata')\n async head(\n @Query('key') key: string | undefined,\n @Req() request: unknown,\n @Res() response: unknown,\n ): Promise<void> {\n await this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.HEAD);\n const objectKey = await this.#resolvePath(\n request,\n StorageGatewayOperation.HEAD,\n 'key',\n key,\n );\n const metadata = await this.storage\n .use(this.options.store)\n .head(objectKey);\n const raw = rawResponseOf(response);\n raw.statusCode = HttpStatus.OK;\n setObjectHeaders(raw, metadata);\n raw.end();\n });\n }\n\n @Delete('object')\n async delete(\n @Query('key') key: string | undefined,\n @Req() request: unknown,\n ): Promise<ResponseEnvelope<{ deleted: true }>> {\n return this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.DELETE);\n const objectKey = await this.#resolvePath(\n request,\n StorageGatewayOperation.DELETE,\n 'key',\n key,\n );\n await this.storage.use(this.options.store).delete(objectKey);\n return { data: { deleted: true } };\n });\n }\n\n @Get('list')\n async list(\n @Query('prefix') prefix: string | undefined,\n @Query('cursor') cursor: string | undefined,\n @Query('limit') limit: string | undefined,\n @Query('delimiter') delimiter: string | undefined,\n @Req() request: unknown,\n ): Promise<ResponseEnvelope<unknown>> {\n return this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.LIST);\n const parsedLimit =\n queryInteger(limit, 'limit') ?? this.options.maxListResults;\n if (parsedLimit === 0 || parsedLimit > this.options.maxListResults) {\n throw new BadRequestException(\n `limit must be between 1 and ${this.options.maxListResults}.`,\n );\n }\n const resolvedPrefix = await this.#resolvePath(\n request,\n StorageGatewayOperation.LIST,\n 'prefix',\n prefix,\n );\n const result = await this.storage.use(this.options.store).list({\n ...(cursor !== undefined && { cursor }),\n ...(delimiter !== undefined && { delimiter }),\n limit: parsedLimit,\n prefix: resolvedPrefix,\n });\n return { data: result };\n });\n }\n\n @Get('search')\n async search(\n @Query('pattern') pattern: string | undefined,\n @Query('prefix') prefix: string | undefined,\n @Query('limit') limit: string | undefined,\n @Query('maxResults') maxResults: string | undefined,\n @Query('match') match: string | undefined,\n @Query('caseInsensitive') caseInsensitive: string | undefined,\n @Req() request: unknown,\n ): Promise<ResponseEnvelope<unknown>> {\n return this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.SEARCH);\n const searchPattern = await this.#resolvePath(\n request,\n StorageGatewayOperation.SEARCH,\n 'pattern',\n pattern,\n );\n const resolvedPrefix = await this.#resolvePath(\n request,\n StorageGatewayOperation.SEARCH,\n 'prefix',\n prefix,\n );\n if (\n match !== undefined &&\n !['glob', 'regex', 'substring', 'exact'].includes(match)\n ) {\n throw new BadRequestException('Invalid search match mode.');\n }\n const parsedLimit =\n limit === undefined ? undefined : queryInteger(limit, 'limit');\n if (\n parsedLimit !== undefined &&\n (parsedLimit === 0 || parsedLimit > this.options.maxSearchResults)\n ) {\n throw new BadRequestException(\n `limit must be between 1 and ${this.options.maxSearchResults}.`,\n );\n }\n const parsedMaxResults =\n queryInteger(maxResults, 'maxResults') ?? this.options.maxSearchResults;\n if (\n parsedMaxResults === 0 ||\n parsedMaxResults > this.options.maxSearchResults\n ) {\n throw new BadRequestException(\n `maxResults must be between 1 and ${this.options.maxSearchResults}.`,\n );\n }\n const objects: StorageObjectMetadata[] = [];\n for await (const object of this.storage\n .use(this.options.store)\n .search(searchPattern, {\n ...(caseInsensitive !== undefined && {\n caseInsensitive:\n caseInsensitive === 'true' || caseInsensitive === '1',\n }),\n ...(parsedLimit !== undefined && { limit: parsedLimit }),\n ...(match !== undefined && {\n match: match as 'glob' | 'regex' | 'substring' | 'exact',\n }),\n maxResults: parsedMaxResults,\n prefix: resolvedPrefix,\n })) {\n objects.push(object);\n if (objects.length === parsedMaxResults) {\n break;\n }\n }\n return { data: objects };\n });\n }\n\n @Post('sign-download')\n async signDownload(\n @Body() body: unknown,\n @Req() request: unknown,\n ): Promise<ResponseEnvelope<{ url: string }>> {\n return this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.SIGN_DOWNLOAD);\n if (this.options.mode === 'proxy') {\n throw new StorageError(\n 'Signed downloads are disabled in proxy gateway mode.',\n {\n code: StorageErrorCode.NOT_SUPPORTED,\n permanent: true,\n },\n );\n }\n const input = recordOf(body, 'body');\n const responseContentDisposition = safeContentDisposition(\n optionalString(input, 'responseContentDisposition'),\n );\n const options: StorageSignedDownloadOptions = {\n expiresIn: this.#signedExpiry(input),\n ...(responseContentDisposition !== undefined && {\n responseContentDisposition,\n }),\n };\n const objectKey = await this.#resolvePath(\n request,\n StorageGatewayOperation.SIGN_DOWNLOAD,\n 'key',\n requiredString(input, 'key'),\n );\n const client = this.storage.use(this.options.store);\n if (client.capabilities.signedDownloadPolicy?.expiresIn !== true) {\n throw new StorageError(\n 'This store cannot prove that signed-download expiry is provider-enforced.',\n {\n code: StorageErrorCode.NOT_SUPPORTED,\n key: objectKey,\n operation: 'signDownload',\n permanent: true,\n },\n );\n }\n const url = await client.signDownload(objectKey, options);\n return { data: { url } };\n });\n }\n\n @Post('sign-upload')\n async signUpload(\n @Body() body: unknown,\n @Req() request: unknown,\n ): Promise<ResponseEnvelope<unknown>> {\n return this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.SIGN_UPLOAD);\n if (this.options.mode === 'proxy') {\n throw new StorageError(\n 'Signed uploads are disabled in proxy gateway mode.',\n {\n code: StorageErrorCode.NOT_SUPPORTED,\n permanent: true,\n },\n );\n }\n const input = recordOf(body, 'body');\n const rawContentType = optionalString(input, 'contentType');\n if (rawContentType === undefined) {\n throw new BadRequestException(\n 'contentType is required for signed uploads.',\n );\n }\n const contentType = exactContentType(rawContentType, 'contentType');\n if (!this.options.signedUploadContentTypes.has(contentType)) {\n throw new BadRequestException(\n `contentType \"${contentType}\" is not allowed for signed uploads.`,\n );\n }\n const requestedMaxSize = optionalPositiveInteger(input, 'maxSize');\n if (\n requestedMaxSize !== undefined &&\n requestedMaxSize > this.options.maxSignedUploadBytes\n ) {\n throw new StorageError(\n `Signed upload exceeds the ${this.options.maxSignedUploadBytes}-byte gateway limit.`,\n {\n code: StorageErrorCode.LIMIT_EXCEEDED,\n permanent: true,\n },\n );\n }\n const maxSize = requestedMaxSize ?? this.options.maxSignedUploadBytes;\n const minSize = optionalNonNegativeInteger(input, 'minSize');\n if (maxSize !== undefined && minSize !== undefined && minSize > maxSize) {\n throw new BadRequestException(\n 'minSize cannot be greater than maxSize.',\n );\n }\n const options: StorageSignedUploadOptions = {\n contentType,\n expiresIn: this.#signedExpiry(input),\n maxSize,\n ...(minSize !== undefined && { minSize }),\n };\n const objectKey = await this.#resolvePath(\n request,\n StorageGatewayOperation.SIGN_UPLOAD,\n 'key',\n requiredString(input, 'key'),\n );\n const client = this.storage.use(this.options.store);\n const policyCapability = client.capabilities.signedUploadPolicy;\n if (\n policyCapability?.contentType !== true ||\n policyCapability.sizeRange !== true\n ) {\n throw new StorageError(\n 'This store cannot prove that signed-upload MIME and size constraints are provider-enforced.',\n {\n code: StorageErrorCode.NOT_SUPPORTED,\n key: objectKey,\n operation: 'signUpload',\n permanent: true,\n },\n );\n }\n const result = await client.signUpload(objectKey, options);\n return { data: result };\n });\n }\n\n @Post('copy')\n async copy(\n @Body() body: unknown,\n @Req() request: unknown,\n ): Promise<ResponseEnvelope<{ copied: true }>> {\n return this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.COPY);\n const input = recordOf(body, 'body');\n const [from, to] = await Promise.all([\n this.#resolvePath(\n request,\n StorageGatewayOperation.COPY,\n 'from',\n requiredString(input, 'from'),\n ),\n this.#resolvePath(\n request,\n StorageGatewayOperation.COPY,\n 'to',\n requiredString(input, 'to'),\n ),\n ]);\n await this.storage.use(this.options.store).copy(from, to);\n return { data: { copied: true } };\n });\n }\n\n @Post('move')\n async move(\n @Body() body: unknown,\n @Req() request: unknown,\n ): Promise<ResponseEnvelope<{ moved: true }>> {\n return this.#run(async () => {\n this.#assertAllowed(StorageGatewayOperation.MOVE);\n const input = recordOf(body, 'body');\n const [from, to] = await Promise.all([\n this.#resolvePath(\n request,\n StorageGatewayOperation.MOVE,\n 'from',\n requiredString(input, 'from'),\n ),\n this.#resolvePath(\n request,\n StorageGatewayOperation.MOVE,\n 'to',\n requiredString(input, 'to'),\n ),\n ]);\n await this.storage.use(this.options.store).move(from, to);\n return { data: { moved: true } };\n });\n }\n\n #assertAllowed(operation: StorageGatewayOperationName): void {\n if (!this.options.operations.has(operation)) {\n throw new HttpException(\n {\n error: {\n code: 'OPERATION_NOT_ALLOWED',\n message: `Storage gateway operation \"${operation}\" is disabled.`,\n },\n },\n HttpStatus.FORBIDDEN,\n );\n }\n }\n\n async #resolvePath(\n request: unknown,\n operation: StorageGatewayOperationName,\n target: StorageGatewayKeyTarget,\n value: string | undefined,\n ): Promise<string> {\n const input = parseGatewayPath(value, target);\n const resolved = await this.keyPolicy.resolve({\n input,\n operation,\n request,\n target,\n });\n const parsed = parseGatewayPath(resolved, target);\n if (parsed === undefined) {\n throw new StorageError(\n `Storage gateway key policy did not resolve ${target}.`,\n {\n code: StorageErrorCode.UNAUTHORIZED,\n operation,\n permanent: true,\n },\n );\n }\n return parsed.value;\n }\n\n #signedExpiry(input: Record<string, unknown>): number {\n const expiresIn =\n optionalPositiveInteger(input, 'expiresIn') ??\n this.options.defaultSignedUrlExpiresIn;\n if (expiresIn > this.options.maxSignedUrlExpiresIn) {\n throw new BadRequestException(\n `expiresIn cannot exceed ${this.options.maxSignedUrlExpiresIn} seconds.`,\n );\n }\n return expiresIn;\n }\n\n async #run<Result>(operation: () => Promise<Result>): Promise<Result> {\n try {\n return await operation();\n } catch (error) {\n throw toHttpException(error);\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-gateway.module.d.ts","sourceRoot":"","sources":["../../src/gateway/storage-gateway.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"storage-gateway.module.d.ts","sourceRoot":"","sources":["../../src/gateway/storage-gateway.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,gBAAgB,CAAC;AAUxB,OAAO,EAIL,KAAK,qBAAqB,EAC3B,MAAM,4BAA4B,CAAC;AAmJpC,qBACa,oBAAoB;IAC/B,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,qBAAqB,GAAG,aAAa;CA6C/D"}
|
|
@@ -9,9 +9,13 @@ import { Module, } from '@nestjs/common';
|
|
|
9
9
|
import { StorageGatewayController } from './storage-gateway.controller.js';
|
|
10
10
|
import { StorageGatewayFastifyParser } from './storage-gateway-fastify-parser.js';
|
|
11
11
|
import { StorageGatewayGuard } from './storage-gateway.guard.js';
|
|
12
|
-
import { STORAGE_GATEWAY_GUARDS, STORAGE_GATEWAY_OPTIONS, } from './storage-gateway.tokens.js';
|
|
12
|
+
import { STORAGE_GATEWAY_GUARDS, STORAGE_GATEWAY_KEY_POLICY, STORAGE_GATEWAY_OPTIONS, } from './storage-gateway.tokens.js';
|
|
13
13
|
import { StorageGatewayOperation, } from './storage-gateway.types.js';
|
|
14
14
|
const operations = new Set(Object.values(StorageGatewayOperation));
|
|
15
|
+
function isExactContentType(value) {
|
|
16
|
+
return (typeof value === 'string' &&
|
|
17
|
+
/^[a-z0-9][a-z0-9!#$&^_.+-]*\/[a-z0-9][a-z0-9!#$&^_.+-]*$/u.test(value));
|
|
18
|
+
}
|
|
15
19
|
function resolveOptions(options) {
|
|
16
20
|
if (options.operations.length === 0) {
|
|
17
21
|
throw new TypeError('StorageGatewayModule requires a non-empty operation allowlist.');
|
|
@@ -25,6 +29,14 @@ function resolveOptions(options) {
|
|
|
25
29
|
options.allowUnauthenticated !== true) {
|
|
26
30
|
throw new TypeError('StorageGatewayModule requires at least one Nest guard. Set allowUnauthenticated: true only for explicit development use.');
|
|
27
31
|
}
|
|
32
|
+
if (options.keyPolicy === undefined &&
|
|
33
|
+
options.unsafeAllowUnscopedKeys !== true) {
|
|
34
|
+
throw new TypeError('StorageGatewayModule requires a keyPolicy. Set unsafeAllowUnscopedKeys: true only as an explicit migration escape hatch.');
|
|
35
|
+
}
|
|
36
|
+
if (options.keyPolicy !== undefined &&
|
|
37
|
+
options.unsafeAllowUnscopedKeys === true) {
|
|
38
|
+
throw new TypeError('StorageGatewayModule cannot combine keyPolicy with unsafeAllowUnscopedKeys.');
|
|
39
|
+
}
|
|
28
40
|
if (options.mode !== undefined &&
|
|
29
41
|
!['proxy', 'signed', 'hybrid'].includes(options.mode)) {
|
|
30
42
|
throw new TypeError(`Unknown storage gateway mode: ${options.mode}.`);
|
|
@@ -46,6 +58,30 @@ function resolveOptions(options) {
|
|
|
46
58
|
defaultSignedUrlExpiresIn <= 0) {
|
|
47
59
|
throw new TypeError('defaultSignedUrlExpiresIn must be a positive safe integer.');
|
|
48
60
|
}
|
|
61
|
+
const maxSignedUrlExpiresIn = options.maxSignedUrlExpiresIn ?? 3600;
|
|
62
|
+
if (!Number.isSafeInteger(maxSignedUrlExpiresIn) ||
|
|
63
|
+
maxSignedUrlExpiresIn <= 0) {
|
|
64
|
+
throw new TypeError('maxSignedUrlExpiresIn must be a positive safe integer.');
|
|
65
|
+
}
|
|
66
|
+
if (defaultSignedUrlExpiresIn > maxSignedUrlExpiresIn) {
|
|
67
|
+
throw new TypeError('defaultSignedUrlExpiresIn cannot exceed maxSignedUrlExpiresIn.');
|
|
68
|
+
}
|
|
69
|
+
const maxSignedUploadBytes = options.maxSignedUploadBytes ?? maxUploadBytes;
|
|
70
|
+
if (!Number.isSafeInteger(maxSignedUploadBytes) ||
|
|
71
|
+
maxSignedUploadBytes <= 0) {
|
|
72
|
+
throw new TypeError('maxSignedUploadBytes must be a positive safe integer.');
|
|
73
|
+
}
|
|
74
|
+
const signedUploadContentTypes = options.signedUploadContentTypes ?? [
|
|
75
|
+
'application/octet-stream',
|
|
76
|
+
];
|
|
77
|
+
if (signedUploadContentTypes.length === 0) {
|
|
78
|
+
throw new TypeError('signedUploadContentTypes must contain at least one exact MIME type.');
|
|
79
|
+
}
|
|
80
|
+
for (const contentType of signedUploadContentTypes) {
|
|
81
|
+
if (!isExactContentType(contentType)) {
|
|
82
|
+
throw new TypeError('signedUploadContentTypes must contain lowercase exact MIME types without parameters.');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
49
85
|
const proxyInlineContentTypes = options.proxyInlineContentTypes ?? [];
|
|
50
86
|
for (const contentType of proxyInlineContentTypes) {
|
|
51
87
|
if (typeof contentType !== 'string' ||
|
|
@@ -60,10 +96,13 @@ function resolveOptions(options) {
|
|
|
60
96
|
defaultSignedUrlExpiresIn,
|
|
61
97
|
maxListResults,
|
|
62
98
|
maxSearchResults,
|
|
99
|
+
maxSignedUploadBytes,
|
|
100
|
+
maxSignedUrlExpiresIn,
|
|
63
101
|
maxUploadBytes,
|
|
64
102
|
mode: options.mode ?? 'hybrid',
|
|
65
103
|
operations: new Set(options.operations),
|
|
66
104
|
proxyInlineContentTypes: new Set(proxyInlineContentTypes.map((contentType) => contentType.toLowerCase())),
|
|
105
|
+
signedUploadContentTypes: new Set(signedUploadContentTypes),
|
|
67
106
|
...(options.store !== undefined && { store: options.store }),
|
|
68
107
|
};
|
|
69
108
|
}
|
|
@@ -78,6 +117,25 @@ let StorageGatewayModule = StorageGatewayModule_1 = class StorageGatewayModule {
|
|
|
78
117
|
inject: [...guardTokens],
|
|
79
118
|
useFactory: (...guards) => guards,
|
|
80
119
|
};
|
|
120
|
+
const keyPolicyProvider = options.keyPolicy === undefined
|
|
121
|
+
? {
|
|
122
|
+
provide: STORAGE_GATEWAY_KEY_POLICY,
|
|
123
|
+
useValue: {
|
|
124
|
+
resolve({ input, target }) {
|
|
125
|
+
if (input !== undefined) {
|
|
126
|
+
return input.value;
|
|
127
|
+
}
|
|
128
|
+
if (target === 'prefix') {
|
|
129
|
+
return '';
|
|
130
|
+
}
|
|
131
|
+
throw new TypeError(`${target} is required.`);
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
}
|
|
135
|
+
: {
|
|
136
|
+
provide: STORAGE_GATEWAY_KEY_POLICY,
|
|
137
|
+
useExisting: options.keyPolicy,
|
|
138
|
+
};
|
|
81
139
|
return {
|
|
82
140
|
module: StorageGatewayModule_1,
|
|
83
141
|
imports: options.imports ?? [],
|
|
@@ -85,6 +143,7 @@ let StorageGatewayModule = StorageGatewayModule_1 = class StorageGatewayModule {
|
|
|
85
143
|
providers: [
|
|
86
144
|
{ provide: STORAGE_GATEWAY_OPTIONS, useValue: resolved },
|
|
87
145
|
guardsProvider,
|
|
146
|
+
keyPolicyProvider,
|
|
88
147
|
StorageGatewayGuard,
|
|
89
148
|
StorageGatewayFastifyParser,
|
|
90
149
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-gateway.module.js","sourceRoot":"","sources":["../../src/gateway/storage-gateway.module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EACL,MAAM,GAIP,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,wBAAwB,EAAE,MAAM,iC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MAAM,CAAC,EAAE,CAAC;GACE,oBAAoB,CAyBhC","sourcesContent":["import {\n Module,\n type CanActivate,\n type DynamicModule,\n type Provider,\n} from '@nestjs/common';\n\nimport { StorageGatewayController } from './storage-gateway.controller.js';\nimport { StorageGatewayFastifyParser } from './storage-gateway-fastify-parser.js';\nimport { StorageGatewayGuard } from './storage-gateway.guard.js';\nimport {\n STORAGE_GATEWAY_GUARDS,\n STORAGE_GATEWAY_OPTIONS,\n} from './storage-gateway.tokens.js';\nimport {\n StorageGatewayOperation,\n type ResolvedStorageGatewayOptions,\n type StorageGatewayOptions,\n} from './storage-gateway.types.js';\n\nconst operations = new Set(Object.values(StorageGatewayOperation));\n\nfunction resolveOptions(\n options: StorageGatewayOptions,\n): ResolvedStorageGatewayOptions {\n if (options.operations.length === 0) {\n throw new TypeError(\n 'StorageGatewayModule requires a non-empty operation allowlist.',\n );\n }\n for (const operation of options.operations) {\n if (!operations.has(operation)) {\n throw new TypeError(\n `Unknown storage gateway operation: ${String(operation)}.`,\n );\n }\n }\n if (\n (options.guards?.length ?? 0) === 0 &&\n options.allowUnauthenticated !== true\n ) {\n throw new TypeError(\n 'StorageGatewayModule requires at least one Nest guard. Set allowUnauthenticated: true only for explicit development use.',\n );\n }\n if (\n options.mode !== undefined &&\n !['proxy', 'signed', 'hybrid'].includes(options.mode)\n ) {\n throw new TypeError(`Unknown storage gateway mode: ${options.mode}.`);\n }\n const maxUploadBytes = options.maxUploadBytes ?? 100 * 1024 * 1024;\n if (!Number.isSafeInteger(maxUploadBytes) || maxUploadBytes <= 0) {\n throw new TypeError('maxUploadBytes must be a positive safe integer.');\n }\n const maxListResults = options.maxListResults ?? 1000;\n if (!Number.isSafeInteger(maxListResults) || maxListResults <= 0) {\n throw new TypeError('maxListResults must be a positive safe integer.');\n }\n const maxSearchResults = options.maxSearchResults ?? 1000;\n if (!Number.isSafeInteger(maxSearchResults) || maxSearchResults <= 0) {\n throw new TypeError('maxSearchResults must be a positive safe integer.');\n }\n const defaultSignedUrlExpiresIn = options.defaultSignedUrlExpiresIn ?? 300;\n if (\n !Number.isSafeInteger(defaultSignedUrlExpiresIn) ||\n defaultSignedUrlExpiresIn <= 0\n ) {\n throw new TypeError(\n 'defaultSignedUrlExpiresIn must be a positive safe integer.',\n );\n }\n const proxyInlineContentTypes = options.proxyInlineContentTypes ?? [];\n for (const contentType of proxyInlineContentTypes) {\n if (\n typeof contentType !== 'string' ||\n contentType.length === 0 ||\n contentType.trim() !== contentType ||\n contentType.includes(';')\n ) {\n throw new TypeError(\n 'proxyInlineContentTypes must contain exact, non-empty MIME types without parameters.',\n );\n }\n }\n\n return {\n allowUnauthenticated: options.allowUnauthenticated === true,\n defaultSignedUrlExpiresIn,\n maxListResults,\n maxSearchResults,\n maxUploadBytes,\n mode: options.mode ?? 'hybrid',\n operations: new Set(options.operations),\n proxyInlineContentTypes: new Set(\n proxyInlineContentTypes.map((contentType) => contentType.toLowerCase()),\n ),\n ...(options.store !== undefined && { store: options.store }),\n };\n}\n\n@Module({})\nexport class StorageGatewayModule {\n static register(options: StorageGatewayOptions): DynamicModule {\n const resolved = resolveOptions(options);\n const guardTokens = options.guards ?? [];\n const guardsProvider: Provider =\n guardTokens.length === 0\n ? { provide: STORAGE_GATEWAY_GUARDS, useValue: [] }\n : {\n provide: STORAGE_GATEWAY_GUARDS,\n inject: [...guardTokens],\n useFactory: (...guards: CanActivate[]) => guards,\n };\n\n return {\n module: StorageGatewayModule,\n imports: options.imports ?? [],\n controllers: [StorageGatewayController],\n providers: [\n { provide: STORAGE_GATEWAY_OPTIONS, useValue: resolved },\n guardsProvider,\n StorageGatewayGuard,\n StorageGatewayFastifyParser,\n ],\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"storage-gateway.module.js","sourceRoot":"","sources":["../../src/gateway/storage-gateway.module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EACL,MAAM,GAIP,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,wBAAwB,EAAE,M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,CAAC,CAAC;gBACE,OAAO,EAAE,0BAA0B;gBACnC,QAAQ,EAAE;oBACR,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE;wBACvB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;4BACxB,OAAO,KAAK,CAAC,KAAK,CAAC;wBACrB,CAAC;wBACD,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;4BACxB,OAAO,EAAE,CAAC;wBACZ,CAAC;wBACD,MAAM,IAAI,SAAS,CAAC,GAAG,MAAM,eAAe,CAAC,CAAC;oBAChD,CAAC;iBACgC;aACpC;YACH,CAAC,CAAC;gBACE,OAAO,EAAE,0BAA0B;gBACnC,WAAW,EAAE,OAAO,CAAC,SAAS;aAC/B,CAAC;QAER,OAAO;YACL,MAAM,EAAE,sBAAoB;YAC5B,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;YAC9B,WAAW,EAAE,CAAC,wBAAwB,CAAC;YACvC,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,QAAQ,EAAE;gBACxD,cAAc;gBACd,iBAAiB;gBACjB,mBAAmB;gBACnB,2BAA2B;aAC5B;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA9CY,oBAAoB;IADhC,MAAM,CAAC,EAAE,CAAC;GACE,oBAAoB,CA8ChC","sourcesContent":["import {\n Module,\n type CanActivate,\n type DynamicModule,\n type Provider,\n} from '@nestjs/common';\n\nimport { StorageGatewayController } from './storage-gateway.controller.js';\nimport { StorageGatewayFastifyParser } from './storage-gateway-fastify-parser.js';\nimport { StorageGatewayGuard } from './storage-gateway.guard.js';\nimport {\n STORAGE_GATEWAY_GUARDS,\n STORAGE_GATEWAY_KEY_POLICY,\n STORAGE_GATEWAY_OPTIONS,\n} from './storage-gateway.tokens.js';\nimport {\n StorageGatewayOperation,\n type ResolvedStorageGatewayOptions,\n type StorageGatewayKeyPolicy,\n type StorageGatewayOptions,\n} from './storage-gateway.types.js';\n\nconst operations = new Set(Object.values(StorageGatewayOperation));\n\nfunction isExactContentType(value: unknown): value is string {\n return (\n typeof value === 'string' &&\n /^[a-z0-9][a-z0-9!#$&^_.+-]*\\/[a-z0-9][a-z0-9!#$&^_.+-]*$/u.test(value)\n );\n}\n\nfunction resolveOptions(\n options: StorageGatewayOptions,\n): ResolvedStorageGatewayOptions {\n if (options.operations.length === 0) {\n throw new TypeError(\n 'StorageGatewayModule requires a non-empty operation allowlist.',\n );\n }\n for (const operation of options.operations) {\n if (!operations.has(operation)) {\n throw new TypeError(\n `Unknown storage gateway operation: ${String(operation)}.`,\n );\n }\n }\n if (\n (options.guards?.length ?? 0) === 0 &&\n options.allowUnauthenticated !== true\n ) {\n throw new TypeError(\n 'StorageGatewayModule requires at least one Nest guard. Set allowUnauthenticated: true only for explicit development use.',\n );\n }\n if (\n options.keyPolicy === undefined &&\n options.unsafeAllowUnscopedKeys !== true\n ) {\n throw new TypeError(\n 'StorageGatewayModule requires a keyPolicy. Set unsafeAllowUnscopedKeys: true only as an explicit migration escape hatch.',\n );\n }\n if (\n options.keyPolicy !== undefined &&\n options.unsafeAllowUnscopedKeys === true\n ) {\n throw new TypeError(\n 'StorageGatewayModule cannot combine keyPolicy with unsafeAllowUnscopedKeys.',\n );\n }\n if (\n options.mode !== undefined &&\n !['proxy', 'signed', 'hybrid'].includes(options.mode)\n ) {\n throw new TypeError(`Unknown storage gateway mode: ${options.mode}.`);\n }\n const maxUploadBytes = options.maxUploadBytes ?? 100 * 1024 * 1024;\n if (!Number.isSafeInteger(maxUploadBytes) || maxUploadBytes <= 0) {\n throw new TypeError('maxUploadBytes must be a positive safe integer.');\n }\n const maxListResults = options.maxListResults ?? 1000;\n if (!Number.isSafeInteger(maxListResults) || maxListResults <= 0) {\n throw new TypeError('maxListResults must be a positive safe integer.');\n }\n const maxSearchResults = options.maxSearchResults ?? 1000;\n if (!Number.isSafeInteger(maxSearchResults) || maxSearchResults <= 0) {\n throw new TypeError('maxSearchResults must be a positive safe integer.');\n }\n const defaultSignedUrlExpiresIn = options.defaultSignedUrlExpiresIn ?? 300;\n if (\n !Number.isSafeInteger(defaultSignedUrlExpiresIn) ||\n defaultSignedUrlExpiresIn <= 0\n ) {\n throw new TypeError(\n 'defaultSignedUrlExpiresIn must be a positive safe integer.',\n );\n }\n const maxSignedUrlExpiresIn = options.maxSignedUrlExpiresIn ?? 3600;\n if (\n !Number.isSafeInteger(maxSignedUrlExpiresIn) ||\n maxSignedUrlExpiresIn <= 0\n ) {\n throw new TypeError(\n 'maxSignedUrlExpiresIn must be a positive safe integer.',\n );\n }\n if (defaultSignedUrlExpiresIn > maxSignedUrlExpiresIn) {\n throw new TypeError(\n 'defaultSignedUrlExpiresIn cannot exceed maxSignedUrlExpiresIn.',\n );\n }\n const maxSignedUploadBytes = options.maxSignedUploadBytes ?? maxUploadBytes;\n if (\n !Number.isSafeInteger(maxSignedUploadBytes) ||\n maxSignedUploadBytes <= 0\n ) {\n throw new TypeError(\n 'maxSignedUploadBytes must be a positive safe integer.',\n );\n }\n const signedUploadContentTypes = options.signedUploadContentTypes ?? [\n 'application/octet-stream',\n ];\n if (signedUploadContentTypes.length === 0) {\n throw new TypeError(\n 'signedUploadContentTypes must contain at least one exact MIME type.',\n );\n }\n for (const contentType of signedUploadContentTypes) {\n if (!isExactContentType(contentType)) {\n throw new TypeError(\n 'signedUploadContentTypes must contain lowercase exact MIME types without parameters.',\n );\n }\n }\n const proxyInlineContentTypes = options.proxyInlineContentTypes ?? [];\n for (const contentType of proxyInlineContentTypes) {\n if (\n typeof contentType !== 'string' ||\n contentType.length === 0 ||\n contentType.trim() !== contentType ||\n contentType.includes(';')\n ) {\n throw new TypeError(\n 'proxyInlineContentTypes must contain exact, non-empty MIME types without parameters.',\n );\n }\n }\n\n return {\n allowUnauthenticated: options.allowUnauthenticated === true,\n defaultSignedUrlExpiresIn,\n maxListResults,\n maxSearchResults,\n maxSignedUploadBytes,\n maxSignedUrlExpiresIn,\n maxUploadBytes,\n mode: options.mode ?? 'hybrid',\n operations: new Set(options.operations),\n proxyInlineContentTypes: new Set(\n proxyInlineContentTypes.map((contentType) => contentType.toLowerCase()),\n ),\n signedUploadContentTypes: new Set(signedUploadContentTypes),\n ...(options.store !== undefined && { store: options.store }),\n };\n}\n\n@Module({})\nexport class StorageGatewayModule {\n static register(options: StorageGatewayOptions): DynamicModule {\n const resolved = resolveOptions(options);\n const guardTokens = options.guards ?? [];\n const guardsProvider: Provider =\n guardTokens.length === 0\n ? { provide: STORAGE_GATEWAY_GUARDS, useValue: [] }\n : {\n provide: STORAGE_GATEWAY_GUARDS,\n inject: [...guardTokens],\n useFactory: (...guards: CanActivate[]) => guards,\n };\n const keyPolicyProvider: Provider =\n options.keyPolicy === undefined\n ? {\n provide: STORAGE_GATEWAY_KEY_POLICY,\n useValue: {\n resolve({ input, target }) {\n if (input !== undefined) {\n return input.value;\n }\n if (target === 'prefix') {\n return '';\n }\n throw new TypeError(`${target} is required.`);\n },\n } satisfies StorageGatewayKeyPolicy,\n }\n : {\n provide: STORAGE_GATEWAY_KEY_POLICY,\n useExisting: options.keyPolicy,\n };\n\n return {\n module: StorageGatewayModule,\n imports: options.imports ?? [],\n controllers: [StorageGatewayController],\n providers: [\n { provide: STORAGE_GATEWAY_OPTIONS, useValue: resolved },\n guardsProvider,\n keyPolicyProvider,\n StorageGatewayGuard,\n StorageGatewayFastifyParser,\n ],\n };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-gateway.tokens.d.ts","sourceRoot":"","sources":["../../src/gateway/storage-gateway.tokens.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,eAEnC,CAAC;AAEF,eAAO,MAAM,sBAAsB,eAElC,CAAC"}
|
|
1
|
+
{"version":3,"file":"storage-gateway.tokens.d.ts","sourceRoot":"","sources":["../../src/gateway/storage-gateway.tokens.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,eAEnC,CAAC;AAEF,eAAO,MAAM,sBAAsB,eAElC,CAAC;AAEF,eAAO,MAAM,0BAA0B,eAEtC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export const STORAGE_GATEWAY_OPTIONS = Symbol.for('@nestm/storage/gateway/options');
|
|
2
2
|
export const STORAGE_GATEWAY_GUARDS = Symbol.for('@nestm/storage/gateway/guards');
|
|
3
|
+
export const STORAGE_GATEWAY_KEY_POLICY = Symbol.for('@nestm/storage/gateway/key-policy');
|
|
3
4
|
//# sourceMappingURL=storage-gateway.tokens.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-gateway.tokens.js","sourceRoot":"","sources":["../../src/gateway/storage-gateway.tokens.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAC/C,gCAAgC,CACjC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,CAC9C,+BAA+B,CAChC,CAAC","sourcesContent":["export const STORAGE_GATEWAY_OPTIONS = Symbol.for(\n '@nestm/storage/gateway/options',\n);\n\nexport const STORAGE_GATEWAY_GUARDS = Symbol.for(\n '@nestm/storage/gateway/guards',\n);\n"]}
|
|
1
|
+
{"version":3,"file":"storage-gateway.tokens.js","sourceRoot":"","sources":["../../src/gateway/storage-gateway.tokens.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAC/C,gCAAgC,CACjC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,CAC9C,+BAA+B,CAChC,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAClD,mCAAmC,CACpC,CAAC","sourcesContent":["export const STORAGE_GATEWAY_OPTIONS = Symbol.for(\n '@nestm/storage/gateway/options',\n);\n\nexport const STORAGE_GATEWAY_GUARDS = Symbol.for(\n '@nestm/storage/gateway/guards',\n);\n\nexport const STORAGE_GATEWAY_KEY_POLICY = Symbol.for(\n '@nestm/storage/gateway/key-policy',\n);\n"]}
|
|
@@ -13,6 +13,27 @@ export declare const StorageGatewayOperation: {
|
|
|
13
13
|
};
|
|
14
14
|
export type StorageGatewayOperation = (typeof StorageGatewayOperation)[keyof typeof StorageGatewayOperation];
|
|
15
15
|
export type StorageGatewayMode = 'proxy' | 'signed' | 'hybrid';
|
|
16
|
+
export type StorageGatewayKeyTarget = 'key' | 'prefix' | 'pattern' | 'from' | 'to';
|
|
17
|
+
/** A path parsed before it crosses the application's key policy boundary. */
|
|
18
|
+
export interface ParsedStorageGatewayKey {
|
|
19
|
+
readonly value: string;
|
|
20
|
+
readonly segments: readonly string[];
|
|
21
|
+
readonly trailingSlash: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface StorageGatewayKeyPolicyContext {
|
|
24
|
+
readonly operation: StorageGatewayOperation;
|
|
25
|
+
readonly target: StorageGatewayKeyTarget;
|
|
26
|
+
readonly request: unknown;
|
|
27
|
+
/** Undefined only for an omitted list/search prefix. */
|
|
28
|
+
readonly input: ParsedStorageGatewayKey | undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Resolves an untrusted, parsed gateway path to the exact provider key/prefix.
|
|
32
|
+
* Throw to deny. The returned value is parsed again before provider use.
|
|
33
|
+
*/
|
|
34
|
+
export interface StorageGatewayKeyPolicy {
|
|
35
|
+
resolve(context: StorageGatewayKeyPolicyContext): string | Promise<string>;
|
|
36
|
+
}
|
|
16
37
|
export interface StorageGatewayOptions {
|
|
17
38
|
/**
|
|
18
39
|
* Module exporting StorageService. Required when StorageModule is not global.
|
|
@@ -32,6 +53,16 @@ export interface StorageGatewayOptions {
|
|
|
32
53
|
* gateway.
|
|
33
54
|
*/
|
|
34
55
|
allowUnauthenticated?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Existing provider implementing the mandatory key authorization/scope
|
|
58
|
+
* boundary. It may be request scoped.
|
|
59
|
+
*/
|
|
60
|
+
keyPolicy?: InjectionToken<StorageGatewayKeyPolicy>;
|
|
61
|
+
/**
|
|
62
|
+
* Migration-only escape hatch preserving caller-controlled keys. It cannot
|
|
63
|
+
* be combined with keyPolicy and must never be used on an exposed gateway.
|
|
64
|
+
*/
|
|
65
|
+
unsafeAllowUnscopedKeys?: boolean;
|
|
35
66
|
/** Defaults to hybrid: prefer signed downloads, proxy when unavailable. */
|
|
36
67
|
mode?: StorageGatewayMode;
|
|
37
68
|
/** Proxy upload ceiling. Defaults to 100 MiB. */
|
|
@@ -50,6 +81,15 @@ export interface StorageGatewayOptions {
|
|
|
50
81
|
proxyInlineContentTypes?: readonly string[];
|
|
51
82
|
/** Default signed-download lifetime. Defaults to 300 seconds. */
|
|
52
83
|
defaultSignedUrlExpiresIn?: number;
|
|
84
|
+
/** Hard ceiling for every signed URL. Defaults to 3,600 seconds. */
|
|
85
|
+
maxSignedUrlExpiresIn?: number;
|
|
86
|
+
/** Hard signed-upload ceiling. Defaults to maxUploadBytes. */
|
|
87
|
+
maxSignedUploadBytes?: number;
|
|
88
|
+
/**
|
|
89
|
+
* Exact MIME allowlist for direct uploads. Defaults to only
|
|
90
|
+
* application/octet-stream; signed-upload callers must always provide one.
|
|
91
|
+
*/
|
|
92
|
+
signedUploadContentTypes?: readonly string[];
|
|
53
93
|
}
|
|
54
94
|
export interface ResolvedStorageGatewayOptions {
|
|
55
95
|
store?: string;
|
|
@@ -61,5 +101,8 @@ export interface ResolvedStorageGatewayOptions {
|
|
|
61
101
|
maxSearchResults: number;
|
|
62
102
|
proxyInlineContentTypes: ReadonlySet<string>;
|
|
63
103
|
defaultSignedUrlExpiresIn: number;
|
|
104
|
+
maxSignedUrlExpiresIn: number;
|
|
105
|
+
maxSignedUploadBytes: number;
|
|
106
|
+
signedUploadContentTypes: ReadonlySet<string>;
|
|
64
107
|
}
|
|
65
108
|
//# sourceMappingURL=storage-gateway.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-gateway.types.d.ts","sourceRoot":"","sources":["../../src/gateway/storage-gateway.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,cAAc,EACf,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,uBAAuB;;;;;;;;;;;CAW1B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,OAAO,uBAAuB,CAAC,CAAC;AAEzE,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE/D,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;IACpC,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gFAAgF;IAChF,UAAU,EAAE,SAAS,uBAAuB,EAAE,CAAC;IAC/C;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC;IAChD;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,2EAA2E;IAC3E,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wEAAwE;IACxE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,uBAAuB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,iEAAiE;IACjE,yBAAyB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"storage-gateway.types.d.ts","sourceRoot":"","sources":["../../src/gateway/storage-gateway.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,cAAc,EACf,MAAM,gBAAgB,CA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AAM,uBAAuB,GAAG;IACrC,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,aAAa,EAAE,cAAc;IAC7B,WAAW,EAAE,YAAY;IACzB,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;CACJ,CAAC","sourcesContent":["import type {\n CanActivate,\n InjectionToken,\n ModuleMetadata,\n} from '@nestjs/common';\n\nexport const StorageGatewayOperation = {\n DOWNLOAD: 'download',\n UPLOAD: 'upload',\n HEAD: 'head',\n DELETE: 'delete',\n LIST: 'list',\n SEARCH: 'search',\n SIGN_DOWNLOAD: 'signDownload',\n SIGN_UPLOAD: 'signUpload',\n COPY: 'copy',\n MOVE: 'move',\n} as const;\n\nexport type StorageGatewayOperation =\n (typeof StorageGatewayOperation)[keyof typeof StorageGatewayOperation];\n\nexport type StorageGatewayMode = 'proxy' | 'signed' | 'hybrid';\n\nexport interface StorageGatewayOptions {\n /**\n * Module exporting StorageService. Required when StorageModule is not global.\n */\n imports?: ModuleMetadata['imports'];\n /** Store used by the gateway. Omit to use StorageService's default. */\n store?: string;\n /** Deny-by-default operation allowlist. Must contain at least one operation. */\n operations: readonly StorageGatewayOperation[];\n /**\n * Existing Nest guard providers. Every guard must allow the request.\n * Registration fails when omitted unless allowUnauthenticated is true.\n */\n guards?: readonly InjectionToken<CanActivate>[];\n /**\n * Explicit development escape hatch. Never enable this on an internet-facing\n * gateway.\n */\n allowUnauthenticated?: boolean;\n /** Defaults to hybrid: prefer signed downloads, proxy when unavailable. */\n mode?: StorageGatewayMode;\n /** Proxy upload ceiling. Defaults to 100 MiB. */\n maxUploadBytes?: number;\n /** Maximum list page size exposed by the gateway. Defaults to 1,000. */\n maxListResults?: number;\n /**\n * Maximum number of search results materialized by one gateway request.\n * Defaults to 1,000.\n */\n maxSearchResults?: number;\n /**\n * Exact MIME types that proxy downloads may render inline. Everything else\n * is served as an attachment. Defaults to an empty allowlist.\n */\n proxyInlineContentTypes?: readonly string[];\n /** Default signed-download lifetime. Defaults to 300 seconds. */\n defaultSignedUrlExpiresIn?: number;\n}\n\nexport interface ResolvedStorageGatewayOptions {\n store?: string;\n operations: ReadonlySet<StorageGatewayOperation>;\n allowUnauthenticated: boolean;\n mode: StorageGatewayMode;\n maxUploadBytes: number;\n maxListResults: number;\n maxSearchResults: number;\n proxyInlineContentTypes: ReadonlySet<string>;\n defaultSignedUrlExpiresIn: number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"storage-gateway.types.js","sourceRoot":"","sources":["../../src/gateway/storage-gateway.types.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,aAAa,EAAE,cAAc;IAC7B,WAAW,EAAE,YAAY;IACzB,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;CACJ,CAAC","sourcesContent":["import type {\n CanActivate,\n InjectionToken,\n ModuleMetadata,\n} from '@nestjs/common';\n\nexport const StorageGatewayOperation = {\n DOWNLOAD: 'download',\n UPLOAD: 'upload',\n HEAD: 'head',\n DELETE: 'delete',\n LIST: 'list',\n SEARCH: 'search',\n SIGN_DOWNLOAD: 'signDownload',\n SIGN_UPLOAD: 'signUpload',\n COPY: 'copy',\n MOVE: 'move',\n} as const;\n\nexport type StorageGatewayOperation =\n (typeof StorageGatewayOperation)[keyof typeof StorageGatewayOperation];\n\nexport type StorageGatewayMode = 'proxy' | 'signed' | 'hybrid';\n\nexport type StorageGatewayKeyTarget =\n 'key' | 'prefix' | 'pattern' | 'from' | 'to';\n\n/** A path parsed before it crosses the application's key policy boundary. */\nexport interface ParsedStorageGatewayKey {\n readonly value: string;\n readonly segments: readonly string[];\n readonly trailingSlash: boolean;\n}\n\nexport interface StorageGatewayKeyPolicyContext {\n readonly operation: StorageGatewayOperation;\n readonly target: StorageGatewayKeyTarget;\n readonly request: unknown;\n /** Undefined only for an omitted list/search prefix. */\n readonly input: ParsedStorageGatewayKey | undefined;\n}\n\n/**\n * Resolves an untrusted, parsed gateway path to the exact provider key/prefix.\n * Throw to deny. The returned value is parsed again before provider use.\n */\nexport interface StorageGatewayKeyPolicy {\n resolve(context: StorageGatewayKeyPolicyContext): string | Promise<string>;\n}\n\nexport interface StorageGatewayOptions {\n /**\n * Module exporting StorageService. Required when StorageModule is not global.\n */\n imports?: ModuleMetadata['imports'];\n /** Store used by the gateway. Omit to use StorageService's default. */\n store?: string;\n /** Deny-by-default operation allowlist. Must contain at least one operation. */\n operations: readonly StorageGatewayOperation[];\n /**\n * Existing Nest guard providers. Every guard must allow the request.\n * Registration fails when omitted unless allowUnauthenticated is true.\n */\n guards?: readonly InjectionToken<CanActivate>[];\n /**\n * Explicit development escape hatch. Never enable this on an internet-facing\n * gateway.\n */\n allowUnauthenticated?: boolean;\n /**\n * Existing provider implementing the mandatory key authorization/scope\n * boundary. It may be request scoped.\n */\n keyPolicy?: InjectionToken<StorageGatewayKeyPolicy>;\n /**\n * Migration-only escape hatch preserving caller-controlled keys. It cannot\n * be combined with keyPolicy and must never be used on an exposed gateway.\n */\n unsafeAllowUnscopedKeys?: boolean;\n /** Defaults to hybrid: prefer signed downloads, proxy when unavailable. */\n mode?: StorageGatewayMode;\n /** Proxy upload ceiling. Defaults to 100 MiB. */\n maxUploadBytes?: number;\n /** Maximum list page size exposed by the gateway. Defaults to 1,000. */\n maxListResults?: number;\n /**\n * Maximum number of search results materialized by one gateway request.\n * Defaults to 1,000.\n */\n maxSearchResults?: number;\n /**\n * Exact MIME types that proxy downloads may render inline. Everything else\n * is served as an attachment. Defaults to an empty allowlist.\n */\n proxyInlineContentTypes?: readonly string[];\n /** Default signed-download lifetime. Defaults to 300 seconds. */\n defaultSignedUrlExpiresIn?: number;\n /** Hard ceiling for every signed URL. Defaults to 3,600 seconds. */\n maxSignedUrlExpiresIn?: number;\n /** Hard signed-upload ceiling. Defaults to maxUploadBytes. */\n maxSignedUploadBytes?: number;\n /**\n * Exact MIME allowlist for direct uploads. Defaults to only\n * application/octet-stream; signed-upload callers must always provide one.\n */\n signedUploadContentTypes?: readonly string[];\n}\n\nexport interface ResolvedStorageGatewayOptions {\n store?: string;\n operations: ReadonlySet<StorageGatewayOperation>;\n allowUnauthenticated: boolean;\n mode: StorageGatewayMode;\n maxUploadBytes: number;\n maxListResults: number;\n maxSearchResults: number;\n proxyInlineContentTypes: ReadonlySet<string>;\n defaultSignedUrlExpiresIn: number;\n maxSignedUrlExpiresIn: number;\n maxSignedUploadBytes: number;\n signedUploadContentTypes: ReadonlySet<string>;\n}\n"]}
|
package/dist/storage.client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StorageDriver } from './storage.driver.js';
|
|
2
|
-
import type { StorageBody, StorageBufferedDownloadOptions, StorageBulkOptions, StorageCapabilities, StorageDeleteManyResult, StorageDownloadManyResult, StorageDownloadOptions, StorageExistsManyResult, StorageHeadManyResult, StorageListOptions, StorageListResult, StorageObject, StorageObjectMetadata, StorageOperationOptions, StoragePlugin, StorageSearchOptions, StorageSignedDownloadOptions, StorageSignedUpload, StorageSignedUploadOptions, StorageUploadManyItem, StorageUploadManyOptions, StorageUploadManyResult, StorageUploadOptions, StorageUploadResult } from './storage.types.js';
|
|
2
|
+
import type { StorageBody, StorageBufferedDownloadOptions, StorageBulkOptions, StorageCapabilities, StorageDeleteManyResult, StorageDownloadManyResult, StorageDownloadOptions, StorageExistsManyResult, StorageHeadManyResult, StorageListOptions, StorageListResult, StorageObject, StorageObjectMetadata, StorageOperationOptions, StoragePlugin, StoragePromotionOptions, StorageSearchOptions, StorageSignedDownloadOptions, StorageSignedUpload, StorageSignedUploadOptions, StorageUploadManyItem, StorageUploadManyOptions, StorageUploadManyResult, StorageUploadOptions, StorageUploadResult } from './storage.types.js';
|
|
3
3
|
export declare const DEFAULT_BUFFER_LIMIT: number;
|
|
4
4
|
type BulkOperationOptions = StorageBulkOptions & StorageOperationOptions;
|
|
5
5
|
type DownloadManyOptions = StorageBulkOptions & StorageDownloadOptions;
|
|
@@ -16,6 +16,8 @@ export interface StorageFileHandle {
|
|
|
16
16
|
signUpload(options: StorageSignedUploadOptions): Promise<StorageSignedUpload>;
|
|
17
17
|
copyTo(destinationKey: string, options?: StorageOperationOptions): Promise<void>;
|
|
18
18
|
moveTo(destinationKey: string, options?: StorageOperationOptions): Promise<void>;
|
|
19
|
+
/** Conditionally copies this staged object and deliberately retains it. */
|
|
20
|
+
promoteTo(destinationKey: string, options: StoragePromotionOptions): Promise<void>;
|
|
19
21
|
}
|
|
20
22
|
export declare class StorageClient {
|
|
21
23
|
#private;
|
|
@@ -34,6 +36,11 @@ export declare class StorageClient {
|
|
|
34
36
|
delete(key: string, options?: StorageOperationOptions): Promise<void>;
|
|
35
37
|
copy(sourceKey: string, destinationKey: string, options?: StorageOperationOptions): Promise<void>;
|
|
36
38
|
move(sourceKey: string, destinationKey: string, options?: StorageOperationOptions): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Conditionally copies a staged object to a final key. This operation does
|
|
41
|
+
* not delete the source; delete it after the application commit succeeds.
|
|
42
|
+
*/
|
|
43
|
+
promote(sourceKey: string, destinationKey: string, options: StoragePromotionOptions): Promise<void>;
|
|
37
44
|
list(options?: StorageListOptions): Promise<StorageListResult>;
|
|
38
45
|
listAll(options?: StorageListOptions): AsyncGenerator<StorageObjectMetadata, void>;
|
|
39
46
|
search(pattern: string | RegExp, options?: StorageSearchOptions): AsyncIterable<StorageObjectMetadata>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.client.d.ts","sourceRoot":"","sources":["../src/storage.client.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE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