Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support alternative method of passing Presigned params #178

Merged
merged 11 commits into from
Feb 29, 2024

Conversation

joehoyle
Copy link
Member

@joehoyle joehoyle commented Feb 28, 2024

Allow passing ?presign={signature params} to work around lambda not allowing the pre-soign params directly.

If there is a presign param, we need to decode it and add it to the args. This is to provide a secondary way to pass pre-sign params, as using them in a Lambda function URL invocation will trigger a Lambda error.
@joehoyle joehoyle requested review from rmccue and kovshenin February 28, 2024 12:32
Copy link
Member

@rmccue rmccue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor things, but the debug/test stuff should be removed before merge.

.github/workflows/test.yml Outdated Show resolved Hide resolved
{
region: process.env.S3_REGION,
bucket: process.env.S3_BUCKET,
} as S3ClientConfig
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this required? Is there a type error here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this was copied from the lib.ts. It seems the ts types don't account for this style of passing these times for some reason. Mostly just copied it though

/**
* Middleware to remove the x-id query string param form the GetObject call.
*/
const middleware: MiddlewareType<any, any> = ( next: any, context: any ) => async ( args: any ) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these be more specifically typed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They could but it's a test so I'm not that worried

tests/test-private-upload.ts Outdated Show resolved Hide resolved
Comment on lines 46 to 51
let queryStringParameters: Args = {};
presignedUrl.searchParams.forEach( ( value, key ) => {
queryStringParameters[ key as keyof Args ] = value;
} );

return queryStringParameters;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe: Object.fromEntries( presignedUrl.searchParams ) ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that's the function I was looking for I think!

tests/test-lambda.ts Outdated Show resolved Hide resolved
@joehoyle joehoyle requested a review from rmccue February 29, 2024 09:17
@joehoyle joehoyle self-assigned this Feb 29, 2024
@joehoyle joehoyle merged commit f304c48 into master Feb 29, 2024
2 checks passed
@joehoyle joehoyle deleted the presigned-params branch February 29, 2024 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants