pdcarroll / react-kinesis-webrtc

An experimental library of React hooks for the AWS Kinesis WebRTC JavaScript SDK.
ISC License
13 stars 7 forks source link

Allow temporary credentials #17

Closed cyuste closed 2 years ago

cyuste commented 2 years ago

Allow using temporary credentials, for example when using amplify + cognito authentication.

Couldn't test because currently I'm getting a failure in the viewer example,

Property 'media' does not exist on type 'Peer | undefined'.

here

  const {
    error,
    peer: { media },
  } = useViewer(config);

If you could help me with that issue I can polish this PR :)

pdcarroll commented 2 years ago

@cyuste My mistake, the wiki example is missing a default value for peer. I've updated the example:

const {
  error,
  peer: { media } = {},
} = useViewer(config);
cyuste commented 2 years ago

@pdcarroll , thank you very much for your help.

I've been playing a little bit with your (great) component and it works just fine in my webpage with these changes. I'm using Amplify/Cognito auth and the credentials I get are temporary, so I need to use sessionToken.

As you can see, I introduced another change that you might find useful: In my current scenario, I'm creating a webrtc connection to one of the many cameras that a device has and the user can switch over other camera using a drop-down menu. When I tried to switch I received errors complaining that the signalingChannel was already opened so I had to slightly modify how the closure is done to allow this. If you are interested, take a look at it and let me know what you think. Maybe the code can be improved but the idea is there :)

pdcarroll commented 2 years ago

@cyuste I agree, switching media sources seems like a useful feature. I think that change may require a bit more testing. Would you mind moving your changes related to channel switching into a new PR? That way I can go ahead and merge your sessionToken changes so that it's not blocked by the other feature. Thanks so much for the contrubutions!

cyuste commented 2 years ago

@pdcarroll , reverted changes not related with the use of sessionToken. In the following weeks I will also test how well does it cope with connections issues, I'll keep you updated. Thank you again!