-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Signer removed in v6 #13340
Comments
Hello, @abarke and thank you for creating this issue. While the decision to remove support for the Beyond what you've already detailed in the description of this issue, can you share any further context/use cases for this? Thanks! |
We use an open API generated TS library for our endpoints. To sign the requests we use an interceptor in the generated code so that it works as expected. We sign the requests manually. I switch to using // Custom middleware that signs the request with the current credentials
const awsSigningMiddleware: Middleware = {
pre: async (context) => {
const { headers } = await signRequest(
context.init.method ?? "GET",
context.url,
parseBody(context.init.body),
);
// Update the fetch request headers with the signed headers
context.init.headers = {
...headers,
};
return context;
},
};
// Custom middleware for error handling
const errorHandlingMiddleware: Middleware = {
onError: async (context) => {
const h3Error = apiErrorHandler(context.error);
console.error(h3Error);
return context.response;
},
};
// Configure the API client with the custom middleware
const apiConfig = new Configuration({
middleware: [awsSigningMiddleware, errorHandlingMiddleware],
});
// Create the API client with the custom configuration
export const api = new DefaultApi(apiConfig); |
Here is the current workaround using async function signRequest(method: string, uri: string, body?: string) {
const { credentials } = await fetchAuthSession();
if (credentials === undefined) {
throw new Error("Unauthorized");
}
const url = new URL(uri);
const request = new HttpRequest({
hostname: url.hostname,
path: url.pathname + url.search,
method,
body,
headers: {
host: url.hostname, // host is required by AWS Signature V4
"Content-Type": "application/json",
},
});
const signer = new SignatureV4({
credentials,
region,
service,
sha256: Sha256,
});
return signer.sign(request);
} |
@abarke, thanks for the code example showing the workaround. Using the |
https://stackoverflow.com/q/78465559/20597701, Amplify V6 Rest api doesnt seem to sign the request |
Not sure when this changed, but for future Googlers we're importing it directly from |
Hi @AtharvArolkar sorry about the delayed response. We had any issue that IAM and |
unfortunately, @smithy/signature-v4 isn't compatible with react native, any suggestions on what to use with Expo? |
Before opening, please confirm:
JavaScript Framework
Vue
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
auth
Backend
None
Environment information
Describe the bug
Signer
export has been removed. I found it somewhere in the core, but could not find a way to import it. I tried "aws-amplify/utils" with no avail.I could find in node
import { Signer } from "@aws-amplify/core/dist/esm/Signer"
but again no clean import.Could we have something like this please?
No mention about this breaking change in https://docs.amplify.aws/gen1/javascript/build-a-backend/auth/auth-migration-guide/
Expected behavior
Reproduction steps
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: