What is @aws-sdk/signature-v4-crt?
@aws-sdk/signature-v4-crt is a package that provides AWS Signature Version 4 signing for requests made to AWS services. It is part of the AWS SDK for JavaScript and leverages the AWS Common Runtime (CRT) for enhanced performance and security.
What are @aws-sdk/signature-v4-crt's main functionalities?
Sign HTTP Requests
This feature allows you to sign HTTP requests to AWS services using AWS Signature Version 4. The code sample demonstrates how to sign a GET request to an S3 bucket using the SignatureV4Crt class.
const { SignatureV4Crt } = require('@aws-sdk/signature-v4-crt');
const { HttpRequest } = require('@aws-sdk/protocol-http');
const { defaultProvider } = require('@aws-sdk/credential-provider-node');
const signRequest = async () => {
const signer = new SignatureV4Crt({
service: 's3',
region: 'us-east-1',
credentials: defaultProvider(),
});
const request = new HttpRequest({
method: 'GET',
hostname: 'examplebucket.s3.amazonaws.com',
path: '/exampleobject',
});
const signedRequest = await signer.sign(request);
console.log(signedRequest);
};
signRequest();
Sign WebSocket Requests
This feature allows you to sign WebSocket requests to AWS services using AWS Signature Version 4. The code sample demonstrates how to sign a WebSocket request to an AWS IoT endpoint using the SignatureV4Crt class.
const { SignatureV4Crt } = require('@aws-sdk/signature-v4-crt');
const { WebSocketRequest } = require('@aws-sdk/protocol-websocket');
const { defaultProvider } = require('@aws-sdk/credential-provider-node');
const signWebSocketRequest = async () => {
const signer = new SignatureV4Crt({
service: 'iot',
region: 'us-east-1',
credentials: defaultProvider(),
});
const request = new WebSocketRequest({
hostname: 'example.iot.us-east-1.amazonaws.com',
path: '/mqtt',
});
const signedRequest = await signer.sign(request);
console.log(signedRequest);
};
signWebSocketRequest();
Other packages similar to @aws-sdk/signature-v4-crt
@aws-sdk/signature-v4
@aws-sdk/signature-v4 is another package from the AWS SDK for JavaScript that provides AWS Signature Version 4 signing. Unlike @aws-sdk/signature-v4-crt, it does not leverage the AWS Common Runtime (CRT) and may have different performance characteristics.
aws4
aws4 is a lightweight library for signing AWS requests with Signature Version 4. It is not part of the AWS SDK for JavaScript and is often used in environments where a smaller dependency footprint is desired.