iobroker.parcel 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/io-package.json +9 -2
- package/main.js +123 -72
- package/package.json +3 -3
package/io-package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "parcel",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.2",
|
|
5
5
|
"news": {
|
|
6
|
-
"0.2.
|
|
6
|
+
"0.2.2": {
|
|
7
|
+
"en": "Improvment for Amazon Login and fix for Briefaanündigung Image",
|
|
8
|
+
"de": "Verbesserung für Amazon Login und Fix für Briefankündigung Image State"
|
|
9
|
+
},
|
|
10
|
+
"0.2.1": {
|
|
7
11
|
"en": "Fix for Briefankündigung",
|
|
8
12
|
"de": "Briefankündigung wieder aktiviert"
|
|
9
13
|
},
|
|
@@ -166,6 +170,9 @@
|
|
|
166
170
|
"native": {
|
|
167
171
|
"amzusername": "",
|
|
168
172
|
"amzpassword": "",
|
|
173
|
+
"aliUsername": "",
|
|
174
|
+
"aliPassword": "",
|
|
175
|
+
"aliMfa": "",
|
|
169
176
|
"glsusername": "",
|
|
170
177
|
"glspassword": "",
|
|
171
178
|
"upsusername": "",
|
package/main.js
CHANGED
|
@@ -18,7 +18,7 @@ Module.prototype.require = function () {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const utils = require('@iobroker/adapter-core');
|
|
21
|
-
const axios = require('axios');
|
|
21
|
+
const axios = require('axios').default;
|
|
22
22
|
const qs = require('qs');
|
|
23
23
|
const crypto = require('crypto');
|
|
24
24
|
const Json2iob = require('json2iob');
|
|
@@ -64,6 +64,7 @@ class Parcel extends utils.Adapter {
|
|
|
64
64
|
DELIVERED: 1,
|
|
65
65
|
};
|
|
66
66
|
this.tmpDir = tmpdir();
|
|
67
|
+
this.requestClient = axios.create();
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
/**
|
|
@@ -181,7 +182,8 @@ class Parcel extends utils.Adapter {
|
|
|
181
182
|
url: 'https://login.dhl.de/af5f9bb6-27ad-4af4-9445-008e7a5cddb8/login/authorize',
|
|
182
183
|
params: {
|
|
183
184
|
redirect_uri: 'dhllogin://de.deutschepost.dhl/login',
|
|
184
|
-
state:
|
|
185
|
+
state:
|
|
186
|
+
'eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9',
|
|
185
187
|
client_id: '83471082-5c13-4fce-8dcb-19d2a3fca413',
|
|
186
188
|
response_type: 'code',
|
|
187
189
|
scope: 'openid offline_access',
|
|
@@ -301,7 +303,8 @@ class Parcel extends utils.Adapter {
|
|
|
301
303
|
redirect_uri: 'dhllogin://de.deutschepost.dhl/login',
|
|
302
304
|
response_type: 'code',
|
|
303
305
|
scope: 'openid',
|
|
304
|
-
state:
|
|
306
|
+
state:
|
|
307
|
+
'eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9',
|
|
305
308
|
ui_locales: 'de-DE",',
|
|
306
309
|
},
|
|
307
310
|
headers: {
|
|
@@ -349,7 +352,8 @@ class Parcel extends utils.Adapter {
|
|
|
349
352
|
redirect_uri: 'dhllogin://de.deutschepost.dhl/login',
|
|
350
353
|
response_type: 'code',
|
|
351
354
|
scope: 'openid',
|
|
352
|
-
state:
|
|
355
|
+
state:
|
|
356
|
+
'eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9',
|
|
353
357
|
ui_locales: 'de-DE',
|
|
354
358
|
},
|
|
355
359
|
headers: {
|
|
@@ -400,6 +404,10 @@ class Parcel extends utils.Adapter {
|
|
|
400
404
|
this.log.error(JSON.stringify(error.response.data));
|
|
401
405
|
}
|
|
402
406
|
});
|
|
407
|
+
if (!codeUrl) {
|
|
408
|
+
this.log.error('DHL codeUrl failed');
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
403
411
|
await this.requestClient({
|
|
404
412
|
method: 'post',
|
|
405
413
|
url: 'https://login.dhl.de/af5f9bb6-27ad-4af4-9445-008e7a5cddb8/login/token',
|
|
@@ -448,8 +456,6 @@ class Parcel extends utils.Adapter {
|
|
|
448
456
|
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_8 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148',
|
|
449
457
|
'accept-language': 'de-de',
|
|
450
458
|
},
|
|
451
|
-
jar: this.cookieJar,
|
|
452
|
-
withCredentials: true,
|
|
453
459
|
})
|
|
454
460
|
.then(async (res) => {
|
|
455
461
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -479,8 +485,6 @@ class Parcel extends utils.Adapter {
|
|
|
479
485
|
force: false,
|
|
480
486
|
meta: '',
|
|
481
487
|
}),
|
|
482
|
-
jar: this.cookieJar,
|
|
483
|
-
withCredentials: true,
|
|
484
488
|
})
|
|
485
489
|
.then(async (res) => {
|
|
486
490
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -607,7 +611,8 @@ class Parcel extends utils.Adapter {
|
|
|
607
611
|
'sec-ch-ua-mobile': '?0',
|
|
608
612
|
'sec-ch-ua-platform': '"macOS"',
|
|
609
613
|
'upgrade-insecure-requests': '1',
|
|
610
|
-
'user-agent':
|
|
614
|
+
'user-agent':
|
|
615
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.20 Safari/537.36',
|
|
611
616
|
accept:
|
|
612
617
|
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
|
|
613
618
|
'sec-fetch-site': 'same-site',
|
|
@@ -616,8 +621,6 @@ class Parcel extends utils.Adapter {
|
|
|
616
621
|
referer: 'https://login.aliexpress.com/',
|
|
617
622
|
'accept-language': 'de',
|
|
618
623
|
},
|
|
619
|
-
jar: this.cookieJar,
|
|
620
|
-
withCredentials: true,
|
|
621
624
|
})
|
|
622
625
|
.then(async (res) => {
|
|
623
626
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -653,7 +656,8 @@ class Parcel extends utils.Adapter {
|
|
|
653
656
|
accept: 'application/json, text/plain, */*',
|
|
654
657
|
'content-type': 'application/x-www-form-urlencoded',
|
|
655
658
|
'sec-ch-ua-mobile': '?0',
|
|
656
|
-
'user-agent':
|
|
659
|
+
'user-agent':
|
|
660
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.20 Safari/537.36',
|
|
657
661
|
'sec-ch-ua-platform': '"macOS"',
|
|
658
662
|
origin: 'https://login.aliexpress.com',
|
|
659
663
|
'sec-fetch-site': 'same-site',
|
|
@@ -683,7 +687,9 @@ class Parcel extends utils.Adapter {
|
|
|
683
687
|
})
|
|
684
688
|
.then(async (res) => {
|
|
685
689
|
// this.log.debug(JSON.stringify(res.data));
|
|
686
|
-
res.data.indexOf('Session has expired') !== -1
|
|
690
|
+
res.data.indexOf('Session has expired') !== -1
|
|
691
|
+
? this.log.error('Session has expired')
|
|
692
|
+
: this.log.info('Login to Aliexpress successful');
|
|
687
693
|
})
|
|
688
694
|
.catch(async (error) => {
|
|
689
695
|
error.response && this.log.error(JSON.stringify(error.response.data));
|
|
@@ -692,6 +698,7 @@ class Parcel extends utils.Adapter {
|
|
|
692
698
|
} else {
|
|
693
699
|
this.log.info('Login to AliExpress with MFA token');
|
|
694
700
|
this.log.debug('MFA: ' + this.config.dhlMfa);
|
|
701
|
+
const mfaToken = '';
|
|
695
702
|
await this.requestClient({
|
|
696
703
|
method: 'post',
|
|
697
704
|
url: 'https://www.dhl.de/int-erkennen/2fa',
|
|
@@ -768,8 +775,6 @@ class Parcel extends utils.Adapter {
|
|
|
768
775
|
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_8 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148',
|
|
769
776
|
'accept-language': 'de-de',
|
|
770
777
|
},
|
|
771
|
-
jar: this.cookieJar,
|
|
772
|
-
withCredentials: true,
|
|
773
778
|
})
|
|
774
779
|
.then(async (res) => {
|
|
775
780
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -778,7 +783,7 @@ class Parcel extends utils.Adapter {
|
|
|
778
783
|
.catch((error) => {
|
|
779
784
|
this.log.error('Amazon first login step failed');
|
|
780
785
|
this.log.error(
|
|
781
|
-
'https://www.amazon.de/ap/signin?_encoding=UTF8&accountStatusPolicy=P1&openid.assoc_handle=deflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.de%2Fgp%2Fcss%2Forder-history%3Fie%3DUTF8%26ref_%3Dnav_orders_first&pageId=webcs-yourorder&showRmrMe=1'
|
|
786
|
+
'https://www.amazon.de/ap/signin?_encoding=UTF8&accountStatusPolicy=P1&openid.assoc_handle=deflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.de%2Fgp%2Fcss%2Forder-history%3Fie%3DUTF8%26ref_%3Dnav_orders_first&pageId=webcs-yourorder&showRmrMe=1',
|
|
782
787
|
);
|
|
783
788
|
this.log.error(error);
|
|
784
789
|
if (error.response) {
|
|
@@ -800,8 +805,6 @@ class Parcel extends utils.Adapter {
|
|
|
800
805
|
referer: 'https://www.amazon.de/ap/signin',
|
|
801
806
|
},
|
|
802
807
|
data: qs.stringify(form),
|
|
803
|
-
jar: this.cookieJar,
|
|
804
|
-
withCredentials: true,
|
|
805
808
|
})
|
|
806
809
|
.then(async (res) => {
|
|
807
810
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -814,7 +817,7 @@ class Parcel extends utils.Adapter {
|
|
|
814
817
|
this.log.error(JSON.stringify(error.response.data));
|
|
815
818
|
}
|
|
816
819
|
this.log.info(
|
|
817
|
-
'Delete amazon cookie please restart the adapter to trigger relogin. If this is not working please manualy delete parcel.0.auth.cookie'
|
|
820
|
+
'Delete amazon cookie please restart the adapter to trigger relogin. If this is not working please manualy delete parcel.0.auth.cookie',
|
|
818
821
|
);
|
|
819
822
|
delete this.cookieJar.store.idx['amazon.de'];
|
|
820
823
|
});
|
|
@@ -834,13 +837,11 @@ class Parcel extends utils.Adapter {
|
|
|
834
837
|
referer: 'https://www.amazon.de/ap/signin',
|
|
835
838
|
},
|
|
836
839
|
data: qs.stringify(form),
|
|
837
|
-
jar: this.cookieJar,
|
|
838
|
-
withCredentials: true,
|
|
839
840
|
})
|
|
840
841
|
.then(async (res) => {
|
|
841
842
|
this.log.debug(JSON.stringify(res.data));
|
|
842
843
|
if (res.data.indexOf('js-yo-main-content') !== -1) {
|
|
843
|
-
this.log.info('
|
|
844
|
+
this.log.info('Relogin to Amazon successful');
|
|
844
845
|
this.sessions['amz'] = true;
|
|
845
846
|
this.setState('info.connection', true, true);
|
|
846
847
|
this.setState('auth.cookie', JSON.stringify(this.cookieJar.toJSON()), true);
|
|
@@ -865,8 +866,6 @@ class Parcel extends utils.Adapter {
|
|
|
865
866
|
referer: 'https://www.amazon.de/ap/signin',
|
|
866
867
|
},
|
|
867
868
|
data: qs.stringify(form),
|
|
868
|
-
jar: this.cookieJar,
|
|
869
|
-
withCredentials: true,
|
|
870
869
|
})
|
|
871
870
|
.then(async (res) => {
|
|
872
871
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -902,11 +901,11 @@ class Parcel extends utils.Adapter {
|
|
|
902
901
|
this.log.error('Login to Amazon failed, please login to Amazon manually and check the login');
|
|
903
902
|
if (res.data.indexOf('captcha-placeholder') !== -1) {
|
|
904
903
|
this.log.warn(
|
|
905
|
-
'Captcha required. Please login into your account to check the state of the account. If this is not wokring please pause the adapter for 24h.'
|
|
904
|
+
'Captcha required. Please login into your account to check the state of the account. If this is not wokring please pause the adapter for 24h.',
|
|
906
905
|
);
|
|
907
906
|
}
|
|
908
907
|
this.log.info(
|
|
909
|
-
'Amazon cookie are removed. Please restart the adapter to trigger a relogin. If this is not working please manually delete parcel.0.auth.cookie'
|
|
908
|
+
'Amazon cookie are removed. Please restart the adapter to trigger a relogin. If this is not working please manually delete parcel.0.auth.cookie',
|
|
910
909
|
);
|
|
911
910
|
delete this.cookieJar.store.idx['amazon.de'];
|
|
912
911
|
this.log.info('Start relogin');
|
|
@@ -936,8 +935,6 @@ class Parcel extends utils.Adapter {
|
|
|
936
935
|
await this.requestClient({
|
|
937
936
|
method: 'get',
|
|
938
937
|
url: 'https://my.dpd.de/logout.aspx',
|
|
939
|
-
jar: this.cookieJar,
|
|
940
|
-
withCredentials: true,
|
|
941
938
|
}).catch(async (error) => {
|
|
942
939
|
error.response && this.log.error(JSON.stringify(error.response.data));
|
|
943
940
|
this.log.error(error);
|
|
@@ -947,7 +944,8 @@ class Parcel extends utils.Adapter {
|
|
|
947
944
|
url: 'https://www.dpd.com/de/de/mydpd-anmelden-und-registrieren/',
|
|
948
945
|
headers: {
|
|
949
946
|
'content-type': 'application/x-www-form-urlencoded',
|
|
950
|
-
'user-agent':
|
|
947
|
+
'user-agent':
|
|
948
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.66 Safari/537.36',
|
|
951
949
|
accept:
|
|
952
950
|
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
|
|
953
951
|
'accept-language': 'de,en;q=0.9',
|
|
@@ -956,8 +954,6 @@ class Parcel extends utils.Adapter {
|
|
|
956
954
|
dpg_username: this.config.dpdusername,
|
|
957
955
|
dpg_password: this.config.dpdpassword,
|
|
958
956
|
}),
|
|
959
|
-
jar: this.cookieJar,
|
|
960
|
-
withCredentials: true,
|
|
961
957
|
maxRedirects: 0,
|
|
962
958
|
})
|
|
963
959
|
.then(async (res) => {
|
|
@@ -1002,8 +998,6 @@ class Parcel extends utils.Adapter {
|
|
|
1002
998
|
await this.requestClient({
|
|
1003
999
|
method: 'get',
|
|
1004
1000
|
url: 'https://my.dpd.de/myParcel.aspx?dpd_token=' + this.dpdToken,
|
|
1005
|
-
jar: this.cookieJar,
|
|
1006
|
-
withCredentials: true,
|
|
1007
1001
|
}).catch(async (error) => {
|
|
1008
1002
|
error.response && this.log.error(JSON.stringify(error.response.data));
|
|
1009
1003
|
this.log.error(error);
|
|
@@ -1029,8 +1023,6 @@ class Parcel extends utils.Adapter {
|
|
|
1029
1023
|
username: this.config.glsusername,
|
|
1030
1024
|
password: this.config.glspassword,
|
|
1031
1025
|
}),
|
|
1032
|
-
jar: this.cookieJar,
|
|
1033
|
-
withCredentials: true,
|
|
1034
1026
|
})
|
|
1035
1027
|
.then(async (res) => {
|
|
1036
1028
|
this.sessions['gls'] = res.data;
|
|
@@ -1058,8 +1050,6 @@ class Parcel extends utils.Adapter {
|
|
|
1058
1050
|
'X-Client-Id': 'iOS',
|
|
1059
1051
|
'X-Auth-Token': this.glstoken,
|
|
1060
1052
|
},
|
|
1061
|
-
jar: this.cookieJar,
|
|
1062
|
-
withCredentials: true,
|
|
1063
1053
|
})
|
|
1064
1054
|
.then(async (res) => {
|
|
1065
1055
|
!silent && this.log.info('Login to GLS successful');
|
|
@@ -1102,9 +1092,6 @@ class Parcel extends utils.Adapter {
|
|
|
1102
1092
|
'accept-language': 'de-de',
|
|
1103
1093
|
},
|
|
1104
1094
|
data: { username: this.config.hermesusername, password: this.config.hermespassword },
|
|
1105
|
-
|
|
1106
|
-
jar: this.cookieJar,
|
|
1107
|
-
withCredentials: true,
|
|
1108
1095
|
})
|
|
1109
1096
|
.then(async (res) => {
|
|
1110
1097
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -1170,8 +1157,6 @@ class Parcel extends utils.Adapter {
|
|
|
1170
1157
|
IsMobile: 'true',
|
|
1171
1158
|
},
|
|
1172
1159
|
}),
|
|
1173
|
-
jar: this.cookieJar,
|
|
1174
|
-
withCredentials: true,
|
|
1175
1160
|
})
|
|
1176
1161
|
.then(async (res) => {
|
|
1177
1162
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -1251,8 +1236,6 @@ class Parcel extends utils.Adapter {
|
|
|
1251
1236
|
},
|
|
1252
1237
|
},
|
|
1253
1238
|
}),
|
|
1254
|
-
jar: this.cookieJar,
|
|
1255
|
-
withCredentials: true,
|
|
1256
1239
|
})
|
|
1257
1240
|
.then(async (res) => {
|
|
1258
1241
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -1349,8 +1332,6 @@ class Parcel extends utils.Adapter {
|
|
|
1349
1332
|
'","Password":"' +
|
|
1350
1333
|
this.config.t17password +
|
|
1351
1334
|
'","CaptchaCode":""},"sourcetype":0,"timeZoneOffset":-60}',
|
|
1352
|
-
jar: this.cookieJar,
|
|
1353
|
-
withCredentials: true,
|
|
1354
1335
|
})
|
|
1355
1336
|
.then(async (res) => {
|
|
1356
1337
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -1686,18 +1667,18 @@ class Parcel extends utils.Adapter {
|
|
|
1686
1667
|
}
|
|
1687
1668
|
async cleanupProvider(id, data) {
|
|
1688
1669
|
if (id === 'dhl' && data.hasOwnProperty('grantToken')) {
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1670
|
+
await this.delObjectAsync('dhl.briefe', { recursive: true });
|
|
1671
|
+
await this.setObjectNotExistsAsync('dhl.briefe.json', {
|
|
1672
|
+
type: 'state',
|
|
1673
|
+
common: {
|
|
1674
|
+
name: 'Json Briefe',
|
|
1675
|
+
write: false,
|
|
1676
|
+
read: true,
|
|
1677
|
+
type: 'string',
|
|
1678
|
+
role: 'json',
|
|
1679
|
+
},
|
|
1680
|
+
native: {},
|
|
1681
|
+
});
|
|
1701
1682
|
}
|
|
1702
1683
|
if ((id === 'dhl' || id === 'dpd' || id === 'amz' || id === 'gls' || id === 'ups' || id === 'hermes') && data && data.sendungen) {
|
|
1703
1684
|
const states = await this.getStatesAsync(id + '.sendungen*.id');
|
|
@@ -1730,6 +1711,9 @@ class Parcel extends utils.Adapter {
|
|
|
1730
1711
|
if (sendung.sendungsdetails && sendung.sendungsdetails.liveTrackingVerfuegbar && sendung.sendungsdetails.liveTracking) {
|
|
1731
1712
|
status = status + ' ' + sendung.sendungsdetails.liveTracking.countdown + ' Stopps';
|
|
1732
1713
|
}
|
|
1714
|
+
if (status === '') {
|
|
1715
|
+
return;
|
|
1716
|
+
}
|
|
1733
1717
|
const name = sendung.sendungsinfo.sendungsname || 'Unbekannt';
|
|
1734
1718
|
|
|
1735
1719
|
const sendungsObject = { id: sendung.id, name: name, status: status, source: 'DHL' };
|
|
@@ -2127,6 +2111,7 @@ class Parcel extends utils.Adapter {
|
|
|
2127
2111
|
this.log.debug('Get Amazon Packages');
|
|
2128
2112
|
const amzResult = { sendungen: [] };
|
|
2129
2113
|
|
|
2114
|
+
await this.loginAmz();
|
|
2130
2115
|
let orders = await this.getAmazonOrders();
|
|
2131
2116
|
if (!orders) {
|
|
2132
2117
|
orders = await this.getAmazonOrders();
|
|
@@ -2144,13 +2129,38 @@ class Parcel extends utils.Adapter {
|
|
|
2144
2129
|
order.url = 'https://www.amazon.de' + order.url;
|
|
2145
2130
|
}
|
|
2146
2131
|
this.log.debug(order.url);
|
|
2147
|
-
order.url = order.url + '
|
|
2132
|
+
order.url = order.url + '';
|
|
2148
2133
|
const element = await this.requestClient({
|
|
2149
2134
|
method: 'get',
|
|
2150
2135
|
url: order.url,
|
|
2151
2136
|
headers: {
|
|
2152
|
-
|
|
2153
|
-
|
|
2137
|
+
authority: 'www.amazon.de',
|
|
2138
|
+
accept:
|
|
2139
|
+
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
|
2140
|
+
'accept-language': 'de,en;q=0.9,es;q=0.8,hi;q=0.7,kn;q=0.6',
|
|
2141
|
+
'cache-control': 'no-cache',
|
|
2142
|
+
'device-memory': '8',
|
|
2143
|
+
downlink: '2',
|
|
2144
|
+
dpr: '2',
|
|
2145
|
+
ect: '4g',
|
|
2146
|
+
pragma: 'no-cache',
|
|
2147
|
+
referer: 'https://www.amazon.de/gp/css/order-history?ref_=nav_orders_first',
|
|
2148
|
+
rtt: '50',
|
|
2149
|
+
'sec-ch-device-memory': '8',
|
|
2150
|
+
'sec-ch-dpr': '2',
|
|
2151
|
+
'sec-ch-ua': '"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"',
|
|
2152
|
+
'sec-ch-ua-mobile': '?0',
|
|
2153
|
+
'sec-ch-ua-platform': '"macOS"',
|
|
2154
|
+
'sec-ch-ua-platform-version': '"14.1.1"',
|
|
2155
|
+
'sec-ch-viewport-width': '1264',
|
|
2156
|
+
'sec-fetch-dest': 'document',
|
|
2157
|
+
'sec-fetch-mode': 'navigate',
|
|
2158
|
+
'sec-fetch-site': 'same-origin',
|
|
2159
|
+
'sec-fetch-user': '?1',
|
|
2160
|
+
'upgrade-insecure-requests': '1',
|
|
2161
|
+
'user-agent':
|
|
2162
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
|
|
2163
|
+
'viewport-width': '1264',
|
|
2154
2164
|
},
|
|
2155
2165
|
})
|
|
2156
2166
|
.then(async (res) => {
|
|
@@ -2201,6 +2211,18 @@ class Parcel extends utils.Adapter {
|
|
|
2201
2211
|
if (!status) {
|
|
2202
2212
|
status = stateObject.promise?.promiseMessage;
|
|
2203
2213
|
}
|
|
2214
|
+
if (!status) {
|
|
2215
|
+
const shippingInfo = document.querySelector('.js-shipment-info-container');
|
|
2216
|
+
if (shippingInfo) {
|
|
2217
|
+
status = shippingInfo.textContent.replace(/\n */g, '');
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
if (!status) {
|
|
2221
|
+
const returnInfo = document.querySelector('.a-alert-container .a-text-bold');
|
|
2222
|
+
if (returnInfo) {
|
|
2223
|
+
status = returnInfo.textContent.replace(/\n */g, '');
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2204
2226
|
if (!additionalStatus) {
|
|
2205
2227
|
additionalStatus = stateObject.promise?.pdwHelpIconMessage;
|
|
2206
2228
|
}
|
|
@@ -2218,7 +2240,11 @@ class Parcel extends utils.Adapter {
|
|
|
2218
2240
|
if (stopsStatus) {
|
|
2219
2241
|
status = status + '. ' + stopsStatus;
|
|
2220
2242
|
}
|
|
2221
|
-
|
|
2243
|
+
if (!status) {
|
|
2244
|
+
this.log.info('No status found for ' + order.url);
|
|
2245
|
+
this.log.debug(res.data);
|
|
2246
|
+
return;
|
|
2247
|
+
}
|
|
2222
2248
|
return {
|
|
2223
2249
|
id: document.querySelector('.pt-delivery-card-trackingId')
|
|
2224
2250
|
? document.querySelector('.pt-delivery-card-trackingId').textContent.replace('Trackingnummer ', '')
|
|
@@ -2260,15 +2286,35 @@ class Parcel extends utils.Adapter {
|
|
|
2260
2286
|
async getAmazonOrders() {
|
|
2261
2287
|
return await this.requestClient({
|
|
2262
2288
|
method: 'get',
|
|
2263
|
-
url: 'https://www.amazon.de/gp/css/order-history?ref_=nav_orders_first
|
|
2289
|
+
url: 'https://www.amazon.de/gp/css/order-history?ref_=nav_orders_first',
|
|
2264
2290
|
headers: {
|
|
2265
2291
|
authority: 'www.amazon.de',
|
|
2292
|
+
Connection: 'keep-alive',
|
|
2293
|
+
'Cache-Control': 'no-cache',
|
|
2266
2294
|
accept:
|
|
2267
2295
|
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
|
2268
2296
|
'accept-language': 'de-de',
|
|
2269
|
-
|
|
2270
|
-
'
|
|
2271
|
-
'
|
|
2297
|
+
Pragma: 'no-cache',
|
|
2298
|
+
'Sec-Fetch-Dest': 'document',
|
|
2299
|
+
'Sec-Fetch-Mode': 'navigate',
|
|
2300
|
+
'Sec-Fetch-Site': 'none',
|
|
2301
|
+
'Sec-Fetch-User': '?1',
|
|
2302
|
+
'Upgrade-Insecure-Requests': '1',
|
|
2303
|
+
'User-Agent':
|
|
2304
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
|
|
2305
|
+
'device-memory': '8',
|
|
2306
|
+
downlink: '10',
|
|
2307
|
+
dpr: '2',
|
|
2308
|
+
ect: '4g',
|
|
2309
|
+
rtt: '50',
|
|
2310
|
+
'sec-ch-device-memory': '8',
|
|
2311
|
+
'sec-ch-dpr': '2',
|
|
2312
|
+
'sec-ch-ua': '"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"',
|
|
2313
|
+
'sec-ch-ua-mobile': '?0',
|
|
2314
|
+
'sec-ch-ua-platform': '"macOS"',
|
|
2315
|
+
'sec-ch-ua-platform-version': '"14.1.1"',
|
|
2316
|
+
'sec-ch-viewport-width': '1264',
|
|
2317
|
+
'viewport-width': '1264',
|
|
2272
2318
|
},
|
|
2273
2319
|
})
|
|
2274
2320
|
.then(async (res) => {
|
|
@@ -2277,6 +2323,8 @@ class Parcel extends utils.Adapter {
|
|
|
2277
2323
|
|
|
2278
2324
|
if (res.data.includes('auth-workflow')) {
|
|
2279
2325
|
this.log.debug('Amazon Login required');
|
|
2326
|
+
|
|
2327
|
+
this.log.debug(res.data);
|
|
2280
2328
|
await this.loginAmz();
|
|
2281
2329
|
return;
|
|
2282
2330
|
}
|
|
@@ -2286,10 +2334,12 @@ class Parcel extends utils.Adapter {
|
|
|
2286
2334
|
|
|
2287
2335
|
for (const order of orders) {
|
|
2288
2336
|
const descHandle = order.querySelector(
|
|
2289
|
-
'.a-fixed-right-grid-col.a-col-left .a-fixed-left-grid-col.a-col-right div:first-child .a-link-normal'
|
|
2337
|
+
'.a-fixed-right-grid-col.a-col-left .a-fixed-left-grid-col.a-col-right div:first-child .a-link-normal',
|
|
2290
2338
|
);
|
|
2291
2339
|
const desc = descHandle ? descHandle.textContent.replace(/\n */g, '') : '';
|
|
2292
|
-
let url = order.querySelector('.track-package-button a')
|
|
2340
|
+
let url = order.querySelector('.track-package-button a')
|
|
2341
|
+
? order.querySelector('.track-package-button a').getAttribute('href')
|
|
2342
|
+
: '';
|
|
2293
2343
|
if (!url) {
|
|
2294
2344
|
const allLinks = order.querySelectorAll('.a-button-inner a');
|
|
2295
2345
|
for (const link of allLinks) {
|
|
@@ -2570,8 +2620,7 @@ class Parcel extends utils.Adapter {
|
|
|
2570
2620
|
await this.requestClient({
|
|
2571
2621
|
method: 'post',
|
|
2572
2622
|
url: 'https://buyer.17track.net/orderapi/call',
|
|
2573
|
-
|
|
2574
|
-
|
|
2623
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
2575
2624
|
data: JSON.stringify({
|
|
2576
2625
|
version: '1.0',
|
|
2577
2626
|
timeZoneOffset: -60,
|
|
@@ -2622,10 +2671,10 @@ class Parcel extends utils.Adapter {
|
|
|
2622
2671
|
const pathArray = id.split('.');
|
|
2623
2672
|
pathArray.pop();
|
|
2624
2673
|
pathArray.push('image');
|
|
2625
|
-
await this.
|
|
2674
|
+
await this.extendObjectAsync(pathArray.join('.'), {
|
|
2626
2675
|
type: 'state',
|
|
2627
2676
|
common: {
|
|
2628
|
-
name: 'Image',
|
|
2677
|
+
name: 'Image Base64 Decrypted from URL',
|
|
2629
2678
|
write: false,
|
|
2630
2679
|
read: true,
|
|
2631
2680
|
type: 'string',
|
|
@@ -2691,6 +2740,8 @@ class Parcel extends utils.Adapter {
|
|
|
2691
2740
|
this.log.error(error);
|
|
2692
2741
|
}
|
|
2693
2742
|
}
|
|
2743
|
+
} else {
|
|
2744
|
+
this.setState(id.replace('image_url', 'image'), imageBase64, true);
|
|
2694
2745
|
}
|
|
2695
2746
|
}
|
|
2696
2747
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.parcel",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Parcel tracking",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TA2k",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@iobroker/adapter-core": "^3.0.4",
|
|
29
|
-
"axios": "^1.6.
|
|
29
|
+
"axios": "^1.6.2",
|
|
30
30
|
"http-cookie-agent": "^5.0.4",
|
|
31
31
|
"jsdom": "^21.1.2",
|
|
32
32
|
"json2iob": "^2.4.8",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@types/chai": "^4.3.10",
|
|
40
40
|
"@types/chai-as-promised": "^7.1.8",
|
|
41
41
|
"@types/mocha": "^10.0.4",
|
|
42
|
-
"@types/node": "^20.9.
|
|
42
|
+
"@types/node": "^20.9.1",
|
|
43
43
|
"@types/proxyquire": "^1.3.31",
|
|
44
44
|
"@types/sinon": "^10.0.20",
|
|
45
45
|
"@types/sinon-chai": "^3.2.12",
|