From 9f8845092972d97598706928041ac5a44d1c35d9 Mon Sep 17 00:00:00 2001 From: prakash Date: Sat, 20 Jun 2026 01:56:45 +0530 Subject: [PATCH] update comments , update type casing and update examples based on feedback --- examples/aws-nodejs/index.js | 4 ++-- examples/aws-nodejs/public/index.html | 2 -- packages/@uppy/aws-s3/src/s3-client/S3mini.ts | 2 +- packages/@uppy/aws-s3/src/s3-client/index.ts | 2 +- packages/@uppy/aws-s3/src/s3-client/signer.ts | 4 ++-- packages/@uppy/aws-s3/src/s3-client/types.ts | 8 ++++---- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/examples/aws-nodejs/index.js b/examples/aws-nodejs/index.js index b1dbb88f5..61da3c5ec 100644 --- a/examples/aws-nodejs/index.js +++ b/examples/aws-nodejs/index.js @@ -24,8 +24,8 @@ app.get('/', (req, res) => { if (err) return res.status(500).send('Error loading page') // Inject bucket/region config so the client can read them. const config = `` res.setHeader('Content-Type', 'text/html') res.send(html.replace('', `${config}`)) diff --git a/examples/aws-nodejs/public/index.html b/examples/aws-nodejs/public/index.html index 2ff0ec921..3b444471e 100644 --- a/examples/aws-nodejs/public/index.html +++ b/examples/aws-nodejs/public/index.html @@ -90,8 +90,6 @@ height: 400, }) .use(AwsS3, { - bucket: window.UPPY_S3_BUCKET, - region: window.UPPY_S3_REGION, signRequest: async (request) => { const response = await fetch('/s3/presign', { method: 'POST', diff --git a/packages/@uppy/aws-s3/src/s3-client/S3mini.ts b/packages/@uppy/aws-s3/src/s3-client/S3mini.ts index 060be670b..26cf3a61d 100644 --- a/packages/@uppy/aws-s3/src/s3-client/S3mini.ts +++ b/packages/@uppy/aws-s3/src/s3-client/S3mini.ts @@ -92,7 +92,7 @@ class S3mini extends S3Client { private _createCredentialBasedSigner(): IT.SignRequestFn { return async ( request: IT.PresignableRequest, - ): Promise => { + ): Promise => { const creds = await this._getCachedCredentials() if (this.endpoint == null) { throw new Error('Endpoint is required for credential-based signing') diff --git a/packages/@uppy/aws-s3/src/s3-client/index.ts b/packages/@uppy/aws-s3/src/s3-client/index.ts index cf6e14488..158faebb8 100644 --- a/packages/@uppy/aws-s3/src/s3-client/index.ts +++ b/packages/@uppy/aws-s3/src/s3-client/index.ts @@ -1,4 +1,4 @@ -// Export the S3 class as default export and named export +// Public exports for the S3 client. export { S3mini } from './S3mini.js' // Re-export types export type { diff --git a/packages/@uppy/aws-s3/src/s3-client/signer.ts b/packages/@uppy/aws-s3/src/s3-client/signer.ts index a5c3f58e9..b31582c62 100644 --- a/packages/@uppy/aws-s3/src/s3-client/signer.ts +++ b/packages/@uppy/aws-s3/src/s3-client/signer.ts @@ -5,7 +5,7 @@ */ import * as C from './consts.js' -import type { PresignableRequest, presignedResponse } from './types.js' +import type { PresignableRequest, PresignedResponse } from './types.js' import * as U from './utils.js' export interface SignerConfig { @@ -46,7 +46,7 @@ export function createSigV4Presigner(config: SignerConfig) { return async function presign( request: PresignableRequest, - ): Promise { + ): Promise { const { method, key, expiresIn = DEFAULT_EXPIRES_IN } = request // Build the URL - need to track encoded path separately because URL object decodes it diff --git a/packages/@uppy/aws-s3/src/s3-client/types.ts b/packages/@uppy/aws-s3/src/s3-client/types.ts index 889dc465a..349386ed7 100644 --- a/packages/@uppy/aws-s3/src/s3-client/types.ts +++ b/packages/@uppy/aws-s3/src/s3-client/types.ts @@ -41,14 +41,14 @@ export type PresignableRequest = | UploadPartRequest /** Response with the pre-signed URL */ -export type presignedResponse = { +export type PresignedResponse = { url: string } /** Function that generates a pre-signed URL for a request */ export type SignRequestFn = ( request: PresignableRequest, -) => Promise +) => Promise /** * Temporary security credentials from STS or similar service. @@ -92,11 +92,11 @@ type S3ConfigWithSignRequest = S3ConfigBase & { signRequest: SignRequestFn } -/** Config when using getCredentials callback (region required for signing) */ +/** Config for the getCredentials callback (region optional). */ type S3ConfigWithGetCredentials = Omit & { /** Function to retrieve temporary credentials for client-side signing. */ getCredentials: GetCredentialsFn - /** AWS region. Required for signing with getCredentials. */ + /** AWS region. Optional; falls back to the getCredentials response or 'auto'. */ region?: string /** Endpoint URL of the S3-compatible service (e.g., 'https://s3.amazonaws.com/bucket-name') */ endpoint: string