aws / aws-iot-device-sdk-js

SDK for connecting to AWS IoT from a device using JavaScript/Node.js
Apache License 2.0
964 stars 384 forks source link

Required when there is no file system ('fs') #399

Closed impactro closed 2 years ago

impactro commented 2 years ago

Issue #, if available: Required when there is no file system ('fs') and the certificate is embedded in the code

Description of changes: Certificates are already passed in the buffer, from a string

Exemple of use:

const client_privkey = -----BEGIN RSA PRIVATE KEY----- ....................... -----END RSA PRIVATE KEY-----;

const client = new device({ privateKey: Buffer.from(client_privkey), ...

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

bretambrose commented 2 years ago

My kneejerk reaction is that this is not a pattern we want to support or encourage. In a browser environment we strongly recommend mqtt-over-websockets using sigv4 authentication. AWS credentials can be sourced in a variety of ways using the regular AWS SDK for JS (v3) credentials providers, with Cognito being the preferred js-in-a-browser solution.

impactro commented 2 years ago

I didn't use it in a browser, but in a React Native application, and in my context I can't use file system (fs) I understand that the most recommended thing is to host the files, but in my context, I only have the code running in memory, without any physical access to any file, that's why I suggested this improvement, to be a native and simple directly in your library so that one day it doesn't depend on this local adjustment that I made.