awslabs / aws-crt-nodejs

NodeJS bindings for the AWS Common Runtime.
Apache License 2.0
40 stars 27 forks source link

Property 'newStatic' does not exist on type 'typeof AwsCredentialsProvider'. #352

Closed karllundgren closed 1 year ago

karllundgren commented 2 years ago

I am using aws-iot-device-sdk-js-v2, following the example: https://github.com/coderbyheart/aws-iot-device-sdk-js-browser-esm/blob/cdefd5912f5e3c78fd0fe99cec7b512a4215b287/index.js to create an MQTT client that connects to AWS IoT Hub.

Per the documentation I've found: https://aws.github.io/aws-iot-device-sdk-js-v2/node/classes/http.AwsCredentialsProvider.html AwsCredentialsProvider has 2 methods, newDefault(), and newStatic(). However, only newDefault() is defined, newStatic() doesn't exist.

I have aws-crt installed at version 1.14.1, and my code is using the implementation of AwsCredentialsProvider as defined at node_modules\aws-crt\dist\native\auth.d.ts

bretambrose commented 2 years ago

Node and browser have close but not quite identical capabilities, leading to slight differences in API contract, based on what we can get out of the browser-only dependencies. You've linked a browser sample but the node API docs. Try working from https://aws.github.io/aws-iot-device-sdk-js-v2/browser/modules/auth.html for relevant browser docs, or don't use a browser-based sample as your basis.

bretambrose commented 2 years ago

Revisiting this for unrelated reasons, it looks like we don't export newStatic from its internal native implementation. It should be fixed as part of other work shortly.

bretambrose commented 1 year ago

Assuming a node environment, I believe this was addressed by https://github.com/awslabs/aws-crt-nodejs/pull/356