aws-observability / aws-rum-web

Amazon CloudWatch RUM Web Client
Apache License 2.0
114 stars 65 forks source link

fix: Save deserialized credential object to Authentication member #436

Closed adebayor123 closed 10 months ago

adebayor123 commented 10 months ago

Details

Currently in our Authentication and EnhancedAuthentication, we save credential object as serialized string values. Then, as we read the serialized string from Storage, we parse the string into a Credential object.

However, in AnonymousStorageCredentialsProvider, we overwrite the local member variable credential with the serialized string instead of the parsed object. As a result, any situation that requires reading of the credential from storage leads to: TypeError: this.credentials.expiration.getTime is not a function.

This PR removes the unnecessary step to overwrite the local member this.credential with the serialized string.


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

qhanam commented 10 months ago

I've pushed a patch for EnhancedAuthentication.ts:

  1. Add type to credentials local variable
  2. Add return statement when rejecting
  3. Fix expiration (to be date object) in resolved value
  4. Added unit tests