Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aws-crt

Package Overview
Dependencies
Maintainers
4
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-crt

NodeJS/browser bindings to the aws-c-* libraries

  • 1.11.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
145K
decreased by-63.71%
Maintainers
4
Weekly downloads
 
Created

What is aws-crt?

The aws-crt npm package is a low-level client library for AWS services, providing a high-performance, cross-platform implementation of the AWS Common Runtime (CRT). It offers functionalities for networking, cryptography, and other foundational services that are essential for building AWS SDKs and other AWS-related applications.

What are aws-crt's main functionalities?

MQTT Client

This feature allows you to create an MQTT client to connect to AWS IoT Core. The code sample demonstrates how to set up the client, connect to the broker, subscribe to a topic, and handle incoming messages.

const { mqtt } = require('aws-crt');

const client = mqtt.Client({
  host: 'example.iot.region.amazonaws.com',
  port: 8883,
  clientId: 'myClientId',
  clean: true,
  keepAlive: 60,
  protocol: 'mqtts',
  key: 'path/to/private-key.pem',
  cert: 'path/to/certificate.pem',
  ca: 'path/to/ca.pem'
});

client.on('connect', () => {
  console.log('Connected to MQTT broker');
  client.subscribe('my/topic', { qos: 1 });
});

client.on('message', (topic, message) => {
  console.log(`Received message: ${message.toString()} on topic: ${topic}`);
});

client.connect();

HTTP Client

This feature provides an HTTP client for making HTTP requests. The code sample shows how to create an HTTP client, make a GET request, and handle the response.

const { http } = require('aws-crt');

const client = new http.HttpClient();

const request = new http.HttpRequest('https://example.com', 'GET');

client.request(request, (response) => {
  console.log(`Status Code: ${response.statusCode}`);
  response.on('data', (chunk) => {
    console.log(`Body: ${chunk.toString()}`);
  });
});

WebSocket Client

This feature allows you to create a WebSocket client for real-time communication. The code sample demonstrates how to set up the client, connect to a WebSocket server, send messages, and handle incoming messages.

const { websocket } = require('aws-crt');

const client = new websocket.WebSocketClient('wss://example.com/socket');

client.on('open', () => {
  console.log('WebSocket connection opened');
  client.send('Hello, WebSocket!');
});

client.on('message', (message) => {
  console.log(`Received message: ${message}`);
});

client.on('close', () => {
  console.log('WebSocket connection closed');
});

client.connect();

Other packages similar to aws-crt

FAQs

Package last updated on 11 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc