@venizia/ignis 0.4.8-3 → 0.4.8-5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/base/middlewares/request-spy/request-spy.middleware.d.ts +1 -0
- package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js +9 -2
- package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js.map +1 -1
- package/dist/esm/components/auth/authenticate/component.js +37 -1
- package/dist/esm/components/auth/authenticate/component.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.d.ts +56 -5
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js +115 -11
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js +2 -2
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js +10 -3
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jws.service.d.ts +11 -0
- package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js +25 -3
- package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/index.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/services/index.js +1 -0
- package/dist/esm/components/auth/authenticate/services/index.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/jwks-url-policy.d.ts +31 -0
- package/dist/esm/components/auth/authenticate/services/jwks-url-policy.js +99 -0
- package/dist/esm/components/auth/authenticate/services/jwks-url-policy.js.map +1 -0
- package/dist/esm/components/auth/authenticate/services/service/verifier.service.js +7 -1
- package/dist/esm/components/auth/authenticate/services/service/verifier.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/service.strategy.js +2 -4
- package/dist/esm/components/auth/authenticate/strategies/service.strategy.js.map +1 -1
- package/dist/esm/components/health-check/reporter.js +2 -2
- package/dist/esm/components/health-check/reporter.js.map +1 -1
- package/dist/esm/components/static-asset/common/constants.d.ts +2 -0
- package/dist/esm/components/static-asset/common/constants.js +2 -0
- package/dist/esm/components/static-asset/common/constants.js.map +1 -1
- package/dist/esm/components/static-asset/common/types.d.ts +6 -0
- package/dist/esm/components/static-asset/common/types.js.map +1 -1
- package/dist/esm/components/static-asset/controller/base.definition.d.ts +2 -0
- package/dist/esm/components/static-asset/controller/base.definition.js +6 -4
- package/dist/esm/components/static-asset/controller/base.definition.js.map +1 -1
- package/dist/esm/components/static-asset/controller/factory.js +16 -8
- package/dist/esm/components/static-asset/controller/factory.js.map +1 -1
- package/dist/esm/components/static-asset/controller/route-options.d.ts +9 -0
- package/dist/esm/components/static-asset/controller/route-options.js +16 -3
- package/dist/esm/components/static-asset/controller/route-options.js.map +1 -1
- package/dist/esm/components/static-asset/ingest.d.ts +2 -2
- package/dist/esm/components/static-asset/ingest.js +2 -2
- package/dist/esm/components/static-asset/ingest.js.map +1 -1
- package/dist/esm/testing/assert-application-boots.d.ts +9 -0
- package/dist/esm/testing/assert-application-boots.js +11 -1
- package/dist/esm/testing/assert-application-boots.js.map +1 -1
- package/dist/presets/app/preset.json +3 -3
- package/dist/presets/lib/preset.json +2 -2
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/controller/factory.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,kBAAkB,EAAsB,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,UAAU,IAAI,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,GASf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,eAAe,EAAuB,MAAM,+BAA+B,CAAC;AAE3F,OAAO,EAAE,UAA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O;oCACP,YAAY,EAAE,aAAa,CAAC,uBAAuB,CAAC;wCAClD,MAAM;wCACN,MAAM,EAAE,SAAS;wCACjB,MAAM;wCACN,IAAI;wCACJ,QAAQ;qCACT,CAAC;oCACF,QAAQ;oCACR,KAAK,EAAE,EAAE;iCACV,CAAC,CAAC;gCAEH,OAAO,GAAG,CAAC,IAAI,CACb;oCACE,OAAO,EAAE,IAAI;oCACb,MAAM,EAAE,uBAAuB,CAAC,OAAO;oCACvC,KAAK,EAAE,CAAC;oCACR,QAAQ,EAAE,OAAO;oCACjB,SAAS,EAAE,CAAC,OAAO,CAAC;iCACrB,EACD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CACzB,CAAC;4BACJ,CAAC;yBACF,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;gBAED,oFAAoF;gBACpF,iBAAiB,EAAE,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC,CAAC;YAClF,CAAC;SACF,CAAA;QAr5BK,8BAA8B;YADnC,mBAAmB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;WAClC,8BAA8B,CAq5BnC;QAED,MAAM,CAAC,cAAc,CAAC,8BAA8B,EAAE,MAAM,EAAE;YAC5D,KAAK,EAAE,IAAI;YACX,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;QAEH,OAAO,8BAA8B,CAAC;IACxC,CAAC;CACF","sourcesContent":["import { BaseRestController, type TRouteContext } from '@/base/controllers';\nimport { controller as controllerDecorator } from '@/base/metadata';\nimport {\n BaseStorageHelper,\n RequestUtility,\n StorageUtility,\n type IObjectLocation,\n type IObjectMetadata,\n type IObjectRef,\n type IStorageHelper,\n type IUploadFile,\n type IPostPolicy,\n type IUploadResult,\n type TUploadNaming,\n} from '@venizia/ignis-helpers';\nimport { HTTP, ResolverUtility, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport type { AnyType, TValueOrAsyncResolver } from '@venizia/ignis-helpers/common';\nimport { BaseHelper, getError, UuidHelper } from '@venizia/ignis-helpers/core';\nimport { type Env } from 'hono';\nimport { readFileSync, rmSync } from 'node:fs';\nimport {\n RENDERABLE_CONTENT_TYPES,\n StaticAssetErrors,\n type TBucketParams,\n type TDefineExtraRoutes,\n type TListQuery,\n type TMetaLinkConfig,\n DEFAULT_PENDING_PREFIX,\n META_LINK_CREATE_FAILED,\n type TObjectParams,\n type TUploadPolicyRequest,\n type TObjectNameResolver,\n type TStaticAssetExtraOptions,\n type TStaticAssetsComponentOptions,\n type TStaticAssetStorageType,\n type TUploadQuery,\n WHITELIST_HEADERS,\n} from '../common';\nimport { AssetCommitToken, MetaLinkRecreateActions } from '../common';\nimport { AssetDefinitionBuilder } from './base.definition';\nimport { AssetKeyScope } from './key-scope';\nimport { AssetMetaLink } from './meta-link';\nimport { AssetRouteOptions } from './route-options';\n\n/** Input of `AssetControllerFactory.defineAssetController`: one entry of `TStaticAssetsComponentOptions` with its storage type and helper. */\nexport interface IAssetControllerOptions {\n controller: TStaticAssetsComponentOptions[string]['controller'];\n storage: TStaticAssetStorageType;\n helper: IStorageHelper;\n useMetaLink?: boolean;\n /** The table is erased at this seam on purpose. The public option types carry the real `Schema` and check it; inside the controller every read and write is on MetaLink COLUMNS, and threading a table type nobody here constrains through 700 lines of handler buys nothing. */\n metaLink?: TMetaLinkConfig<AnyType>;\n options?: TStaticAssetExtraOptions;\n\n /** Decides the stored object name of each uploaded file. Absent leaves the storage helper's own naming untouched. */\n resolveObjectName?: TObjectNameResolver;\n\n /** Registers the application's own routes on the generated controller, after every built-in one. */\n /** Registers the application's own routes BEFORE every built-in one, so a literal path wins over the catch-all `rawObjectPath` produces. */\n defineRoutesBefore?: TDefineExtraRoutes;\n defineExtraRoutes?: TDefineExtraRoutes;\n}\n\n/** Hono ALREADY percent-decodes path params - a second decodeURIComponent throws on `report_100%.pdf` and turns `a%2Fb.png` into a DIFFERENT object; `isValidName`/`isValidPath` still run on this value, so traversal is still rejected. */\n/** The upload labels, read off the multipart form. Every value arrives as text, so `sequence` is the one that needs converting. */\n/** One list: the reader below and the stale-caller warning must agree. */\nconst UPLOAD_LABEL_NAMES = [\n 'principalType',\n 'principalId',\n 'variant',\n 'sequence',\n 'folderPath',\n] as const;\n\n/** The body of `AssetControllerFactory.findLabelsInQuery`, callable from the helpers above the class. */\nconst listLabelsInQuery = (opts: {\n query: Record<string, string>;\n names?: ReadonlyArray<(typeof UPLOAD_LABEL_NAMES)[number]>;\n}): string[] => (opts.names ?? UPLOAD_LABEL_NAMES).filter((name) => opts.query[name] !== undefined);\n\n/** Refused before the body is read: a route that ignored them would store an unlabelled row. */\nconst refuseLabelsInQuery = (opts: {\n query: Record<string, string>;\n names?: ReadonlyArray<(typeof UPLOAD_LABEL_NAMES)[number]>;\n reason?: string;\n}): void => {\n const names = listLabelsInQuery(opts);\n\n if (names.length > 0) {\n throw getError({\n error: StaticAssetErrors.LABELS_IN_QUERY,\n message: `${opts.reason ?? 'Upload labels belong in the request body, not the query'} | names: ${names.join(', ')}`,\n });\n }\n};\n\n/** The commit body carries four of the five: the object key - and so `folderPath` - was fixed when the policy was issued. */\nconst COMMIT_LABEL_NAMES = UPLOAD_LABEL_NAMES.filter((name) => name !== 'folderPath');\n\n// A multipart form hands strings; a JSON commit body may hand `sequence` as a number.\nconst readUploadLabels = (opts: {\n fields: Partial<Record<(typeof UPLOAD_LABEL_NAMES)[number], string | number>>;\n}): TUploadQuery => {\n const { fields } = opts;\n\n const read = (name: (typeof UPLOAD_LABEL_NAMES)[number]) => {\n const value = fields[name];\n\n return value === undefined || value === '' ? undefined : String(value);\n };\n\n const sequence = read('sequence');\n\n return {\n principalType: read('principalType'),\n principalId: read('principalId'),\n variant: read('variant'),\n sequence: sequence === undefined ? undefined : Number(sequence),\n folderPath: read('folderPath'),\n };\n};\n\nconst readObjectName: (rawObjectName: string) => string = (rawObjectName) => rawObjectName;\n\n/** Encodes an object path into a SINGLE url segment: `{objectName}` matches one segment only, so `/` must be percent-encoded too (Hono decodes it back before the handler reads the param). */\nconst encodeObjectPath: (objectPath: string) => string = (objectPath) => {\n return encodeURIComponent(objectPath);\n};\n\n/** The bucket one request works on: a configured value wins - called on every request, so an application may read an environment variable lazily - else the path param, which is only registered when there is no configured bucket. */\nconst resolveBucket = async (opts: {\n configured?: TValueOrAsyncResolver<string>;\n param?: string;\n}): Promise<string> => {\n const { configured, param } = opts;\n\n if (configured === undefined) {\n return param ?? '';\n }\n\n return ResolverUtility.resolveValueAsync({ value: configured });\n};\n\n/** Mirrors `BaseStorageHelper.normalizeObjectName`, which is protected: `resolveObjectName` is offered the very name the helper would otherwise have written. */\nconst defaultObjectName: (opts: { file: TUploadNaming }) => string = ({ file }) => {\n const { originalName, folderPath } = file;\n const normalizedFileName = originalName.toLowerCase().replace(/ /g, '_');\n\n if (!folderPath) {\n return normalizedFileName;\n }\n\n return `${folderPath.toLowerCase().replace(/ /g, '_')}/${normalizedFileName}`;\n};\n\n/**\n * Reads one `Range` header. Only a single byte range is honoured - multipart ranges need a multipart\n * body no browser asks for here. An unsatisfiable or malformed range returns `null`, and the caller\n * serves the whole object, which is what RFC 9110 allows.\n */\nconst readByteRange = (opts: {\n header: string | undefined;\n size: number;\n}): { start: number; end: number } | null => {\n const { header, size } = opts;\n\n if (!header || size <= 0) {\n return null;\n }\n\n const match = /^bytes=(\\d*)-(\\d*)$/.exec(header.trim());\n\n if (!match) {\n return null;\n }\n\n const [, rawStart, rawEnd] = match;\n\n // `bytes=-500` means the LAST 500 bytes, not \"from 0 to 500\".\n if (!rawStart) {\n const suffixLength = Number(rawEnd);\n\n if (!Number.isInteger(suffixLength) || suffixLength <= 0) {\n return null;\n }\n\n return { start: Math.max(size - suffixLength, 0), end: size - 1 };\n }\n\n const start = Number(rawStart);\n const end = rawEnd ? Number(rawEnd) : size - 1;\n\n if (!Number.isInteger(start) || !Number.isInteger(end) || start > end || start >= size) {\n return null;\n }\n\n return { start, end: Math.min(end, size - 1) };\n};\n\n/** Sets whitelisted metadata headers on the response context. `content-type` is not among them. */\nconst applyMetadataHeaders: (opts: {\n ctx: TRouteContext<Env>;\n metadata: IObjectMetadata;\n}) => void = ({ ctx, metadata }) => {\n Object.entries(metadata).forEach(([key, value]) => {\n if (!WHITELIST_HEADERS.includes(key.toLowerCase() as (typeof WHITELIST_HEADERS)[number])) {\n return;\n }\n\n ctx.header(key.toLowerCase(), String(value).replace(/[\\r\\n]/g, ''));\n });\n};\n\n/** Builds the REST controller class for a static asset entry. Static helpers also expose label checking, object link building and served content type resolution. */\nexport class AssetControllerFactory extends BaseHelper {\n constructor() {\n super({ scope: AssetControllerFactory.name });\n }\n\n /** Names any label a caller put in the query - where the upload routes refuse it. */\n static findLabelsInQuery(opts: {\n query: Record<string, string>;\n names?: ReadonlyArray<(typeof UPLOAD_LABEL_NAMES)[number]>;\n }): string[] {\n return listLabelsInQuery(opts);\n }\n\n /** The URL of one object, in the shape its controller serves: no `/buckets/<name>` with a configured bucket, and a raw path with `rawObjectPath`. */\n static buildObjectLink(\n opts: IObjectLocation & {\n basePath: string;\n hasConfiguredBucket?: boolean;\n rawObjectPath?: boolean;\n },\n ): string {\n const { basePath, bucket, object } = opts;\n const { hasConfiguredBucket = false, rawObjectPath = false } = opts;\n\n const bucketSegment = hasConfiguredBucket ? '' : `/buckets/${bucket.name}`;\n const objectSegment = rawObjectPath ? object.key : encodeObjectPath(object.key);\n\n return `${basePath}${bucketSegment}/objects/${objectSegment}`;\n }\n\n /**\n * The served type comes from the object NAME, never the backend or the uploader: a renderable type on\n * the API origin is stored XSS. Public so a hand-written route makes the same decision - the\n * backend's own content-type is dropped by `WHITELIST_HEADERS`.\n */\n static resolveServedContentType(opts: { helper: IStorageHelper; object: IObjectRef }): {\n contentType: string;\n isRenderable: boolean;\n } {\n const { helper, object } = opts;\n const candidate = helper\n .getMimeType({ filename: object.key })\n .toLowerCase()\n .split(';')[0]\n .trim();\n\n if (!RENDERABLE_CONTENT_TYPES.has(candidate)) {\n return { contentType: HTTP.HeaderValues.APPLICATION_OCTET_STREAM, isRenderable: false };\n }\n\n return { contentType: candidate, isRenderable: true };\n }\n\n static defineAssetController(opts: IAssetControllerOptions) {\n const { controller, helper, options, useMetaLink, metaLink, storage } = opts;\n const { resolveObjectName, defineRoutesBefore, defineExtraRoutes } = opts;\n const { directUpload } = controller;\n const { name, basePath, routes, isStrict = true, bucket, rawObjectPath = false } = controller;\n const maxFolderDepth = options?.maxFolderDepth ?? BaseStorageHelper.DEFAULT_MAX_FOLDER_DEPTH;\n const maxBytes = options?.maxBytes;\n\n const hasConfiguredBucket = bucket !== undefined;\n\n // With the bucket in the URL, the bucket routes stay unscoped and the scope spans every bucket.\n if (controller.keyPrefix !== undefined && !hasConfiguredBucket) {\n throw getError({\n message: `[${name}] keyPrefix needs controller.bucket | a bucket in the URL is a bucket the caller chooses, and the bucket routes cannot be scoped`,\n });\n }\n\n const scope =\n controller.keyPrefix === undefined\n ? undefined\n : AssetKeyScope.normalizePrefix({ keyPrefix: controller.keyPrefix, helper, scope: name });\n const keyPrefix = scope?.keyPrefix;\n // `maxFolderDepth` counts the caller's folders; the scope's own are configuration, not input.\n const objectKeyMaxDepth = maxFolderDepth + (scope?.depth ?? 0);\n // The component's own name under a scope: the original name must stay one segment, as without one.\n const isScopedDefaultNaming =\n keyPrefix !== undefined && !resolveObjectName && !options?.normalizeNameFn;\n const definitions = AssetDefinitionBuilder.build({ hasConfiguredBucket, rawObjectPath });\n\n // The mount path may be declared with or without a leading slash; a link must carry exactly one.\n const normalizedBasePath = basePath.startsWith('/') ? basePath : `/${basePath}`;\n\n /** Only when the URL shape deviates: with neither option the storage helper's own link is left untouched. */\n const shapedLinkFn =\n hasConfiguredBucket || rawObjectPath\n ? (linkOptions: IObjectLocation) =>\n AssetControllerFactory.buildObjectLink({\n basePath: normalizedBasePath,\n bucket: linkOptions.bucket,\n object: linkOptions.object,\n hasConfiguredBucket,\n rawObjectPath,\n })\n : undefined;\n const normalizeLinkFn = options?.normalizeLinkFn ?? shapedLinkFn;\n\n @controllerDecorator({ path: basePath })\n class GeneratedStaticAssetController extends BaseRestController {\n constructor() {\n super({\n scope: name,\n path: basePath,\n isStrict,\n });\n }\n\n /** Clears the multipart spool files written by `parseMultipartBody({ storage: 'disk' })`. */\n removeSpoolFiles(spoolOptions: { paths: string[] }): void {\n for (const filePath of spoolOptions.paths) {\n try {\n rmSync(filePath, { force: true });\n } catch (error) {\n this.logger\n .for('UPLOAD')\n .error('Failed to remove spool file | path: %s | Error: %s', filePath, error);\n }\n }\n }\n\n override binding(): ValueOrPromise<void> {\n // First, so a literal path can win over the built-in catch-all `rawObjectPath` registers.\n defineRoutesBefore?.({ controller: this, helper, basePath: normalizedBasePath });\n\n // A single-bucket application has no reason to expose bucket creation or deletion, so the\n // four bucket-management routes are not registered once `bucket` is configured.\n if (!hasConfiguredBucket) {\n const getBucketsRoute = AssetRouteOptions.readOverride({ route: routes?.getBuckets });\n\n if (getBucketsRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.GET_BUCKETS, ...getBucketsRoute.override },\n }).to({\n handler: async (ctx) => {\n const buckets = await helper.getBuckets();\n\n return ctx.json(buckets, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n\n const getBucketByNameRoute = AssetRouteOptions.readOverride({\n route: routes?.getBucketByName,\n });\n\n if (getBucketByNameRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.GET_BUCKET_BY_NAME, ...getBucketByNameRoute.override },\n }).to({\n handler: async (ctx) => {\n const params = ctx.req.valid<TBucketParams>('param');\n const bucketName = await resolveBucket({\n configured: bucket,\n param: params.bucketName,\n });\n\n if (!helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n const found = await helper.getBucket({ bucket: { name: bucketName } });\n\n return ctx.json(found, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n\n const createBucketRoute = AssetRouteOptions.readOverride({ route: routes?.createBucket });\n\n if (createBucketRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.CREATE_BUCKET, ...createBucketRoute.override },\n }).to({\n handler: async (ctx) => {\n const params = ctx.req.valid<TBucketParams>('param');\n const bucketName = await resolveBucket({\n configured: bucket,\n param: params.bucketName,\n });\n\n if (!helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n const createdBucket = await helper.createBucket({ bucket: { name: bucketName } });\n\n return ctx.json(createdBucket, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n\n const deleteBucketRoute = AssetRouteOptions.readOverride({ route: routes?.deleteBucket });\n\n if (deleteBucketRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.DELETE_BUCKET, ...deleteBucketRoute.override },\n }).to({\n handler: async (ctx) => {\n const params = ctx.req.valid<TBucketParams>('param');\n const bucketName = await resolveBucket({\n configured: bucket,\n param: params.bucketName,\n });\n\n if (!helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n const isRemovedBucket = await helper.removeBucket({\n bucket: { name: bucketName },\n });\n\n return ctx.json({ isDeleted: isRemovedBucket }, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n }\n\n const getObjectByNameRoute = AssetRouteOptions.readOverride({\n route: routes?.getObjectByName,\n });\n\n if (getObjectByNameRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.GET_OBJECT_BY_NAME, ...getObjectByNameRoute.override },\n }).to({\n handler: async (ctx) => {\n const params = ctx.req.valid<TObjectParams>('param');\n const bucketName = await resolveBucket({\n configured: bucket,\n param: params.bucketName,\n });\n const objectName = readObjectName(params.objectName);\n\n if (!helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n if (\n !helper.isValidObjectKey({\n object: { key: objectName },\n maxDepth: objectKeyMaxDepth,\n })\n ) {\n throw getError({ error: StaticAssetErrors.OBJECT_NAME_INVALID });\n }\n\n // Before any storage call: a key outside the scope must not even be probed.\n AssetKeyScope.assertInScope({ key: objectName, keyPrefix });\n\n const fileStat = await helper.getStat({\n bucket: { name: bucketName },\n object: { key: objectName },\n });\n const { size, metadata } = fileStat;\n applyMetadataHeaders({ ctx, metadata });\n\n const served = AssetControllerFactory.resolveServedContentType({\n helper,\n object: { key: objectName },\n });\n ctx.header(HTTP.Headers.CONTENT_TYPE, served.contentType);\n ctx.header('x-content-type-options', 'nosniff');\n // Sandboxed even when renderable, so an unforeseen renderable type cannot reach this origin.\n ctx.header(HTTP.Headers.CONTENT_SECURITY_POLICY, 'sandbox');\n // Advertised unconditionally: a player only offers seeking once it sees this.\n ctx.header('accept-ranges', 'bytes');\n\n // A type outside the allow-list downloads instead of rendering; that is the XSS boundary.\n if (!served.isRenderable) {\n const inlineName = objectName.split('/').pop() ?? objectName;\n ctx.header(\n HTTP.Headers.CONTENT_DISPOSITION,\n RequestUtility.buildContentDispositionHeader({\n filename: inlineName,\n type: 'attachment',\n }),\n );\n }\n\n const range = readByteRange({ header: ctx.req.header('range'), size });\n\n if (range) {\n ctx.header(HTTP.Headers.CONTENT_LENGTH, String(range.end - range.start + 1));\n ctx.header(HTTP.Headers.CONTENT_RANGE, `bytes ${range.start}-${range.end}/${size}`);\n } else {\n ctx.header(HTTP.Headers.CONTENT_LENGTH, size.toString());\n }\n\n // The web stream is what a Response body wants, so no Node Readable sits in between.\n const stream = await helper.getObjectStream({\n bucket: { name: bucketName },\n object: { key: objectName },\n ...(range ? { range } : {}),\n });\n\n return new Response(stream, {\n headers: ctx.res.headers,\n status: range ? HTTP.ResultCodes.RS_2.PartialContent : HTTP.ResultCodes.RS_2.Ok,\n });\n },\n });\n }\n\n const downloadObjectByNameRoute = AssetRouteOptions.readOverride({\n route: routes?.downloadObjectByName,\n });\n\n if (downloadObjectByNameRoute.isEnabled) {\n this.bindRoute({\n configs: {\n ...definitions.DOWNLOAD_OBJECT_BY_NAME,\n ...downloadObjectByNameRoute.override,\n },\n }).to({\n handler: async (ctx) => {\n const params = ctx.req.valid<TObjectParams>('param');\n const bucketName = await resolveBucket({\n configured: bucket,\n param: params.bucketName,\n });\n const objectName = readObjectName(params.objectName);\n\n if (!helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n if (\n !helper.isValidObjectKey({\n object: { key: objectName },\n maxDepth: objectKeyMaxDepth,\n })\n ) {\n throw getError({ error: StaticAssetErrors.OBJECT_NAME_INVALID });\n }\n\n // Before any storage call: a key outside the scope must not even be probed.\n AssetKeyScope.assertInScope({ key: objectName, keyPrefix });\n\n const fileStat = await helper.getStat({\n bucket: { name: bucketName },\n object: { key: objectName },\n });\n const { size, metadata } = fileStat;\n applyMetadataHeaders({ ctx, metadata });\n\n // Download always attaches, so the served type only has to be honest, never renderable.\n const served = AssetControllerFactory.resolveServedContentType({\n helper,\n object: { key: objectName },\n });\n ctx.header(HTTP.Headers.CONTENT_TYPE, served.contentType);\n ctx.header(HTTP.Headers.CONTENT_LENGTH, size.toString());\n\n const fileName = objectName.split('/').pop() ?? objectName;\n ctx.header(\n HTTP.Headers.CONTENT_DISPOSITION,\n RequestUtility.buildContentDispositionHeader({\n filename: fileName,\n type: 'attachment',\n }),\n );\n ctx.header('x-content-type-options', 'nosniff');\n ctx.header(HTTP.Headers.CONTENT_SECURITY_POLICY, 'sandbox');\n\n const stream = await helper.getObjectStream({\n bucket: { name: bucketName },\n object: { key: objectName },\n });\n\n return new Response(stream, {\n headers: ctx.res.headers,\n status: HTTP.ResultCodes.RS_2.Ok,\n });\n },\n });\n }\n\n const uploadRoute = AssetRouteOptions.readOverride({ route: routes?.upload });\n\n if (uploadRoute.isEnabled) {\n const uploadMiddleware =\n maxBytes === undefined\n ? uploadRoute.override.middleware\n : AssetRouteOptions.appendLengthGuard({\n middleware: uploadRoute.override.middleware,\n maxBytes,\n });\n\n this.bindRoute({\n configs: {\n ...definitions.UPLOAD,\n ...uploadRoute.override,\n middleware: uploadMiddleware,\n },\n }).to({\n handler: async (ctx) => {\n // A configured bucket drops `params` from this route entirely, so it is read only when it exists.\n const bucketParam = hasConfiguredBucket\n ? undefined\n : ctx.req.valid<TBucketParams>('param').bucketName;\n const bucketName = await resolveBucket({ configured: bucket, param: bucketParam });\n\n if (!helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n const validateFolderPath = (folderPath: string) => {\n const normalizedFolder = folderPath.replace(/^\\/+|\\/+$/g, '');\n\n if (!normalizedFolder) {\n throw getError({ error: StaticAssetErrors.FOLDER_PATH_INVALID });\n }\n\n // maxFolderDepth excludes the filename, so it is compared directly against segment count.\n const folderSegments = normalizedFolder.split('/');\n\n if (folderSegments.length > maxFolderDepth) {\n throw getError({\n error: StaticAssetErrors.FOLDER_DEPTH_EXCEEDED,\n message: `Folder path exceeds max depth of ${maxFolderDepth}`,\n });\n }\n\n const invalidSegmentIndex = folderSegments.findIndex(\n (segment) => !helper.isValidSegment({ segment }),\n );\n\n if (invalidSegmentIndex !== -1) {\n throw getError({\n error: StaticAssetErrors.FOLDER_SEGMENT_INVALID,\n message: `Invalid folder path segment: ${folderSegments[invalidSegmentIndex]}`,\n });\n }\n };\n\n refuseLabelsInQuery({ query: ctx.req.query() });\n\n const { files: filesArray, fields } = await RequestUtility.parseMultipartBody({\n context: ctx,\n storage: options?.parseMultipartBody?.storage,\n uploadDir: options?.parseMultipartBody?.uploadDir,\n });\n\n // Labels travel with the payload, not the URL, so the folder check waits for the parse.\n const query = readUploadLabels({ fields });\n\n const folderPath = query.folderPath;\n\n if (folderPath) {\n validateFolderPath(folderPath);\n }\n\n const spoolPaths = filesArray\n .map((file) => file.path)\n .filter((filePath): filePath is string => Boolean(filePath));\n\n let uploaded: IUploadResult[];\n\n try {\n // `storage: 'disk'` spools the payload to `uploadDir` and returns `path` instead of `buffer`; the storage helpers only ever write `buffer`, so it must be read back.\n const modifiedFiles: IUploadFile[] = filesArray.map((file) => {\n const buffer = file.buffer ?? (file.path ? readFileSync(file.path) : undefined);\n\n if (!buffer?.length) {\n throw getError({\n error: StaticAssetErrors.FILE_EMPTY,\n message: `Empty file content | name: ${file.originalname}`,\n });\n }\n\n // Authoritative: `buffer.length`, not the client-declared `size`.\n if (maxBytes !== undefined && buffer.length > maxBytes) {\n throw getError({\n error: StaticAssetErrors.UPLOAD_TOO_LARGE,\n message: `File ${file.originalname} of ${buffer.length} bytes exceeds the maximum of ${maxBytes}`,\n });\n }\n\n return {\n originalName: file.originalname,\n mimetype: file.mimetype,\n buffer,\n size: file.size,\n encoding: file.encoding,\n folderPath: folderPath ?? undefined,\n };\n });\n\n // Built per request: the hook is offered the bucket, which only the route knows. With\n // neither hook nor scope, `normalizeNameFn` stays exactly as configured. Under a scope,\n // the component's own default is placed inside it; an application hook's key is\n // checked, never rewritten, because the application may record that key elsewhere.\n const normalizeNameFn =\n resolveObjectName || keyPrefix !== undefined\n ? (naming: { file: TUploadNaming }) => {\n if (\n isScopedDefaultNaming &&\n !helper.isValidSegment({ segment: naming.file.originalName })\n ) {\n throw getError({ message: '[upload] Invalid original file name' });\n }\n\n const defaultKey = options?.normalizeNameFn\n ? options.normalizeNameFn(naming)\n : `${keyPrefix ?? ''}${defaultObjectName(naming)}`;\n\n const key = resolveObjectName\n ? resolveObjectName({\n bucket: { name: bucketName },\n file: naming.file,\n defaultKey,\n })\n : defaultKey;\n\n if (!AssetKeyScope.isInScope({ key, keyPrefix })) {\n throw getError({\n error: StaticAssetErrors.OBJECT_KEY_OUT_OF_SCOPE,\n message: `Object key is outside the key prefix of this controller | key: ${key} | keyPrefix: ${keyPrefix}`,\n });\n }\n\n return key;\n }\n : options?.normalizeNameFn;\n\n const result = await helper.upload({\n bucket: { name: bucketName },\n files: modifiedFiles,\n normalizeNameFn,\n normalizeLinkFn,\n // Without this the helper re-validates against its own hard default of 2, so an app configured for a deeper tree spools the body and only then fails inside the helper.\n maxFolderDepth: objectKeyMaxDepth,\n });\n uploaded = result;\n } finally {\n this.removeSpoolFiles({ paths: spoolPaths });\n }\n\n if (!useMetaLink || !metaLink) {\n return ctx.json(uploaded, HTTP.ResultCodes.RS_2.Ok);\n }\n\n const results: IUploadResult[] = [];\n\n for (const uploadResult of uploaded) {\n try {\n const fileStat = await helper.getStat({\n bucket: uploadResult.bucket,\n object: uploadResult.object,\n });\n\n const createdMetaLink = await AssetMetaLink.createRow({\n metaLink,\n helper,\n storage,\n uploadResult,\n fileStat,\n query,\n });\n\n results.push({ ...uploadResult, metaLink: { data: createdMetaLink } });\n } catch (error) {\n this.logger\n .for('UPLOAD')\n .error(\n 'Failed to create MetaLink | objectName: %s | Error: %s',\n uploadResult.object.key,\n error,\n );\n results.push({\n ...uploadResult,\n // A CODE, never the driver text. This handler returns 200, so it bypasses the\n // error middleware and `database.handler` - the two places that strip\n // `detail`/`table`/`constraint` - and shipped raw constraint names to the client.\n // The real error is already logged in full immediately above.\n metaLink: { error: META_LINK_CREATE_FAILED },\n });\n }\n }\n\n return ctx.json(results, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n\n const deleteObjectRoute = AssetRouteOptions.readOverride({ route: routes?.deleteObject });\n\n if (deleteObjectRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.DELETE_OBJECT, ...deleteObjectRoute.override },\n }).to({\n handler: async (ctx) => {\n const params = ctx.req.valid<TObjectParams>('param');\n const bucketName = await resolveBucket({\n configured: bucket,\n param: params.bucketName,\n });\n const objectName = readObjectName(params.objectName);\n\n if (!helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n if (\n !helper.isValidObjectKey({\n object: { key: objectName },\n maxDepth: objectKeyMaxDepth,\n })\n ) {\n throw getError({ error: StaticAssetErrors.OBJECT_NAME_INVALID });\n }\n\n // Before any storage call: a key outside the scope must not even be probed.\n AssetKeyScope.assertInScope({ key: objectName, keyPrefix });\n\n // Deliberately idempotent: S3 answers 200 for a key that was never there, and consumers\n // already depend on it. `disk` throws instead, so the two are reconciled here, not below.\n try {\n await helper.removeObject({\n bucket: { name: bucketName },\n object: { key: objectName },\n });\n } catch (error) {\n if (!StorageUtility.isNotFoundError({ error })) {\n throw error;\n }\n }\n\n if (!useMetaLink || !metaLink) {\n return ctx.json({ success: true }, HTTP.ResultCodes.RS_2.Ok);\n }\n\n const deleteRepository = await ResolverUtility.resolveValueAsync({\n value: metaLink.repository,\n });\n deleteRepository\n .deleteAll({\n where: {\n bucketName,\n objectName,\n },\n })\n .then(() => {\n this.logger\n .for('DELETE_OBJECT')\n .info('Successfully to delete MetaLink for %s/%s', bucketName, objectName);\n })\n .catch((error) => {\n this.logger\n .for('DELETE_OBJECT')\n .error(\n 'Failed to delete MetaLink | bucket: %s | objectName: %s | Error: %s',\n bucketName,\n objectName,\n error,\n );\n });\n\n return ctx.json({ success: true }, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n\n const listObjectsRoute = AssetRouteOptions.readOverride({ route: routes?.listObjects });\n\n if (listObjectsRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.LIST_OBJECTS, ...listObjectsRoute.override },\n }).to({\n handler: async (ctx) => {\n // A configured bucket drops `params` from this route entirely, so it is read only when it exists.\n const bucketParam = hasConfiguredBucket\n ? undefined\n : ctx.req.valid<TBucketParams>('param').bucketName;\n const bucketName = await resolveBucket({ configured: bucket, param: bucketParam });\n const { prefix, recursive, maxKeys } = ctx.req.valid<TListQuery>('query');\n\n if (!helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n // A NaN or 0 maxKeys is silently treated as \"unlimited\" by the storage backends, so an unparsable value must be rejected instead of forwarded.\n let resolvedMaxKeys: number | undefined;\n\n if (maxKeys !== undefined) {\n resolvedMaxKeys = Number(maxKeys);\n\n if (!Number.isInteger(resolvedMaxKeys) || resolvedMaxKeys < 1) {\n throw getError({\n error: StaticAssetErrors.MAX_KEYS_INVALID,\n message: `Invalid maxKeys | Expected a positive integer | value: ${maxKeys}`,\n });\n }\n }\n\n const scoped = AssetKeyScope.resolveListPrefix({ prefix, keyPrefix });\n\n if (scoped.isOutOfScope) {\n return ctx.json([], HTTP.ResultCodes.RS_2.Ok);\n }\n\n const objects = await helper.listObjects({\n bucket: { name: bucketName },\n prefix: scoped.prefix,\n useRecursive: recursive === 'true',\n maxKeys: resolvedMaxKeys,\n });\n\n return ctx.json(objects, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n\n if (directUpload) {\n if (!hasConfiguredBucket) {\n throw getError({\n message: `[${name}] directUpload needs controller.bucket | a policy names one bucket, and a bucket in the URL is a bucket the caller chooses`,\n });\n }\n\n const pendingPrefix = directUpload.pendingPrefix ?? DEFAULT_PENDING_PREFIX;\n // The scope rides inside the pending key, so the commit, which strips `pendingPrefix`, lands inside it.\n const policyKeyPrefix = `${pendingPrefix}${keyPrefix ?? ''}`;\n\n const uploadPolicyRoute = AssetRouteOptions.readOverride({ route: routes?.uploadPolicy });\n\n if (uploadPolicyRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.UPLOAD_POLICY, ...uploadPolicyRoute.override },\n }).to({\n handler: async (ctx) => {\n const result = await directUpload.authorize({ context: ctx });\n\n if (!result) {\n throw getError({ error: StaticAssetErrors.UPLOAD_NOT_AUTHORIZED });\n }\n\n const { files } = ctx.req.valid<TUploadPolicyRequest>('json');\n const bucketName = await resolveBucket({ configured: bucket });\n\n const policies: Array<IPostPolicy & { objectName: string; commitToken: string }> =\n [];\n\n for (const file of files) {\n if (file.size !== undefined && file.size > directUpload.maxBytes) {\n throw getError({\n error: StaticAssetErrors.UPLOAD_TOO_LARGE,\n message: `File '${file.fileName}' is ${file.size} bytes, over the ${directUpload.maxBytes} the policy allows`,\n });\n }\n\n // Generated, never taken from the caller: a key the caller picks is a key the caller\n // can collide with, and the pending object is the one thing a policy authorizes.\n const objectName = `${policyKeyPrefix}${UuidHelper.getInstance().v4()}/${file.fileName}`;\n const policy = await helper.presignPost({\n bucket: { name: bucketName },\n keyPrefix: policyKeyPrefix,\n maxBytes: directUpload.maxBytes,\n contentType: file.contentType,\n expiresIn: directUpload.expiresIn,\n });\n\n policies.push({\n ...policy,\n objectName,\n commitToken: AssetCommitToken.build({\n payload: {\n bucket: bucketName,\n key: objectName,\n expiresAt: new Date(policy.expiresAt).getTime(),\n },\n secretKey: directUpload.secretKey,\n }),\n });\n }\n\n return ctx.json(policies, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n\n const uploadCommitRoute = AssetRouteOptions.readOverride({ route: routes?.uploadCommit });\n\n if (uploadCommitRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.UPLOAD_COMMIT, ...uploadCommitRoute.override },\n }).to({\n handler: async (ctx) => {\n const commitQuery = ctx.req.query();\n refuseLabelsInQuery({ query: commitQuery, names: COMMIT_LABEL_NAMES });\n refuseLabelsInQuery({\n query: commitQuery,\n names: ['folderPath'],\n reason:\n 'folderPath was decided when the upload policy was issued; the commit route cannot move the object',\n });\n\n const { commitToken, ...labels } = ctx.req.valid<\n { commitToken: string } & TUploadQuery\n >('json');\n\n // Verified BEFORE any storage call. That is what keeps this route from being a name\n // prober: a forged token fails without a round trip, so timing says nothing.\n const payload = AssetCommitToken.read({\n token: commitToken,\n secretKey: directUpload.secretKey,\n });\n\n // Labels, not authorization - the token deliberately carries no business fields, so\n // they travel beside it rather than inside it.\n const query = readUploadLabels({ fields: labels });\n\n const bucketRef = { name: payload.bucket };\n const pendingObject = { key: payload.key };\n const object = { key: payload.key.slice(pendingPrefix.length) };\n\n // A token another controller signed with the same secret must not land outside this scope.\n AssetKeyScope.assertInScope({ key: object.key, keyPrefix });\n\n // Before the copy, so a hook that throws leaves the object under the pending prefix\n // for a lifecycle rule, rather than stranding it at the final key.\n await directUpload.onCommit?.({ bucket: bucketRef, pendingObject, object });\n\n await helper.copyObject({\n bucket: bucketRef,\n source: pendingObject,\n destination: object,\n });\n\n // The copy IS the commit; removing the temporary object is cleanup. A failure here\n // leaves one object for the lifecycle rule, and failing the request would tell the\n // caller their upload did not work when it did.\n try {\n await helper.removeObject({ bucket: bucketRef, object: pendingObject });\n } catch (error) {\n this.logger\n .for('UPLOAD_COMMIT')\n .warn(\n 'Committed, but the pending object remains | key: %s | error: %s',\n pendingObject.key,\n error,\n );\n }\n\n const link = AssetControllerFactory.buildObjectLink({\n basePath: normalizedBasePath,\n bucket: bucketRef,\n object,\n hasConfiguredBucket,\n rawObjectPath,\n });\n\n // The two paths have to agree: without this a client reading `metaLink` off the\n // response renders an empty state with no error - the failure nobody reports.\n let metaLinkResult: IUploadResult['metaLink'];\n\n if (useMetaLink && metaLink) {\n try {\n const fileStat = await helper.getStat({ bucket: bucketRef, object });\n const data = await AssetMetaLink.createRow({\n metaLink,\n helper,\n storage,\n uploadResult: AssetMetaLink.buildStoredUploadResult({\n helper,\n bucket: bucketRef,\n object,\n link,\n fileStat,\n }),\n fileStat,\n query,\n });\n\n metaLinkResult = { data };\n } catch (error) {\n // The object IS committed by now. A 500 would send the caller back with a token\n // whose source no longer exists, so this rides the body as a code, like UPLOAD.\n this.logger\n .for('UPLOAD_COMMIT')\n .error(\n 'Failed to create MetaLink | objectName: %s | Error: %s',\n object.key,\n error,\n );\n metaLinkResult = { error: META_LINK_CREATE_FAILED };\n }\n }\n\n return ctx.json(\n {\n bucket: bucketRef,\n object,\n link,\n ...(metaLinkResult === undefined ? {} : { metaLink: metaLinkResult }),\n },\n HTTP.ResultCodes.RS_2.Ok,\n );\n },\n });\n }\n }\n\n if (useMetaLink && metaLink) {\n const recreateMetaLinkRoute = AssetRouteOptions.readOverride({\n route: routes?.recreateMetaLink,\n });\n\n if (recreateMetaLinkRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.RECREATE_METALINK, ...recreateMetaLinkRoute.override },\n }).to({\n handler: async (ctx) => {\n // This route takes no labels anywhere: one in the query would land an unlabelled row.\n refuseLabelsInQuery({\n query: ctx.req.query(),\n reason:\n 'This route recreates a MetaLink for an existing object and takes no labels',\n });\n\n const params = ctx.req.valid<TObjectParams>('param');\n const bucketName = await resolveBucket({\n configured: bucket,\n param: params.bucketName,\n });\n const objectName = readObjectName(params.objectName);\n\n if (!helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n if (\n !helper.isValidObjectKey({\n object: { key: objectName },\n maxDepth: objectKeyMaxDepth,\n })\n ) {\n throw getError({ error: StaticAssetErrors.OBJECT_NAME_INVALID });\n }\n\n // Before any storage call: a key outside the scope must not even be probed.\n AssetKeyScope.assertInScope({ key: objectName, keyPrefix });\n\n const bucketRef = { name: bucketName };\n const object = { key: objectName };\n const fileStat = await helper.getStat({ bucket: bucketRef, object });\n\n const link = options?.normalizeLinkFn\n ? options.normalizeLinkFn({ bucket: bucketRef, object })\n : AssetControllerFactory.buildObjectLink({\n basePath: normalizedBasePath,\n bucket: bucketRef,\n object,\n hasConfiguredBucket,\n rawObjectPath,\n });\n\n const refreshed = await AssetMetaLink.refreshRows({\n metaLink,\n helper,\n bucket: bucketRef,\n object,\n link,\n fileStat,\n });\n\n if (refreshed.count > 0) {\n return ctx.json(\n {\n success: true,\n action: MetaLinkRecreateActions.REFRESHED,\n count: refreshed.count,\n metaLink: refreshed.data[0],\n metaLinks: refreshed.data,\n },\n HTTP.ResultCodes.RS_2.Ok,\n );\n }\n\n // Not atomic with the refresh above: two concurrent calls may both create, which the\n // table allows - rows per pair are deliberately not unique.\n const created = await AssetMetaLink.createRow({\n metaLink,\n helper,\n storage,\n uploadResult: AssetMetaLink.buildStoredUploadResult({\n helper,\n bucket: bucketRef,\n object,\n link,\n fileStat,\n }),\n fileStat,\n query: {},\n });\n\n return ctx.json(\n {\n success: true,\n action: MetaLinkRecreateActions.CREATED,\n count: 1,\n metaLink: created,\n metaLinks: [created],\n },\n HTTP.ResultCodes.RS_2.Ok,\n );\n },\n });\n }\n }\n\n // Last, so a built-in route always wins a path collision with an application's own.\n defineExtraRoutes?.({ controller: this, helper, basePath: normalizedBasePath });\n }\n }\n\n Object.defineProperty(GeneratedStaticAssetController, 'name', {\n value: name,\n configurable: true,\n });\n\n return GeneratedStaticAssetController;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/controller/factory.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,kBAAkB,EAAsB,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,UAAU,IAAI,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,GASf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,eAAe,EAAuB,MAAM,+BAA+B,CAAC;AAE3F,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EAKjB,sBAAsB,EACtB,uBAAuB,EAQvB,iBAAiB,GAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAqBpD,6OAA6O;AAC7O,mIAAmI;AACnI,0EAA0E;AAC1E,MAAM,kBAAkB,GAAG;IACzB,eAAe;IACf,aAAa;IAC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AE,CAAC,OAAO,CAAC;iCACrB,EACD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CACzB,CAAC;4BACJ,CAAC;yBACF,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;gBAED,oFAAoF;gBACpF,iBAAiB,EAAE,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC,CAAC;YAClF,CAAC;SACF,CAAA;QAz5BK,8BAA8B;YADnC,mBAAmB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;WAClC,8BAA8B,CAy5BnC;QAED,MAAM,CAAC,cAAc,CAAC,8BAA8B,EAAE,MAAM,EAAE;YAC5D,KAAK,EAAE,IAAI;YACX,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;QAEH,OAAO,8BAA8B,CAAC;IACxC,CAAC;CACF","sourcesContent":["import { BaseRestController, type TRouteContext } from '@/base/controllers';\nimport { controller as controllerDecorator } from '@/base/metadata';\nimport {\n BaseStorageHelper,\n RequestUtility,\n StorageUtility,\n type IObjectLocation,\n type IObjectMetadata,\n type IObjectRef,\n type IStorageHelper,\n type IUploadFile,\n type IPostPolicy,\n type IUploadResult,\n type TUploadNaming,\n} from '@venizia/ignis-helpers';\nimport { HTTP, ResolverUtility, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport type { AnyType, TValueOrAsyncResolver } from '@venizia/ignis-helpers/common';\nimport { BaseHelper, getError, UuidHelper } from '@venizia/ignis-helpers/core';\nimport { type Env } from 'hono';\nimport { readFileSync, rmSync } from 'node:fs';\nimport {\n RENDERABLE_CONTENT_TYPES,\n StaticAssetErrors,\n type TBucketParams,\n type TDefineExtraRoutes,\n type TListQuery,\n type TMetaLinkConfig,\n DEFAULT_PENDING_PREFIX,\n META_LINK_CREATE_FAILED,\n type TObjectParams,\n type TUploadPolicyRequest,\n type TObjectNameResolver,\n type TStaticAssetExtraOptions,\n type TStaticAssetsComponentOptions,\n type TStaticAssetStorageType,\n type TUploadQuery,\n WHITELIST_HEADERS,\n} from '../common';\nimport { AssetCommitToken, DEFAULT_MAX_UPLOAD_FILES, MetaLinkRecreateActions } from '../common';\nimport { AssetDefinitionBuilder } from './base.definition';\nimport { AssetKeyScope } from './key-scope';\nimport { AssetMetaLink } from './meta-link';\nimport { AssetRouteOptions } from './route-options';\n\n/** Input of `AssetControllerFactory.defineAssetController`: one entry of `TStaticAssetsComponentOptions` with its storage type and helper. */\nexport interface IAssetControllerOptions {\n controller: TStaticAssetsComponentOptions[string]['controller'];\n storage: TStaticAssetStorageType;\n helper: IStorageHelper;\n useMetaLink?: boolean;\n /** The table is erased at this seam on purpose. The public option types carry the real `Schema` and check it; inside the controller every read and write is on MetaLink COLUMNS, and threading a table type nobody here constrains through 700 lines of handler buys nothing. */\n metaLink?: TMetaLinkConfig<AnyType>;\n options?: TStaticAssetExtraOptions;\n\n /** Decides the stored object name of each uploaded file. Absent leaves the storage helper's own naming untouched. */\n resolveObjectName?: TObjectNameResolver;\n\n /** Registers the application's own routes on the generated controller, after every built-in one. */\n /** Registers the application's own routes BEFORE every built-in one, so a literal path wins over the catch-all `rawObjectPath` produces. */\n defineRoutesBefore?: TDefineExtraRoutes;\n defineExtraRoutes?: TDefineExtraRoutes;\n}\n\n/** Hono ALREADY percent-decodes path params - a second decodeURIComponent throws on `report_100%.pdf` and turns `a%2Fb.png` into a DIFFERENT object; `isValidName`/`isValidPath` still run on this value, so traversal is still rejected. */\n/** The upload labels, read off the multipart form. Every value arrives as text, so `sequence` is the one that needs converting. */\n/** One list: the reader below and the stale-caller warning must agree. */\nconst UPLOAD_LABEL_NAMES = [\n 'principalType',\n 'principalId',\n 'variant',\n 'sequence',\n 'folderPath',\n] as const;\n\n/** The body of `AssetControllerFactory.findLabelsInQuery`, callable from the helpers above the class. */\nconst listLabelsInQuery = (opts: {\n query: Record<string, string>;\n names?: ReadonlyArray<(typeof UPLOAD_LABEL_NAMES)[number]>;\n}): string[] => (opts.names ?? UPLOAD_LABEL_NAMES).filter((name) => opts.query[name] !== undefined);\n\n/** Refused before the body is read: a route that ignored them would store an unlabelled row. */\nconst refuseLabelsInQuery = (opts: {\n query: Record<string, string>;\n names?: ReadonlyArray<(typeof UPLOAD_LABEL_NAMES)[number]>;\n reason?: string;\n}): void => {\n const names = listLabelsInQuery(opts);\n\n if (names.length > 0) {\n throw getError({\n error: StaticAssetErrors.LABELS_IN_QUERY,\n message: `${opts.reason ?? 'Upload labels belong in the request body, not the query'} | names: ${names.join(', ')}`,\n });\n }\n};\n\n/** The commit body carries four of the five: the object key - and so `folderPath` - was fixed when the policy was issued. */\nconst COMMIT_LABEL_NAMES = UPLOAD_LABEL_NAMES.filter((name) => name !== 'folderPath');\n\n// A multipart form hands strings; a JSON commit body may hand `sequence` as a number.\nconst readUploadLabels = (opts: {\n fields: Partial<Record<(typeof UPLOAD_LABEL_NAMES)[number], string | number>>;\n}): TUploadQuery => {\n const { fields } = opts;\n\n const read = (name: (typeof UPLOAD_LABEL_NAMES)[number]) => {\n const value = fields[name];\n\n return value === undefined || value === '' ? undefined : String(value);\n };\n\n const sequence = read('sequence');\n\n return {\n principalType: read('principalType'),\n principalId: read('principalId'),\n variant: read('variant'),\n sequence: sequence === undefined ? undefined : Number(sequence),\n folderPath: read('folderPath'),\n };\n};\n\nconst readObjectName: (rawObjectName: string) => string = (rawObjectName) => rawObjectName;\n\n/** Encodes an object path into a SINGLE url segment: `{objectName}` matches one segment only, so `/` must be percent-encoded too (Hono decodes it back before the handler reads the param). */\nconst encodeObjectPath: (objectPath: string) => string = (objectPath) => {\n return encodeURIComponent(objectPath);\n};\n\n/** The bucket one request works on: a configured value wins - called on every request, so an application may read an environment variable lazily - else the path param, which is only registered when there is no configured bucket. */\nconst resolveBucket = async (opts: {\n configured?: TValueOrAsyncResolver<string>;\n param?: string;\n}): Promise<string> => {\n const { configured, param } = opts;\n\n if (configured === undefined) {\n return param ?? '';\n }\n\n return ResolverUtility.resolveValueAsync({ value: configured });\n};\n\n/** Mirrors `BaseStorageHelper.normalizeObjectName`, which is protected: `resolveObjectName` is offered the very name the helper would otherwise have written. */\nconst defaultObjectName: (opts: { file: TUploadNaming }) => string = ({ file }) => {\n const { originalName, folderPath } = file;\n const normalizedFileName = originalName.toLowerCase().replace(/ /g, '_');\n\n if (!folderPath) {\n return normalizedFileName;\n }\n\n return `${folderPath.toLowerCase().replace(/ /g, '_')}/${normalizedFileName}`;\n};\n\n/**\n * Reads one `Range` header. Only a single byte range is honoured - multipart ranges need a multipart\n * body no browser asks for here. An unsatisfiable or malformed range returns `null`, and the caller\n * serves the whole object, which is what RFC 9110 allows.\n */\nconst readByteRange = (opts: {\n header: string | undefined;\n size: number;\n}): { start: number; end: number } | null => {\n const { header, size } = opts;\n\n if (!header || size <= 0) {\n return null;\n }\n\n const match = /^bytes=(\\d*)-(\\d*)$/.exec(header.trim());\n\n if (!match) {\n return null;\n }\n\n const [, rawStart, rawEnd] = match;\n\n // `bytes=-500` means the LAST 500 bytes, not \"from 0 to 500\".\n if (!rawStart) {\n const suffixLength = Number(rawEnd);\n\n if (!Number.isInteger(suffixLength) || suffixLength <= 0) {\n return null;\n }\n\n return { start: Math.max(size - suffixLength, 0), end: size - 1 };\n }\n\n const start = Number(rawStart);\n const end = rawEnd ? Number(rawEnd) : size - 1;\n\n if (!Number.isInteger(start) || !Number.isInteger(end) || start > end || start >= size) {\n return null;\n }\n\n return { start, end: Math.min(end, size - 1) };\n};\n\n/** Sets whitelisted metadata headers on the response context. `content-type` is not among them. */\nconst applyMetadataHeaders: (opts: {\n ctx: TRouteContext<Env>;\n metadata: IObjectMetadata;\n}) => void = ({ ctx, metadata }) => {\n Object.entries(metadata).forEach(([key, value]) => {\n if (!WHITELIST_HEADERS.includes(key.toLowerCase() as (typeof WHITELIST_HEADERS)[number])) {\n return;\n }\n\n ctx.header(key.toLowerCase(), String(value).replace(/[\\r\\n]/g, ''));\n });\n};\n\n/** Builds the REST controller class for a static asset entry. Static helpers also expose label checking, object link building and served content type resolution. */\nexport class AssetControllerFactory extends BaseHelper {\n constructor() {\n super({ scope: AssetControllerFactory.name });\n }\n\n /** Names any label a caller put in the query - where the upload routes refuse it. */\n static findLabelsInQuery(opts: {\n query: Record<string, string>;\n names?: ReadonlyArray<(typeof UPLOAD_LABEL_NAMES)[number]>;\n }): string[] {\n return listLabelsInQuery(opts);\n }\n\n /** The URL of one object, in the shape its controller serves: no `/buckets/<name>` with a configured bucket, and a raw path with `rawObjectPath`. */\n static buildObjectLink(\n opts: IObjectLocation & {\n basePath: string;\n hasConfiguredBucket?: boolean;\n rawObjectPath?: boolean;\n },\n ): string {\n const { basePath, bucket, object } = opts;\n const { hasConfiguredBucket = false, rawObjectPath = false } = opts;\n\n const bucketSegment = hasConfiguredBucket ? '' : `/buckets/${bucket.name}`;\n const objectSegment = rawObjectPath ? object.key : encodeObjectPath(object.key);\n\n return `${basePath}${bucketSegment}/objects/${objectSegment}`;\n }\n\n /**\n * The served type comes from the object NAME, never the backend or the uploader: a renderable type on\n * the API origin is stored XSS. Public so a hand-written route makes the same decision - the\n * backend's own content-type is dropped by `WHITELIST_HEADERS`.\n */\n static resolveServedContentType(opts: { helper: IStorageHelper; object: IObjectRef }): {\n contentType: string;\n isRenderable: boolean;\n } {\n const { helper, object } = opts;\n const candidate = helper\n .getMimeType({ filename: object.key })\n .toLowerCase()\n .split(';')[0]\n .trim();\n\n if (!RENDERABLE_CONTENT_TYPES.has(candidate)) {\n return { contentType: HTTP.HeaderValues.APPLICATION_OCTET_STREAM, isRenderable: false };\n }\n\n return { contentType: candidate, isRenderable: true };\n }\n\n static defineAssetController(opts: IAssetControllerOptions) {\n const { controller, helper, options, useMetaLink, metaLink, storage } = opts;\n const { resolveObjectName, defineRoutesBefore, defineExtraRoutes } = opts;\n const { directUpload } = controller;\n const { name, basePath, routes, isStrict = true, bucket, rawObjectPath = false } = controller;\n const maxFolderDepth = options?.maxFolderDepth ?? BaseStorageHelper.DEFAULT_MAX_FOLDER_DEPTH;\n const maxBytes = options?.maxBytes;\n\n const hasConfiguredBucket = bucket !== undefined;\n\n // With the bucket in the URL, the bucket routes stay unscoped and the scope spans every bucket.\n if (controller.keyPrefix !== undefined && !hasConfiguredBucket) {\n throw getError({\n message: `[${name}] keyPrefix needs controller.bucket | a bucket in the URL is a bucket the caller chooses, and the bucket routes cannot be scoped`,\n });\n }\n\n const scope =\n controller.keyPrefix === undefined\n ? undefined\n : AssetKeyScope.normalizePrefix({ keyPrefix: controller.keyPrefix, helper, scope: name });\n const keyPrefix = scope?.keyPrefix;\n // `maxFolderDepth` counts the caller's folders; the scope's own are configuration, not input.\n const objectKeyMaxDepth = maxFolderDepth + (scope?.depth ?? 0);\n // The component's own name under a scope: the original name must stay one segment, as without one.\n const isScopedDefaultNaming =\n keyPrefix !== undefined && !resolveObjectName && !options?.normalizeNameFn;\n const definitions = AssetDefinitionBuilder.build({\n hasConfiguredBucket,\n rawObjectPath,\n maxPolicyFiles: options?.parseMultipartBody?.maxFiles ?? DEFAULT_MAX_UPLOAD_FILES,\n });\n\n // The mount path may be declared with or without a leading slash; a link must carry exactly one.\n const normalizedBasePath = basePath.startsWith('/') ? basePath : `/${basePath}`;\n\n /** Only when the URL shape deviates: with neither option the storage helper's own link is left untouched. */\n const shapedLinkFn =\n hasConfiguredBucket || rawObjectPath\n ? (linkOptions: IObjectLocation) =>\n AssetControllerFactory.buildObjectLink({\n basePath: normalizedBasePath,\n bucket: linkOptions.bucket,\n object: linkOptions.object,\n hasConfiguredBucket,\n rawObjectPath,\n })\n : undefined;\n const normalizeLinkFn = options?.normalizeLinkFn ?? shapedLinkFn;\n\n @controllerDecorator({ path: basePath })\n class GeneratedStaticAssetController extends BaseRestController {\n constructor() {\n super({\n scope: name,\n path: basePath,\n isStrict,\n });\n }\n\n /** Clears the multipart spool files written by `parseMultipartBody({ storage: 'disk' })`. */\n removeSpoolFiles(spoolOptions: { paths: string[] }): void {\n for (const filePath of spoolOptions.paths) {\n try {\n rmSync(filePath, { force: true });\n } catch (error) {\n this.logger\n .for('UPLOAD')\n .error('Failed to remove spool file | path: %s | Error: %s', filePath, error);\n }\n }\n }\n\n override binding(): ValueOrPromise<void> {\n // First, so a literal path can win over the built-in catch-all `rawObjectPath` registers.\n defineRoutesBefore?.({ controller: this, helper, basePath: normalizedBasePath });\n\n // A single-bucket application has no reason to expose bucket creation or deletion, so the\n // four bucket-management routes are not registered once `bucket` is configured.\n if (!hasConfiguredBucket) {\n const getBucketsRoute = AssetRouteOptions.readOverride({ route: routes?.getBuckets });\n\n if (getBucketsRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.GET_BUCKETS, ...getBucketsRoute.override },\n }).to({\n handler: async (ctx) => {\n const buckets = await helper.getBuckets();\n\n return ctx.json(buckets, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n\n const getBucketByNameRoute = AssetRouteOptions.readOverride({\n route: routes?.getBucketByName,\n });\n\n if (getBucketByNameRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.GET_BUCKET_BY_NAME, ...getBucketByNameRoute.override },\n }).to({\n handler: async (ctx) => {\n const params = ctx.req.valid<TBucketParams>('param');\n const bucketName = await resolveBucket({\n configured: bucket,\n param: params.bucketName,\n });\n\n if (!helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n const found = await helper.getBucket({ bucket: { name: bucketName } });\n\n return ctx.json(found, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n\n const createBucketRoute = AssetRouteOptions.readOverride({ route: routes?.createBucket });\n\n if (createBucketRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.CREATE_BUCKET, ...createBucketRoute.override },\n }).to({\n handler: async (ctx) => {\n const params = ctx.req.valid<TBucketParams>('param');\n const bucketName = await resolveBucket({\n configured: bucket,\n param: params.bucketName,\n });\n\n if (!helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n const createdBucket = await helper.createBucket({ bucket: { name: bucketName } });\n\n return ctx.json(createdBucket, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n\n const deleteBucketRoute = AssetRouteOptions.readOverride({ route: routes?.deleteBucket });\n\n if (deleteBucketRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.DELETE_BUCKET, ...deleteBucketRoute.override },\n }).to({\n handler: async (ctx) => {\n const params = ctx.req.valid<TBucketParams>('param');\n const bucketName = await resolveBucket({\n configured: bucket,\n param: params.bucketName,\n });\n\n if (!helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n const isRemovedBucket = await helper.removeBucket({\n bucket: { name: bucketName },\n });\n\n return ctx.json({ isDeleted: isRemovedBucket }, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n }\n\n const getObjectByNameRoute = AssetRouteOptions.readOverride({\n route: routes?.getObjectByName,\n });\n\n if (getObjectByNameRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.GET_OBJECT_BY_NAME, ...getObjectByNameRoute.override },\n }).to({\n handler: async (ctx) => {\n const params = ctx.req.valid<TObjectParams>('param');\n const bucketName = await resolveBucket({\n configured: bucket,\n param: params.bucketName,\n });\n const objectName = readObjectName(params.objectName);\n\n if (!helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n if (\n !helper.isValidObjectKey({\n object: { key: objectName },\n maxDepth: objectKeyMaxDepth,\n })\n ) {\n throw getError({ error: StaticAssetErrors.OBJECT_NAME_INVALID });\n }\n\n // Before any storage call: a key outside the scope must not even be probed.\n AssetKeyScope.assertInScope({ key: objectName, keyPrefix });\n\n const fileStat = await helper.getStat({\n bucket: { name: bucketName },\n object: { key: objectName },\n });\n const { size, metadata } = fileStat;\n applyMetadataHeaders({ ctx, metadata });\n\n const served = AssetControllerFactory.resolveServedContentType({\n helper,\n object: { key: objectName },\n });\n ctx.header(HTTP.Headers.CONTENT_TYPE, served.contentType);\n ctx.header('x-content-type-options', 'nosniff');\n // Sandboxed even when renderable, so an unforeseen renderable type cannot reach this origin.\n ctx.header(HTTP.Headers.CONTENT_SECURITY_POLICY, 'sandbox');\n // Advertised unconditionally: a player only offers seeking once it sees this.\n ctx.header('accept-ranges', 'bytes');\n\n // A type outside the allow-list downloads instead of rendering; that is the XSS boundary.\n if (!served.isRenderable) {\n const inlineName = objectName.split('/').pop() ?? objectName;\n ctx.header(\n HTTP.Headers.CONTENT_DISPOSITION,\n RequestUtility.buildContentDispositionHeader({\n filename: inlineName,\n type: 'attachment',\n }),\n );\n }\n\n const range = readByteRange({ header: ctx.req.header('range'), size });\n\n if (range) {\n ctx.header(HTTP.Headers.CONTENT_LENGTH, String(range.end - range.start + 1));\n ctx.header(HTTP.Headers.CONTENT_RANGE, `bytes ${range.start}-${range.end}/${size}`);\n } else {\n ctx.header(HTTP.Headers.CONTENT_LENGTH, size.toString());\n }\n\n // The web stream is what a Response body wants, so no Node Readable sits in between.\n const stream = await helper.getObjectStream({\n bucket: { name: bucketName },\n object: { key: objectName },\n ...(range ? { range } : {}),\n });\n\n return new Response(stream, {\n headers: ctx.res.headers,\n status: range ? HTTP.ResultCodes.RS_2.PartialContent : HTTP.ResultCodes.RS_2.Ok,\n });\n },\n });\n }\n\n const downloadObjectByNameRoute = AssetRouteOptions.readOverride({\n route: routes?.downloadObjectByName,\n });\n\n if (downloadObjectByNameRoute.isEnabled) {\n this.bindRoute({\n configs: {\n ...definitions.DOWNLOAD_OBJECT_BY_NAME,\n ...downloadObjectByNameRoute.override,\n },\n }).to({\n handler: async (ctx) => {\n const params = ctx.req.valid<TObjectParams>('param');\n const bucketName = await resolveBucket({\n configured: bucket,\n param: params.bucketName,\n });\n const objectName = readObjectName(params.objectName);\n\n if (!helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n if (\n !helper.isValidObjectKey({\n object: { key: objectName },\n maxDepth: objectKeyMaxDepth,\n })\n ) {\n throw getError({ error: StaticAssetErrors.OBJECT_NAME_INVALID });\n }\n\n // Before any storage call: a key outside the scope must not even be probed.\n AssetKeyScope.assertInScope({ key: objectName, keyPrefix });\n\n const fileStat = await helper.getStat({\n bucket: { name: bucketName },\n object: { key: objectName },\n });\n const { size, metadata } = fileStat;\n applyMetadataHeaders({ ctx, metadata });\n\n // Download always attaches, so the served type only has to be honest, never renderable.\n const served = AssetControllerFactory.resolveServedContentType({\n helper,\n object: { key: objectName },\n });\n ctx.header(HTTP.Headers.CONTENT_TYPE, served.contentType);\n ctx.header(HTTP.Headers.CONTENT_LENGTH, size.toString());\n\n const fileName = objectName.split('/').pop() ?? objectName;\n ctx.header(\n HTTP.Headers.CONTENT_DISPOSITION,\n RequestUtility.buildContentDispositionHeader({\n filename: fileName,\n type: 'attachment',\n }),\n );\n ctx.header('x-content-type-options', 'nosniff');\n ctx.header(HTTP.Headers.CONTENT_SECURITY_POLICY, 'sandbox');\n\n const stream = await helper.getObjectStream({\n bucket: { name: bucketName },\n object: { key: objectName },\n });\n\n return new Response(stream, {\n headers: ctx.res.headers,\n status: HTTP.ResultCodes.RS_2.Ok,\n });\n },\n });\n }\n\n const uploadRoute = AssetRouteOptions.readOverride({ route: routes?.upload });\n\n if (uploadRoute.isEnabled) {\n const uploadMiddleware =\n maxBytes === undefined\n ? uploadRoute.override.middleware\n : AssetRouteOptions.appendLengthGuard({\n middleware: uploadRoute.override.middleware,\n maxBytes,\n maxFiles: options?.parseMultipartBody?.maxFiles ?? DEFAULT_MAX_UPLOAD_FILES,\n });\n\n this.bindRoute({\n configs: {\n ...definitions.UPLOAD,\n ...uploadRoute.override,\n middleware: uploadMiddleware,\n },\n }).to({\n handler: async (ctx) => {\n // A configured bucket drops `params` from this route entirely, so it is read only when it exists.\n const bucketParam = hasConfiguredBucket\n ? undefined\n : ctx.req.valid<TBucketParams>('param').bucketName;\n const bucketName = await resolveBucket({ configured: bucket, param: bucketParam });\n\n if (!helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n const validateFolderPath = (folderPath: string) => {\n const normalizedFolder = folderPath.replace(/^\\/+|\\/+$/g, '');\n\n if (!normalizedFolder) {\n throw getError({ error: StaticAssetErrors.FOLDER_PATH_INVALID });\n }\n\n // maxFolderDepth excludes the filename, so it is compared directly against segment count.\n const folderSegments = normalizedFolder.split('/');\n\n if (folderSegments.length > maxFolderDepth) {\n throw getError({\n error: StaticAssetErrors.FOLDER_DEPTH_EXCEEDED,\n message: `Folder path exceeds max depth of ${maxFolderDepth}`,\n });\n }\n\n const invalidSegmentIndex = folderSegments.findIndex(\n (segment) => !helper.isValidSegment({ segment }),\n );\n\n if (invalidSegmentIndex !== -1) {\n throw getError({\n error: StaticAssetErrors.FOLDER_SEGMENT_INVALID,\n message: `Invalid folder path segment: ${folderSegments[invalidSegmentIndex]}`,\n });\n }\n };\n\n refuseLabelsInQuery({ query: ctx.req.query() });\n\n const { files: filesArray, fields } = await RequestUtility.parseMultipartBody({\n context: ctx,\n storage: options?.parseMultipartBody?.storage,\n uploadDir: options?.parseMultipartBody?.uploadDir,\n maxFiles: options?.parseMultipartBody?.maxFiles ?? DEFAULT_MAX_UPLOAD_FILES,\n });\n\n const spoolPaths = filesArray\n .map((file) => file.path)\n .filter((filePath): filePath is string => Boolean(filePath));\n\n let query: ReturnType<typeof readUploadLabels>;\n let uploaded: IUploadResult[];\n\n // From here every exit removes the spool files, the validation failures included.\n try {\n // Labels travel with the payload, not the URL, so the folder check waits for the parse.\n query = readUploadLabels({ fields });\n\n const folderPath = query.folderPath;\n\n if (folderPath) {\n validateFolderPath(folderPath);\n }\n\n // `storage: 'disk'` spools the payload to `uploadDir` and returns `path` instead of `buffer`; the storage helpers only ever write `buffer`, so it must be read back.\n const modifiedFiles: IUploadFile[] = filesArray.map((file) => {\n const buffer = file.buffer ?? (file.path ? readFileSync(file.path) : undefined);\n\n if (!buffer?.length) {\n throw getError({\n error: StaticAssetErrors.FILE_EMPTY,\n message: `Empty file content | name: ${file.originalname}`,\n });\n }\n\n // Authoritative: `buffer.length`, not the client-declared `size`.\n if (maxBytes !== undefined && buffer.length > maxBytes) {\n throw getError({\n error: StaticAssetErrors.UPLOAD_TOO_LARGE,\n message: `File ${file.originalname} of ${buffer.length} bytes exceeds the maximum of ${maxBytes}`,\n });\n }\n\n return {\n originalName: file.originalname,\n mimetype: file.mimetype,\n buffer,\n size: file.size,\n encoding: file.encoding,\n folderPath: folderPath ?? undefined,\n };\n });\n\n // Built per request: the hook is offered the bucket, which only the route knows. With\n // neither hook nor scope, `normalizeNameFn` stays exactly as configured. Under a scope,\n // the component's own default is placed inside it; an application hook's key is\n // checked, never rewritten, because the application may record that key elsewhere.\n const normalizeNameFn =\n resolveObjectName || keyPrefix !== undefined\n ? (naming: { file: TUploadNaming }) => {\n if (\n isScopedDefaultNaming &&\n !helper.isValidSegment({ segment: naming.file.originalName })\n ) {\n throw getError({ message: '[upload] Invalid original file name' });\n }\n\n const defaultKey = options?.normalizeNameFn\n ? options.normalizeNameFn(naming)\n : `${keyPrefix ?? ''}${defaultObjectName(naming)}`;\n\n const key = resolveObjectName\n ? resolveObjectName({\n bucket: { name: bucketName },\n file: naming.file,\n defaultKey,\n })\n : defaultKey;\n\n if (!AssetKeyScope.isInScope({ key, keyPrefix })) {\n throw getError({\n error: StaticAssetErrors.OBJECT_KEY_OUT_OF_SCOPE,\n message: `Object key is outside the key prefix of this controller | key: ${key} | keyPrefix: ${keyPrefix}`,\n });\n }\n\n return key;\n }\n : options?.normalizeNameFn;\n\n const result = await helper.upload({\n bucket: { name: bucketName },\n files: modifiedFiles,\n normalizeNameFn,\n normalizeLinkFn,\n // Without this the helper re-validates against its own hard default of 2, so an app configured for a deeper tree spools the body and only then fails inside the helper.\n maxFolderDepth: objectKeyMaxDepth,\n });\n uploaded = result;\n } finally {\n this.removeSpoolFiles({ paths: spoolPaths });\n }\n\n if (!useMetaLink || !metaLink) {\n return ctx.json(uploaded, HTTP.ResultCodes.RS_2.Ok);\n }\n\n const results: IUploadResult[] = [];\n\n for (const uploadResult of uploaded) {\n try {\n const fileStat = await helper.getStat({\n bucket: uploadResult.bucket,\n object: uploadResult.object,\n });\n\n const createdMetaLink = await AssetMetaLink.createRow({\n metaLink,\n helper,\n storage,\n uploadResult,\n fileStat,\n query,\n });\n\n results.push({ ...uploadResult, metaLink: { data: createdMetaLink } });\n } catch (error) {\n this.logger\n .for('UPLOAD')\n .error(\n 'Failed to create MetaLink | objectName: %s | Error: %s',\n uploadResult.object.key,\n error,\n );\n results.push({\n ...uploadResult,\n // A CODE, never the driver text. This handler returns 200, so it bypasses the\n // error middleware and `database.handler` - the two places that strip\n // `detail`/`table`/`constraint` - and shipped raw constraint names to the client.\n // The real error is already logged in full immediately above.\n metaLink: { error: META_LINK_CREATE_FAILED },\n });\n }\n }\n\n return ctx.json(results, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n\n const deleteObjectRoute = AssetRouteOptions.readOverride({ route: routes?.deleteObject });\n\n if (deleteObjectRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.DELETE_OBJECT, ...deleteObjectRoute.override },\n }).to({\n handler: async (ctx) => {\n const params = ctx.req.valid<TObjectParams>('param');\n const bucketName = await resolveBucket({\n configured: bucket,\n param: params.bucketName,\n });\n const objectName = readObjectName(params.objectName);\n\n if (!helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n if (\n !helper.isValidObjectKey({\n object: { key: objectName },\n maxDepth: objectKeyMaxDepth,\n })\n ) {\n throw getError({ error: StaticAssetErrors.OBJECT_NAME_INVALID });\n }\n\n // Before any storage call: a key outside the scope must not even be probed.\n AssetKeyScope.assertInScope({ key: objectName, keyPrefix });\n\n // Deliberately idempotent: S3 answers 200 for a key that was never there, and consumers\n // already depend on it. `disk` throws instead, so the two are reconciled here, not below.\n try {\n await helper.removeObject({\n bucket: { name: bucketName },\n object: { key: objectName },\n });\n } catch (error) {\n if (!StorageUtility.isNotFoundError({ error })) {\n throw error;\n }\n }\n\n if (!useMetaLink || !metaLink) {\n return ctx.json({ success: true }, HTTP.ResultCodes.RS_2.Ok);\n }\n\n const deleteRepository = await ResolverUtility.resolveValueAsync({\n value: metaLink.repository,\n });\n deleteRepository\n .deleteAll({\n where: {\n bucketName,\n objectName,\n },\n })\n .then(() => {\n this.logger\n .for('DELETE_OBJECT')\n .info('Successfully to delete MetaLink for %s/%s', bucketName, objectName);\n })\n .catch((error) => {\n this.logger\n .for('DELETE_OBJECT')\n .error(\n 'Failed to delete MetaLink | bucket: %s | objectName: %s | Error: %s',\n bucketName,\n objectName,\n error,\n );\n });\n\n return ctx.json({ success: true }, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n\n const listObjectsRoute = AssetRouteOptions.readOverride({ route: routes?.listObjects });\n\n if (listObjectsRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.LIST_OBJECTS, ...listObjectsRoute.override },\n }).to({\n handler: async (ctx) => {\n // A configured bucket drops `params` from this route entirely, so it is read only when it exists.\n const bucketParam = hasConfiguredBucket\n ? undefined\n : ctx.req.valid<TBucketParams>('param').bucketName;\n const bucketName = await resolveBucket({ configured: bucket, param: bucketParam });\n const { prefix, recursive, maxKeys } = ctx.req.valid<TListQuery>('query');\n\n if (!helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n // A NaN or 0 maxKeys is silently treated as \"unlimited\" by the storage backends, so an unparsable value must be rejected instead of forwarded.\n let resolvedMaxKeys: number | undefined;\n\n if (maxKeys !== undefined) {\n resolvedMaxKeys = Number(maxKeys);\n\n if (!Number.isInteger(resolvedMaxKeys) || resolvedMaxKeys < 1) {\n throw getError({\n error: StaticAssetErrors.MAX_KEYS_INVALID,\n message: `Invalid maxKeys | Expected a positive integer | value: ${maxKeys}`,\n });\n }\n }\n\n const scoped = AssetKeyScope.resolveListPrefix({ prefix, keyPrefix });\n\n if (scoped.isOutOfScope) {\n return ctx.json([], HTTP.ResultCodes.RS_2.Ok);\n }\n\n const objects = await helper.listObjects({\n bucket: { name: bucketName },\n prefix: scoped.prefix,\n useRecursive: recursive === 'true',\n maxKeys: resolvedMaxKeys,\n });\n\n return ctx.json(objects, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n\n if (directUpload) {\n if (!hasConfiguredBucket) {\n throw getError({\n message: `[${name}] directUpload needs controller.bucket | a policy names one bucket, and a bucket in the URL is a bucket the caller chooses`,\n });\n }\n\n const pendingPrefix = directUpload.pendingPrefix ?? DEFAULT_PENDING_PREFIX;\n // The scope rides inside the pending key, so the commit, which strips `pendingPrefix`, lands inside it.\n const policyKeyPrefix = `${pendingPrefix}${keyPrefix ?? ''}`;\n\n const uploadPolicyRoute = AssetRouteOptions.readOverride({ route: routes?.uploadPolicy });\n\n if (uploadPolicyRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.UPLOAD_POLICY, ...uploadPolicyRoute.override },\n }).to({\n handler: async (ctx) => {\n const result = await directUpload.authorize({ context: ctx });\n\n if (!result) {\n throw getError({ error: StaticAssetErrors.UPLOAD_NOT_AUTHORIZED });\n }\n\n const { files } = ctx.req.valid<TUploadPolicyRequest>('json');\n const bucketName = await resolveBucket({ configured: bucket });\n\n const policies: Array<IPostPolicy & { objectName: string; commitToken: string }> =\n [];\n\n for (const file of files) {\n if (file.size !== undefined && file.size > directUpload.maxBytes) {\n throw getError({\n error: StaticAssetErrors.UPLOAD_TOO_LARGE,\n message: `File '${file.fileName}' is ${file.size} bytes, over the ${directUpload.maxBytes} the policy allows`,\n });\n }\n\n // Generated, never taken from the caller: a key the caller picks is a key the caller\n // can collide with, and the pending object is the one thing a policy authorizes.\n const objectName = `${policyKeyPrefix}${UuidHelper.getInstance().v4()}/${file.fileName}`;\n const policy = await helper.presignPost({\n bucket: { name: bucketName },\n keyPrefix: policyKeyPrefix,\n maxBytes: directUpload.maxBytes,\n contentType: file.contentType,\n expiresIn: directUpload.expiresIn,\n });\n\n policies.push({\n ...policy,\n objectName,\n commitToken: AssetCommitToken.build({\n payload: {\n bucket: bucketName,\n key: objectName,\n expiresAt: new Date(policy.expiresAt).getTime(),\n },\n secretKey: directUpload.secretKey,\n }),\n });\n }\n\n return ctx.json(policies, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n\n const uploadCommitRoute = AssetRouteOptions.readOverride({ route: routes?.uploadCommit });\n\n if (uploadCommitRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.UPLOAD_COMMIT, ...uploadCommitRoute.override },\n }).to({\n handler: async (ctx) => {\n const commitQuery = ctx.req.query();\n refuseLabelsInQuery({ query: commitQuery, names: COMMIT_LABEL_NAMES });\n refuseLabelsInQuery({\n query: commitQuery,\n names: ['folderPath'],\n reason:\n 'folderPath was decided when the upload policy was issued; the commit route cannot move the object',\n });\n\n const { commitToken, ...labels } = ctx.req.valid<\n { commitToken: string } & TUploadQuery\n >('json');\n\n // Verified BEFORE any storage call. That is what keeps this route from being a name\n // prober: a forged token fails without a round trip, so timing says nothing.\n const payload = AssetCommitToken.read({\n token: commitToken,\n secretKey: directUpload.secretKey,\n });\n\n // Labels, not authorization - the token deliberately carries no business fields, so\n // they travel beside it rather than inside it.\n const query = readUploadLabels({ fields: labels });\n\n const bucketRef = { name: payload.bucket };\n const pendingObject = { key: payload.key };\n const object = { key: payload.key.slice(pendingPrefix.length) };\n\n // A token another controller signed with the same secret must not land outside this scope.\n AssetKeyScope.assertInScope({ key: object.key, keyPrefix });\n\n // Before the copy, so a hook that throws leaves the object under the pending prefix\n // for a lifecycle rule, rather than stranding it at the final key.\n await directUpload.onCommit?.({ bucket: bucketRef, pendingObject, object });\n\n await helper.copyObject({\n bucket: bucketRef,\n source: pendingObject,\n destination: object,\n });\n\n // The copy IS the commit; removing the temporary object is cleanup. A failure here\n // leaves one object for the lifecycle rule, and failing the request would tell the\n // caller their upload did not work when it did.\n try {\n await helper.removeObject({ bucket: bucketRef, object: pendingObject });\n } catch (error) {\n this.logger\n .for('UPLOAD_COMMIT')\n .warn(\n 'Committed, but the pending object remains | key: %s | error: %s',\n pendingObject.key,\n error,\n );\n }\n\n const link = AssetControllerFactory.buildObjectLink({\n basePath: normalizedBasePath,\n bucket: bucketRef,\n object,\n hasConfiguredBucket,\n rawObjectPath,\n });\n\n // The two paths have to agree: without this a client reading `metaLink` off the\n // response renders an empty state with no error - the failure nobody reports.\n let metaLinkResult: IUploadResult['metaLink'];\n\n if (useMetaLink && metaLink) {\n try {\n const fileStat = await helper.getStat({ bucket: bucketRef, object });\n const data = await AssetMetaLink.createRow({\n metaLink,\n helper,\n storage,\n uploadResult: AssetMetaLink.buildStoredUploadResult({\n helper,\n bucket: bucketRef,\n object,\n link,\n fileStat,\n }),\n fileStat,\n query,\n });\n\n metaLinkResult = { data };\n } catch (error) {\n // The object IS committed by now. A 500 would send the caller back with a token\n // whose source no longer exists, so this rides the body as a code, like UPLOAD.\n this.logger\n .for('UPLOAD_COMMIT')\n .error(\n 'Failed to create MetaLink | objectName: %s | Error: %s',\n object.key,\n error,\n );\n metaLinkResult = { error: META_LINK_CREATE_FAILED };\n }\n }\n\n return ctx.json(\n {\n bucket: bucketRef,\n object,\n link,\n ...(metaLinkResult === undefined ? {} : { metaLink: metaLinkResult }),\n },\n HTTP.ResultCodes.RS_2.Ok,\n );\n },\n });\n }\n }\n\n if (useMetaLink && metaLink) {\n const recreateMetaLinkRoute = AssetRouteOptions.readOverride({\n route: routes?.recreateMetaLink,\n });\n\n if (recreateMetaLinkRoute.isEnabled) {\n this.bindRoute({\n configs: { ...definitions.RECREATE_METALINK, ...recreateMetaLinkRoute.override },\n }).to({\n handler: async (ctx) => {\n // This route takes no labels anywhere: one in the query would land an unlabelled row.\n refuseLabelsInQuery({\n query: ctx.req.query(),\n reason:\n 'This route recreates a MetaLink for an existing object and takes no labels',\n });\n\n const params = ctx.req.valid<TObjectParams>('param');\n const bucketName = await resolveBucket({\n configured: bucket,\n param: params.bucketName,\n });\n const objectName = readObjectName(params.objectName);\n\n if (!helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n if (\n !helper.isValidObjectKey({\n object: { key: objectName },\n maxDepth: objectKeyMaxDepth,\n })\n ) {\n throw getError({ error: StaticAssetErrors.OBJECT_NAME_INVALID });\n }\n\n // Before any storage call: a key outside the scope must not even be probed.\n AssetKeyScope.assertInScope({ key: objectName, keyPrefix });\n\n const bucketRef = { name: bucketName };\n const object = { key: objectName };\n const fileStat = await helper.getStat({ bucket: bucketRef, object });\n\n const link = options?.normalizeLinkFn\n ? options.normalizeLinkFn({ bucket: bucketRef, object })\n : AssetControllerFactory.buildObjectLink({\n basePath: normalizedBasePath,\n bucket: bucketRef,\n object,\n hasConfiguredBucket,\n rawObjectPath,\n });\n\n const refreshed = await AssetMetaLink.refreshRows({\n metaLink,\n helper,\n bucket: bucketRef,\n object,\n link,\n fileStat,\n });\n\n if (refreshed.count > 0) {\n return ctx.json(\n {\n success: true,\n action: MetaLinkRecreateActions.REFRESHED,\n count: refreshed.count,\n metaLink: refreshed.data[0],\n metaLinks: refreshed.data,\n },\n HTTP.ResultCodes.RS_2.Ok,\n );\n }\n\n // Not atomic with the refresh above: two concurrent calls may both create, which the\n // table allows - rows per pair are deliberately not unique.\n const created = await AssetMetaLink.createRow({\n metaLink,\n helper,\n storage,\n uploadResult: AssetMetaLink.buildStoredUploadResult({\n helper,\n bucket: bucketRef,\n object,\n link,\n fileStat,\n }),\n fileStat,\n query: {},\n });\n\n return ctx.json(\n {\n success: true,\n action: MetaLinkRecreateActions.CREATED,\n count: 1,\n metaLink: created,\n metaLinks: [created],\n },\n HTTP.ResultCodes.RS_2.Ok,\n );\n },\n });\n }\n }\n\n // Last, so a built-in route always wins a path collision with an application's own.\n defineExtraRoutes?.({ controller: this, helper, basePath: normalizedBasePath });\n }\n }\n\n Object.defineProperty(GeneratedStaticAssetController, 'name', {\n value: name,\n configurable: true,\n });\n\n return GeneratedStaticAssetController;\n }\n}\n"]}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { type TStaticAssetRouteConfig } from '../common/index.js';
|
|
2
2
|
export declare class AssetRouteOptions {
|
|
3
|
+
/** Multipart framing of one file (boundary, `Content-Disposition` with a file name, `Content-Type`), allowed on top of its `maxBytes` in the route's body limit. */
|
|
4
|
+
static readonly ENVELOPE_BYTES_PER_FILE: number;
|
|
5
|
+
/** The non-file parts of an upload (policy fields, the closing boundary), allowed once in the route's body limit. */
|
|
6
|
+
static readonly ENVELOPE_BYTES_BASE: number;
|
|
3
7
|
/** Splits the `enabled` switch off the route config: it is this component's field, never a Hono one. */
|
|
4
8
|
static readOverride(opts: {
|
|
5
9
|
route?: TStaticAssetRouteConfig;
|
|
@@ -11,10 +15,15 @@ export declare class AssetRouteOptions {
|
|
|
11
15
|
* The route's body validator reads the whole multipart body, so a declared length checked in the
|
|
12
16
|
* handler arrives too late to save any memory. Appended after the application's own middleware, so
|
|
13
17
|
* a check of its own still answers first.
|
|
18
|
+
*
|
|
19
|
+
* The route also sets its own body limit: `maxFiles` files of `maxBytes` each, plus their multipart framing. An
|
|
20
|
+
* upload route that accepts more than the 5 MiB default would otherwise be held to the default, and a chunked body,
|
|
21
|
+
* which has no declared length, is counted too. The per-file check in the handler still decides each file.
|
|
14
22
|
*/
|
|
15
23
|
static appendLengthGuard(opts: {
|
|
16
24
|
middleware: TStaticAssetRouteConfig['middleware'];
|
|
17
25
|
maxBytes: number;
|
|
26
|
+
maxFiles: number;
|
|
18
27
|
}): NonNullable<TStaticAssetRouteConfig['middleware']>;
|
|
19
28
|
}
|
|
20
29
|
//# sourceMappingURL=route-options.d.ts.map
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { HTTP } from '@venizia/ignis-helpers/common';
|
|
2
2
|
import { getError } from '@venizia/ignis-helpers/core';
|
|
3
|
+
import { BodyLimits } from '@venizia/ignis-kernel';
|
|
3
4
|
import { StaticAssetErrors } from '../common/index.js';
|
|
4
5
|
export class AssetRouteOptions {
|
|
6
|
+
/** Multipart framing of one file (boundary, `Content-Disposition` with a file name, `Content-Type`), allowed on top of its `maxBytes` in the route's body limit. */
|
|
7
|
+
static { this.ENVELOPE_BYTES_PER_FILE = 4 * 1024; }
|
|
8
|
+
/** The non-file parts of an upload (policy fields, the closing boundary), allowed once in the route's body limit. */
|
|
9
|
+
static { this.ENVELOPE_BYTES_BASE = 64 * 1024; }
|
|
5
10
|
/** Splits the `enabled` switch off the route config: it is this component's field, never a Hono one. */
|
|
6
11
|
static readOverride(opts) {
|
|
7
12
|
const { enabled, ...override } = opts.route ?? {};
|
|
@@ -11,9 +16,13 @@ export class AssetRouteOptions {
|
|
|
11
16
|
* The route's body validator reads the whole multipart body, so a declared length checked in the
|
|
12
17
|
* handler arrives too late to save any memory. Appended after the application's own middleware, so
|
|
13
18
|
* a check of its own still answers first.
|
|
19
|
+
*
|
|
20
|
+
* The route also sets its own body limit: `maxFiles` files of `maxBytes` each, plus their multipart framing. An
|
|
21
|
+
* upload route that accepts more than the 5 MiB default would otherwise be held to the default, and a chunked body,
|
|
22
|
+
* which has no declared length, is counted too. The per-file check in the handler still decides each file.
|
|
14
23
|
*/
|
|
15
24
|
static appendLengthGuard(opts) {
|
|
16
|
-
const { middleware, maxBytes } = opts;
|
|
25
|
+
const { middleware, maxBytes, maxFiles } = opts;
|
|
17
26
|
const guard = async (context, next) => {
|
|
18
27
|
const declaredLength = Number(context.req.header(HTTP.Headers.CONTENT_LENGTH));
|
|
19
28
|
// Not authoritative: a multipart envelope is larger than its files, so the per-file check in the handler decides.
|
|
@@ -25,10 +34,14 @@ export class AssetRouteOptions {
|
|
|
25
34
|
}
|
|
26
35
|
await next();
|
|
27
36
|
};
|
|
37
|
+
const limit = BodyLimits.route({
|
|
38
|
+
maxSize: maxFiles * (maxBytes + AssetRouteOptions.ENVELOPE_BYTES_PER_FILE) +
|
|
39
|
+
AssetRouteOptions.ENVELOPE_BYTES_BASE,
|
|
40
|
+
});
|
|
28
41
|
if (!middleware) {
|
|
29
|
-
return [guard];
|
|
42
|
+
return [guard, limit];
|
|
30
43
|
}
|
|
31
|
-
return Array.isArray(middleware) ? [...middleware, guard] : [middleware, guard];
|
|
44
|
+
return Array.isArray(middleware) ? [...middleware, guard, limit] : [middleware, guard, limit];
|
|
32
45
|
}
|
|
33
46
|
}
|
|
34
47
|
//# sourceMappingURL=route-options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-options.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/controller/route-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"route-options.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/controller/route-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAgC,MAAM,WAAW,CAAC;AAE5E,MAAM,OAAO,iBAAiB;IAC5B,oKAAoK;aACpJ,4BAAuB,GAAG,CAAC,GAAG,IAAI,CAAC;IAEnD,qHAAqH;aACrG,wBAAmB,GAAG,EAAE,GAAG,IAAI,CAAC;IAEhD,wGAAwG;IACxG,MAAM,CAAC,YAAY,CAAC,IAAyC;QAI3D,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;QAElD,OAAO,EAAE,SAAS,EAAE,OAAO,KAAK,KAAK,EAAE,QAAQ,EAAE,CAAC;IACpD,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,iBAAiB,CAAC,IAIxB;QACC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAEhD,MAAM,KAAK,GAAsB,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;YACvD,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;YAE/E,kHAAkH;YAClH,IAAI,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,cAAc,GAAG,QAAQ,EAAE,CAAC;gBACjE,MAAM,QAAQ,CAAC;oBACb,KAAK,EAAE,iBAAiB,CAAC,gBAAgB;oBACzC,OAAO,EAAE,mBAAmB,cAAc,iCAAiC,QAAQ,EAAE;iBACtF,CAAC,CAAC;YACL,CAAC;YAED,MAAM,IAAI,EAAE,CAAC;QACf,CAAC,CAAC;QAEF,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;YAC7B,OAAO,EACL,QAAQ,GAAG,CAAC,QAAQ,GAAG,iBAAiB,CAAC,uBAAuB,CAAC;gBACjE,iBAAiB,CAAC,mBAAmB;SACxC,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACxB,CAAC;QAED,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAChG,CAAC","sourcesContent":["import { HTTP } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { BodyLimits } from '@venizia/ignis-kernel';\nimport type { MiddlewareHandler } from 'hono';\nimport { StaticAssetErrors, type TStaticAssetRouteConfig } from '../common';\n\nexport class AssetRouteOptions {\n /** Multipart framing of one file (boundary, `Content-Disposition` with a file name, `Content-Type`), allowed on top of its `maxBytes` in the route's body limit. */\n static readonly ENVELOPE_BYTES_PER_FILE = 4 * 1024;\n\n /** The non-file parts of an upload (policy fields, the closing boundary), allowed once in the route's body limit. */\n static readonly ENVELOPE_BYTES_BASE = 64 * 1024;\n\n /** Splits the `enabled` switch off the route config: it is this component's field, never a Hono one. */\n static readOverride(opts: { route?: TStaticAssetRouteConfig }): {\n isEnabled: boolean;\n override: Omit<TStaticAssetRouteConfig, 'enabled'>;\n } {\n const { enabled, ...override } = opts.route ?? {};\n\n return { isEnabled: enabled !== false, override };\n }\n\n /**\n * The route's body validator reads the whole multipart body, so a declared length checked in the\n * handler arrives too late to save any memory. Appended after the application's own middleware, so\n * a check of its own still answers first.\n *\n * The route also sets its own body limit: `maxFiles` files of `maxBytes` each, plus their multipart framing. An\n * upload route that accepts more than the 5 MiB default would otherwise be held to the default, and a chunked body,\n * which has no declared length, is counted too. The per-file check in the handler still decides each file.\n */\n static appendLengthGuard(opts: {\n middleware: TStaticAssetRouteConfig['middleware'];\n maxBytes: number;\n maxFiles: number;\n }): NonNullable<TStaticAssetRouteConfig['middleware']> {\n const { middleware, maxBytes, maxFiles } = opts;\n\n const guard: MiddlewareHandler = async (context, next) => {\n const declaredLength = Number(context.req.header(HTTP.Headers.CONTENT_LENGTH));\n\n // Not authoritative: a multipart envelope is larger than its files, so the per-file check in the handler decides.\n if (Number.isFinite(declaredLength) && declaredLength > maxBytes) {\n throw getError({\n error: StaticAssetErrors.UPLOAD_TOO_LARGE,\n message: `Request body of ${declaredLength} bytes exceeds the maximum of ${maxBytes}`,\n });\n }\n\n await next();\n };\n\n const limit = BodyLimits.route({\n maxSize:\n maxFiles * (maxBytes + AssetRouteOptions.ENVELOPE_BYTES_PER_FILE) +\n AssetRouteOptions.ENVELOPE_BYTES_BASE,\n });\n\n if (!middleware) {\n return [guard, limit];\n }\n\n return Array.isArray(middleware) ? [...middleware, guard, limit] : [middleware, guard, limit];\n }\n}\n"]}
|
|
@@ -51,8 +51,8 @@ export declare class AssetIngest {
|
|
|
51
51
|
* process: the guarded body is capped and handed to `writeStream` as a stream.
|
|
52
52
|
*
|
|
53
53
|
* The url is guarded by `UrlIngest.fetchGuarded` - scheme allow-list, every resolved address
|
|
54
|
-
* checked, redirects walked by hand with a per-hop re-check, and a timeout.
|
|
55
|
-
*
|
|
54
|
+
* checked, redirects walked by hand with a per-hop re-check, and a timeout. The connection goes to the
|
|
55
|
+
* address that was checked, so a DNS answer that changes afterwards is never used; see `UrlIngest.fetchGuarded`.
|
|
56
56
|
*
|
|
57
57
|
* The served content type is decided from the stored KEY, never from what the remote host
|
|
58
58
|
* claimed - the same rule the asset routes apply, and for the same reason.
|
|
@@ -13,8 +13,8 @@ export class AssetIngest {
|
|
|
13
13
|
* process: the guarded body is capped and handed to `writeStream` as a stream.
|
|
14
14
|
*
|
|
15
15
|
* The url is guarded by `UrlIngest.fetchGuarded` - scheme allow-list, every resolved address
|
|
16
|
-
* checked, redirects walked by hand with a per-hop re-check, and a timeout.
|
|
17
|
-
*
|
|
16
|
+
* checked, redirects walked by hand with a per-hop re-check, and a timeout. The connection goes to the
|
|
17
|
+
* address that was checked, so a DNS answer that changes afterwards is never used; see `UrlIngest.fetchGuarded`.
|
|
18
18
|
*
|
|
19
19
|
* The served content type is decided from the stored KEY, never from what the remote host
|
|
20
20
|
* claimed - the same rule the asset routes apply, and for the same reason.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ingest.js","sourceRoot":"","sources":["../../../../src/components/static-asset/ingest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,eAAe,GAOhB,MAAM,wBAAwB,CAAC;A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AAM,EAAE,CAAC;YAC9D,WAAW;YACX,cAAc,EAAE,IAAI,CAAC,cAAc;SACpC,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACtD,MAAM,IAAI,GAAG,eAAe,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAEjD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,uEAAuE,GAAG,EAAE;aACtF,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE;gBAC7B,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE;gBAC7C,IAAI;aACL;YACD,IAAI;SACL,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { getError } from '@venizia/ignis-helpers/core';\nimport {\n UrlIngest,\n UrlSafetyDefaults,\n UrlSafetyErrors,\n type IBucketRef,\n type IObjectRef,\n type IFileStat,\n type IStorageHelper,\n type IUploadResult,\n type IUrlSafetyPolicy,\n} from '@venizia/ignis-helpers';\n\n/**\n * What was stored, and what the backend reports about it. The stat is returned because `getStat`\n * already ran to size the result - a caller writing its own row would otherwise pay for it twice.\n *\n * This does NOT write a meta link. The columns an application attaches to an object - a principal,\n * a variant - come from its own domain, not from the object, so the row stays the caller's.\n */\nexport interface IIngestFromUrlResult {\n upload: IUploadResult;\n stat: IFileStat;\n}\n\n/** Where a fetched object lands, and what it is attached to. */\nexport interface IIngestFromUrlOptions {\n helper: IStorageHelper;\n url: string;\n bucket: IBucketRef;\n\n /**\n * Decides the stored key.\n *\n * **Absent, the key comes from the remote url's last path segment - which on an untrusted url is\n * named by whoever supplied it.** Pass `resolveKey` whenever the url is not your own; the\n * validation below bounds what it can do, but it does not make the remote name yours.\n */\n resolveKey?: (opts: { url: URL; contentType: string }) => string;\n folderPath?: string;\n\n /** Absent leaves IGNIS's own default: https only, no private address, 3 hops, 10s, 10 MB. */\n policy?: IUrlSafetyPolicy;\n\n /**\n * Folder nesting the key may carry.\n *\n * @default BaseStorageHelper.DEFAULT_MAX_FOLDER_DEPTH\n */\n maxFolderDepth?: number;\n\n /**\n * Where the object is served from. **Required**: an absent hook used to yield an empty link, which\n * is exactly the value that satisfies a NOT NULL column and points nowhere.\n */\n normalizeLinkFn: (opts: { bucket: IBucketRef; object: IObjectRef }) => string;\n}\n\nconst readKeyFromUrl = (opts: { url: URL; folderPath?: string }): string => {\n const { url, folderPath } = opts;\n const lastSegment = url.pathname.split('/').filter(Boolean).pop() ?? 'object';\n const normalized = lastSegment.toLowerCase().replace(/ /g, '_');\n\n return folderPath ? `${folderPath}/${normalized}` : normalized;\n};\n\n/** Storing an object that came from somewhere else. */\nexport class AssetIngest {\n /**\n * Fetches an untrusted url and stores what comes back, without the bytes passing through this\n * process: the guarded body is capped and handed to `writeStream` as a stream.\n *\n * The url is guarded by `UrlIngest.fetchGuarded` - scheme allow-list, every resolved address\n * checked, redirects walked by hand with a per-hop re-check, and a timeout.
|
|
1
|
+
{"version":3,"file":"ingest.js","sourceRoot":"","sources":["../../../../src/components/static-asset/ingest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,eAAe,GAOhB,MAAM,wBAAwB,CAAC;AA+ChC,MAAM,cAAc,GAAG,CAAC,IAAuC,EAAU,EAAE;IACzE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IACjC,MAAM,WAAW,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,IAAI,QAAQ,CAAC;IAC9E,M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EjD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,uEAAuE,GAAG,EAAE;aACtF,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE;gBAC7B,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE;gBAC7C,IAAI;aACL;YACD,IAAI;SACL,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { getError } from '@venizia/ignis-helpers/core';\nimport {\n UrlIngest,\n UrlSafetyDefaults,\n UrlSafetyErrors,\n type IBucketRef,\n type IObjectRef,\n type IFileStat,\n type IStorageHelper,\n type IUploadResult,\n type IUrlSafetyPolicy,\n} from '@venizia/ignis-helpers';\n\n/**\n * What was stored, and what the backend reports about it. The stat is returned because `getStat`\n * already ran to size the result - a caller writing its own row would otherwise pay for it twice.\n *\n * This does NOT write a meta link. The columns an application attaches to an object - a principal,\n * a variant - come from its own domain, not from the object, so the row stays the caller's.\n */\nexport interface IIngestFromUrlResult {\n upload: IUploadResult;\n stat: IFileStat;\n}\n\n/** Where a fetched object lands, and what it is attached to. */\nexport interface IIngestFromUrlOptions {\n helper: IStorageHelper;\n url: string;\n bucket: IBucketRef;\n\n /**\n * Decides the stored key.\n *\n * **Absent, the key comes from the remote url's last path segment - which on an untrusted url is\n * named by whoever supplied it.** Pass `resolveKey` whenever the url is not your own; the\n * validation below bounds what it can do, but it does not make the remote name yours.\n */\n resolveKey?: (opts: { url: URL; contentType: string }) => string;\n folderPath?: string;\n\n /** Absent leaves IGNIS's own default: https only, no private address, 3 hops, 10s, 10 MB. */\n policy?: IUrlSafetyPolicy;\n\n /**\n * Folder nesting the key may carry.\n *\n * @default BaseStorageHelper.DEFAULT_MAX_FOLDER_DEPTH\n */\n maxFolderDepth?: number;\n\n /**\n * Where the object is served from. **Required**: an absent hook used to yield an empty link, which\n * is exactly the value that satisfies a NOT NULL column and points nowhere.\n */\n normalizeLinkFn: (opts: { bucket: IBucketRef; object: IObjectRef }) => string;\n}\n\nconst readKeyFromUrl = (opts: { url: URL; folderPath?: string }): string => {\n const { url, folderPath } = opts;\n const lastSegment = url.pathname.split('/').filter(Boolean).pop() ?? 'object';\n const normalized = lastSegment.toLowerCase().replace(/ /g, '_');\n\n return folderPath ? `${folderPath}/${normalized}` : normalized;\n};\n\n/** Storing an object that came from somewhere else. */\nexport class AssetIngest {\n /**\n * Fetches an untrusted url and stores what comes back, without the bytes passing through this\n * process: the guarded body is capped and handed to `writeStream` as a stream.\n *\n * The url is guarded by `UrlIngest.fetchGuarded` - scheme allow-list, every resolved address\n * checked, redirects walked by hand with a per-hop re-check, and a timeout. The connection goes to the\n * address that was checked, so a DNS answer that changes afterwards is never used; see `UrlIngest.fetchGuarded`.\n *\n * The served content type is decided from the stored KEY, never from what the remote host\n * claimed - the same rule the asset routes apply, and for the same reason.\n */\n static async fromUrl(opts: IIngestFromUrlOptions): Promise<IIngestFromUrlResult> {\n const { helper, url, bucket, folderPath, policy, resolveKey, normalizeLinkFn } = opts;\n\n const response = await UrlIngest.fetchGuarded({ url, policy });\n const remoteType = response.headers.get('content-type')?.split(';')[0]?.trim() ?? '';\n const parsed = new URL(url);\n\n const key = resolveKey\n ? resolveKey({ url: parsed, contentType: remoteType })\n : readKeyFromUrl({ url: parsed, folderPath });\n\n // The helper's own default, not an unbounded one: an object arriving through ingest must obey\n // the same depth rule as one arriving through the upload route.\n if (!helper.isValidObjectKey({ object: { key }, maxDepth: opts.maxFolderDepth })) {\n await response.body?.cancel();\n throw getError({ message: `[AssetIngest.fromUrl] Invalid object key | key: ${key}` });\n }\n\n // Refused BEFORE the write starts, so a body that declares its size never opens a multipart\n // upload at all. A body that lies or omits the header is caught mid-flight by `capStream`, and\n // Bun's client answers that with `AbortMultipartUpload` - measured against a recording endpoint,\n // not assumed - so no orphaned parts are left behind either way.\n const declaredLength = Number(response.headers.get('content-length') ?? 0);\n const maxBytes = policy?.maxBytes ?? UrlSafetyDefaults.MAX_BYTES;\n\n if (declaredLength > maxBytes) {\n await response.body?.cancel();\n throw getError({\n error: UrlSafetyErrors.URL_REFUSED,\n message: `[AssetIngest.fromUrl] Body exceeds the cap | declared: ${declaredLength} | max: ${maxBytes}`,\n });\n }\n\n if (!response.body) {\n throw getError({ message: `[AssetIngest.fromUrl] Response carried no body | url: ${url}` });\n }\n\n const object: IObjectRef = { key };\n const contentType = helper.getMimeType({ filename: key });\n\n await helper.writeStream({\n bucket,\n object,\n source: UrlIngest.capStream({ source: response.body, policy }),\n contentType,\n maxFolderDepth: opts.maxFolderDepth,\n });\n\n const stat = await helper.getStat({ bucket, object });\n const link = normalizeLinkFn({ bucket, object });\n\n if (!link) {\n throw getError({\n message: `[AssetIngest.fromUrl] normalizeLinkFn returned an empty link | key: ${key}`,\n });\n }\n\n return {\n upload: {\n bucket: { name: bucket.name },\n object: { key, size: stat.size, contentType },\n link,\n },\n stat,\n };\n }\n}\n"]}
|
|
@@ -62,6 +62,9 @@ export interface IAssertApplicationBootsOptions {
|
|
|
62
62
|
* Datasources are bound and resolved but not configured, unless named in `keepDataSources`; the
|
|
63
63
|
* secrets steps are skipped; every other step and every component runs as in a real boot. A component
|
|
64
64
|
* that opens Redis, Kafka or S3 in `binding()` therefore runs for real: name it in `skipComponents`.
|
|
65
|
+
* `setupMiddlewares()` is not run: it is the application's own start-time step, user code that may open
|
|
66
|
+
* connections, and the probe cannot know it is free of side effects. The framework's default stack (CORS, body
|
|
67
|
+
* limit, request id) is a boot step of `initialize()`, so an invalid `configs.middlewares` value still fails here.
|
|
65
68
|
* When the boot fails inside a component, one warning names it; the rejection is still the original error. When the
|
|
66
69
|
* boot fails, the rejection is the original error. The application stays booted and is returned;
|
|
67
70
|
* a failed boot leaves a half-booted instance, so build a new one rather than reuse it.
|
|
@@ -69,6 +72,12 @@ export interface IAssertApplicationBootsOptions {
|
|
|
69
72
|
* It wraps `registerDynamicBindings` and `getBootSequence` on THIS instance only (an application's
|
|
70
73
|
* own override of either still runs) and restores them whatever happens.
|
|
71
74
|
*
|
|
75
|
+
* It owns the process-wide `AuthorizationEnforcerRegistry` for the duration of the check: it resets it before it
|
|
76
|
+
* boots, so a second boot in the same process (another probe, or a test boot after this one) does not fail with
|
|
77
|
+
* `Enforcer already registered`. An application still running in the same process loses its enforcer registrations
|
|
78
|
+
* and its authorize options, so its requests are then decided by the no-enforcer default (deny unless configured
|
|
79
|
+
* otherwise): do not run the probe in a process that serves an application.
|
|
80
|
+
*
|
|
72
81
|
* @example
|
|
73
82
|
* ```typescript
|
|
74
83
|
* import { ApplicationBootAssertion } from '@venizia/ignis/testing';
|