Skip to content

Commit

Permalink
* (Apollon77) Introduce optional parameter "pushDispatchHost" to spec…
Browse files Browse the repository at this point in the history
…ify the host for the push connection

* (Apollon77) Make sure cookie refresh timeout is valid and prevent overflow
* (Apollon77) Fix support for push connections JP/AU regions
  • Loading branch information
Apollon77 committed Sep 9, 2023
1 parent c29aec3 commit c4fc6c9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ Then it should work again
* docu docu docu (sorry ... will come)

## Changelog:

### __WORK IN PROGRESS__
* (Apollon77) Introduce optional parameter "pushDispatchHost" to specify the host for the push connection
* (Apollon77) Make sure cookie refresh timeout is valid and prevent overflow
* (Apollon77) Fix support for push connections JP/AU regions

### 6.0.2 (2023-09-09)
* (Apollon77) Added experimental support for BR region
* (Apollon77) Added experimental support push connections in BR region

### 6.0.1 (2023-09-08)
* (Apollon77) Optimize reconnection timing
Expand Down
8 changes: 5 additions & 3 deletions alexa-http2push.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ class AlexaHttp2Push extends EventEmitter {
this.access_token = token;

let host = 'bob-dispatch-prod-eu.amazon.com';
if (this._options.amazonPage === 'amazon.com') {
if (this._options.pushDispatchHost) {
host = this._options.pushDispatchHost;
} else if (this._options.amazonPage === 'amazon.com') {
host = 'bob-dispatch-prod-na.amazon.com';
} else if (this._options.amazonPage === 'amazon.com.br') {
host = 'bob-dispatch-prod-na.amazon.com';
} else if (this._options.amazonPage === 'amazon.co.jp') {
host = 'bob-dispatch-prod-fe.amazon.co.jp';
host = 'bob-dispatch-prod-fe.amazon.com';
} else if (this._options.amazonPage === 'amazon.com.au') {
host = 'bob-dispatch-prod-fe.amazon.com.au';
host = 'bob-dispatch-prod-fe.amazon.com';
}
this._options.logger && this._options.logger(`Alexa-Remote HTTP2-PUSH: Use host ${host}`);

Expand Down
3 changes: 3 additions & 0 deletions alexa-remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class AlexaRemote extends EventEmitter {
if (this._options.cookieRefreshInterval !== 0) {
this._options.cookieRefreshInterval = this._options.cookieRefreshInterval || 4 * 24 * 60 * 60 * 1000; // Auto Refresh after 4 days
}
if (this._options.cookieRefreshInterval <= 0 || this._options.cookieRefreshInterval > 2147483646) {
this._options.cookieRefreshInterval = 4 * 24 * 60 * 60 * 1000; // Auto Refresh after 4 days
}

const self = this;
function getCookie(callback) {
Expand Down
1 change: 1 addition & 0 deletions example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ alexa.init({
// acceptLanguage: '...', // optional, override Accept-Language-Header for cookie determination
// amazonPage: '...', // optional, override Amazon-Login-Page for cookie determination and referer for requests
useWsMqtt: true, // optional, true to use the Websocket/MQTT direct push connection
// pushDispatchHost: '...', // optional, override push endpoint host
cookieRefreshInterval: 7*24*60*1000, // optional, cookie refresh intervall, set to 0 to disable refresh
deviceAppName: '...', // optional: name of the device app name which will be registered with Amazon, leave empty to use a default one
apiUserAgentPostFix: '...', // optional: postfix to add to api useragent, leave empty to use a default one
Expand Down

0 comments on commit c4fc6c9

Please sign in to comment.