From c4fc6c9b720c69af14cfd400e9f0d1588bc75d67 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sat, 9 Sep 2023 15:15:18 +0200 Subject: [PATCH] * (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 --- README.md | 8 +++++++- alexa-http2push.js | 8 +++++--- alexa-remote.js | 3 +++ example/example.js | 1 + 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 61b9ed2..b44bbc6 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/alexa-http2push.js b/alexa-http2push.js index ef85af5..842a935 100755 --- a/alexa-http2push.js +++ b/alexa-http2push.js @@ -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}`); diff --git a/alexa-remote.js b/alexa-remote.js index 895ccdd..f817467 100755 --- a/alexa-remote.js +++ b/alexa-remote.js @@ -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) { diff --git a/example/example.js b/example/example.js index 971a120..37c46f1 100644 --- a/example/example.js +++ b/example/example.js @@ -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