compulim / web-speech-cognitive-services

Polyfill Web Speech API with Cognitive Services Bing Speech for both speech-to-text and text-to-speech service.
https://compulim.github.io/web-speech-cognitive-services
MIT License
63 stars 18 forks source link

Unify credentials options #80

Closed compulim closed 4 years ago

compulim commented 4 years ago

Description

Before this change, we only support asynchronously setting authorization token, but not for Azure region. Thus, if you have multiple subscription keys used in different Azure regions, it is not trivial to renew the authentication token while moving to another Azure region.

In this PR, we unified all credentials options into a single option namely credentials. It inherits previous signature which support Promise-based function or simple objects.

You can use the new credentials object to set the Azure region, and your choice of either authorization token or subscription key.

Changelog

Breaking changes

Unifying options to pass credentials

authorizationToken, region, and subscriptionKey are being deprecated in favor of credentials options. credentials can be one of the following types:

If credentials is a function, it will be called just before the credentials is needed and may be called very frequently. This behavior matches the deprecating authorizationToken. The result of the call is also expected to be cached.

If region is not returned, the default value of "westus" will be used.

Removed

Added