diff --git a/server/src/nest/storage/drivers/s3.driver.ts b/server/src/nest/storage/drivers/s3.driver.ts index c43aff1cd..caff9963a 100644 --- a/server/src/nest/storage/drivers/s3.driver.ts +++ b/server/src/nest/storage/drivers/s3.driver.ts @@ -1,3 +1,4 @@ +/// import awsLite from '@aws-lite/client'; import type { Readable } from 'node:stream'; import { assertValidKey, assertValidPrefix } from '../storage-keys'; @@ -65,10 +66,7 @@ export type S3DriverOptions = Omit & { /** Bare GetObject content-sniffs; streamResponsePayload is mandatory (spec, Client). */ export async function defaultClientFactory(opts: S3ClientOptions): Promise { - // AwsLiteClient's ambient .S3 augmentation (@aws-lite/s3-types) isn't picked - // up by tsc without an explicit reference, so this is the one sanctioned - // `as unknown as` boundary — no other cast in this file. - const client = (await awsLite({ + const client = await awsLite({ accessKeyId: opts.accessKeyId, secretAccessKey: opts.secretAccessKey, region: opts.region, @@ -76,8 +74,16 @@ export async function defaultClientFactory(opts: S3ClientOptions): Promise` above pulls in the + // declaration-merged `AwsLiteClient.S3` (https://aws-lite.org/using-typescript), + // so `client.S3` itself needs no cast. This one narrow cast remains because + // of a genuine structural mismatch: the real PutObject/Upload signatures + // require `Bucket`/`Key` (plus other required fields), which S3Api's + // deliberately permissive `Record` input can't guarantee — + // method-syntax parameter bivariance still rejects that narrowing. This is + // the one sanctioned `as unknown as` boundary; no other cast in this file. + return client.S3 as unknown as S3Api; } function statusCode(err: unknown): number | undefined {