iobroker.parcel 0.2.1 → 0.2.5
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 +12 -1
- package/main.js +151 -60
- package/package.json +8 -8
package/io-package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "parcel",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.5",
|
|
5
5
|
"news": {
|
|
6
|
+
"0.2.5": {
|
|
7
|
+
"en": "Improve DHL Status and add link to shipment in the telegram notification",
|
|
8
|
+
"de": "Verbesserung des DHL Status und Link zur Sendung in der Telegram Benachrichtigung hinzugefügt"
|
|
9
|
+
},
|
|
10
|
+
"0.2.2": {
|
|
11
|
+
"en": "Improvment for Amazon Login and fix for Briefaanündigung Image",
|
|
12
|
+
"de": "Verbesserung für Amazon Login und Fix für Briefankündigung Image State"
|
|
13
|
+
},
|
|
6
14
|
"0.2.1": {
|
|
7
15
|
"en": "Fix for Briefankündigung",
|
|
8
16
|
"de": "Briefankündigung wieder aktiviert"
|
|
@@ -166,6 +174,9 @@
|
|
|
166
174
|
"native": {
|
|
167
175
|
"amzusername": "",
|
|
168
176
|
"amzpassword": "",
|
|
177
|
+
"aliUsername": "",
|
|
178
|
+
"aliPassword": "",
|
|
179
|
+
"aliMfa": "",
|
|
169
180
|
"glsusername": "",
|
|
170
181
|
"glspassword": "",
|
|
171
182
|
"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
|
/**
|
|
@@ -403,6 +404,10 @@ class Parcel extends utils.Adapter {
|
|
|
403
404
|
this.log.error(JSON.stringify(error.response.data));
|
|
404
405
|
}
|
|
405
406
|
});
|
|
407
|
+
if (!codeUrl) {
|
|
408
|
+
this.log.error('DHL codeUrl failed');
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
406
411
|
await this.requestClient({
|
|
407
412
|
method: 'post',
|
|
408
413
|
url: 'https://login.dhl.de/af5f9bb6-27ad-4af4-9445-008e7a5cddb8/login/token',
|
|
@@ -451,8 +456,6 @@ class Parcel extends utils.Adapter {
|
|
|
451
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',
|
|
452
457
|
'accept-language': 'de-de',
|
|
453
458
|
},
|
|
454
|
-
jar: this.cookieJar,
|
|
455
|
-
withCredentials: true,
|
|
456
459
|
})
|
|
457
460
|
.then(async (res) => {
|
|
458
461
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -482,8 +485,6 @@ class Parcel extends utils.Adapter {
|
|
|
482
485
|
force: false,
|
|
483
486
|
meta: '',
|
|
484
487
|
}),
|
|
485
|
-
jar: this.cookieJar,
|
|
486
|
-
withCredentials: true,
|
|
487
488
|
})
|
|
488
489
|
.then(async (res) => {
|
|
489
490
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -620,8 +621,6 @@ class Parcel extends utils.Adapter {
|
|
|
620
621
|
referer: 'https://login.aliexpress.com/',
|
|
621
622
|
'accept-language': 'de',
|
|
622
623
|
},
|
|
623
|
-
jar: this.cookieJar,
|
|
624
|
-
withCredentials: true,
|
|
625
624
|
})
|
|
626
625
|
.then(async (res) => {
|
|
627
626
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -699,6 +698,7 @@ class Parcel extends utils.Adapter {
|
|
|
699
698
|
} else {
|
|
700
699
|
this.log.info('Login to AliExpress with MFA token');
|
|
701
700
|
this.log.debug('MFA: ' + this.config.dhlMfa);
|
|
701
|
+
const mfaToken = '';
|
|
702
702
|
await this.requestClient({
|
|
703
703
|
method: 'post',
|
|
704
704
|
url: 'https://www.dhl.de/int-erkennen/2fa',
|
|
@@ -775,8 +775,6 @@ class Parcel extends utils.Adapter {
|
|
|
775
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',
|
|
776
776
|
'accept-language': 'de-de',
|
|
777
777
|
},
|
|
778
|
-
jar: this.cookieJar,
|
|
779
|
-
withCredentials: true,
|
|
780
778
|
})
|
|
781
779
|
.then(async (res) => {
|
|
782
780
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -807,8 +805,6 @@ class Parcel extends utils.Adapter {
|
|
|
807
805
|
referer: 'https://www.amazon.de/ap/signin',
|
|
808
806
|
},
|
|
809
807
|
data: qs.stringify(form),
|
|
810
|
-
jar: this.cookieJar,
|
|
811
|
-
withCredentials: true,
|
|
812
808
|
})
|
|
813
809
|
.then(async (res) => {
|
|
814
810
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -841,13 +837,11 @@ class Parcel extends utils.Adapter {
|
|
|
841
837
|
referer: 'https://www.amazon.de/ap/signin',
|
|
842
838
|
},
|
|
843
839
|
data: qs.stringify(form),
|
|
844
|
-
jar: this.cookieJar,
|
|
845
|
-
withCredentials: true,
|
|
846
840
|
})
|
|
847
841
|
.then(async (res) => {
|
|
848
842
|
this.log.debug(JSON.stringify(res.data));
|
|
849
843
|
if (res.data.indexOf('js-yo-main-content') !== -1) {
|
|
850
|
-
this.log.info('
|
|
844
|
+
this.log.info('Relogin to Amazon successful');
|
|
851
845
|
this.sessions['amz'] = true;
|
|
852
846
|
this.setState('info.connection', true, true);
|
|
853
847
|
this.setState('auth.cookie', JSON.stringify(this.cookieJar.toJSON()), true);
|
|
@@ -872,8 +866,6 @@ class Parcel extends utils.Adapter {
|
|
|
872
866
|
referer: 'https://www.amazon.de/ap/signin',
|
|
873
867
|
},
|
|
874
868
|
data: qs.stringify(form),
|
|
875
|
-
jar: this.cookieJar,
|
|
876
|
-
withCredentials: true,
|
|
877
869
|
})
|
|
878
870
|
.then(async (res) => {
|
|
879
871
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -943,8 +935,6 @@ class Parcel extends utils.Adapter {
|
|
|
943
935
|
await this.requestClient({
|
|
944
936
|
method: 'get',
|
|
945
937
|
url: 'https://my.dpd.de/logout.aspx',
|
|
946
|
-
jar: this.cookieJar,
|
|
947
|
-
withCredentials: true,
|
|
948
938
|
}).catch(async (error) => {
|
|
949
939
|
error.response && this.log.error(JSON.stringify(error.response.data));
|
|
950
940
|
this.log.error(error);
|
|
@@ -964,8 +954,6 @@ class Parcel extends utils.Adapter {
|
|
|
964
954
|
dpg_username: this.config.dpdusername,
|
|
965
955
|
dpg_password: this.config.dpdpassword,
|
|
966
956
|
}),
|
|
967
|
-
jar: this.cookieJar,
|
|
968
|
-
withCredentials: true,
|
|
969
957
|
maxRedirects: 0,
|
|
970
958
|
})
|
|
971
959
|
.then(async (res) => {
|
|
@@ -1010,8 +998,6 @@ class Parcel extends utils.Adapter {
|
|
|
1010
998
|
await this.requestClient({
|
|
1011
999
|
method: 'get',
|
|
1012
1000
|
url: 'https://my.dpd.de/myParcel.aspx?dpd_token=' + this.dpdToken,
|
|
1013
|
-
jar: this.cookieJar,
|
|
1014
|
-
withCredentials: true,
|
|
1015
1001
|
}).catch(async (error) => {
|
|
1016
1002
|
error.response && this.log.error(JSON.stringify(error.response.data));
|
|
1017
1003
|
this.log.error(error);
|
|
@@ -1037,8 +1023,6 @@ class Parcel extends utils.Adapter {
|
|
|
1037
1023
|
username: this.config.glsusername,
|
|
1038
1024
|
password: this.config.glspassword,
|
|
1039
1025
|
}),
|
|
1040
|
-
jar: this.cookieJar,
|
|
1041
|
-
withCredentials: true,
|
|
1042
1026
|
})
|
|
1043
1027
|
.then(async (res) => {
|
|
1044
1028
|
this.sessions['gls'] = res.data;
|
|
@@ -1066,8 +1050,6 @@ class Parcel extends utils.Adapter {
|
|
|
1066
1050
|
'X-Client-Id': 'iOS',
|
|
1067
1051
|
'X-Auth-Token': this.glstoken,
|
|
1068
1052
|
},
|
|
1069
|
-
jar: this.cookieJar,
|
|
1070
|
-
withCredentials: true,
|
|
1071
1053
|
})
|
|
1072
1054
|
.then(async (res) => {
|
|
1073
1055
|
!silent && this.log.info('Login to GLS successful');
|
|
@@ -1110,9 +1092,6 @@ class Parcel extends utils.Adapter {
|
|
|
1110
1092
|
'accept-language': 'de-de',
|
|
1111
1093
|
},
|
|
1112
1094
|
data: { username: this.config.hermesusername, password: this.config.hermespassword },
|
|
1113
|
-
|
|
1114
|
-
jar: this.cookieJar,
|
|
1115
|
-
withCredentials: true,
|
|
1116
1095
|
})
|
|
1117
1096
|
.then(async (res) => {
|
|
1118
1097
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -1178,8 +1157,6 @@ class Parcel extends utils.Adapter {
|
|
|
1178
1157
|
IsMobile: 'true',
|
|
1179
1158
|
},
|
|
1180
1159
|
}),
|
|
1181
|
-
jar: this.cookieJar,
|
|
1182
|
-
withCredentials: true,
|
|
1183
1160
|
})
|
|
1184
1161
|
.then(async (res) => {
|
|
1185
1162
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -1259,8 +1236,6 @@ class Parcel extends utils.Adapter {
|
|
|
1259
1236
|
},
|
|
1260
1237
|
},
|
|
1261
1238
|
}),
|
|
1262
|
-
jar: this.cookieJar,
|
|
1263
|
-
withCredentials: true,
|
|
1264
1239
|
})
|
|
1265
1240
|
.then(async (res) => {
|
|
1266
1241
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -1357,8 +1332,6 @@ class Parcel extends utils.Adapter {
|
|
|
1357
1332
|
'","Password":"' +
|
|
1358
1333
|
this.config.t17password +
|
|
1359
1334
|
'","CaptchaCode":""},"sourcetype":0,"timeZoneOffset":-60}',
|
|
1360
|
-
jar: this.cookieJar,
|
|
1361
|
-
withCredentials: true,
|
|
1362
1335
|
})
|
|
1363
1336
|
.then(async (res) => {
|
|
1364
1337
|
this.log.debug(JSON.stringify(res.data));
|
|
@@ -1695,17 +1668,17 @@ class Parcel extends utils.Adapter {
|
|
|
1695
1668
|
async cleanupProvider(id, data) {
|
|
1696
1669
|
if (id === 'dhl' && data.hasOwnProperty('grantToken')) {
|
|
1697
1670
|
await this.delObjectAsync('dhl.briefe', { recursive: true });
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
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
|
+
});
|
|
1709
1682
|
}
|
|
1710
1683
|
if ((id === 'dhl' || id === 'dpd' || id === 'amz' || id === 'gls' || id === 'ups' || id === 'hermes') && data && data.sendungen) {
|
|
1711
1684
|
const states = await this.getStatesAsync(id + '.sendungen*.id');
|
|
@@ -1735,9 +1708,14 @@ class Parcel extends utils.Adapter {
|
|
|
1735
1708
|
if (sendung.sendungsdetails && sendung.sendungsdetails.sendungsverlauf && sendung.sendungsdetails.sendungsverlauf.kurzStatus) {
|
|
1736
1709
|
status = sendung.sendungsdetails.sendungsverlauf.kurzStatus;
|
|
1737
1710
|
}
|
|
1738
|
-
if (sendung.sendungsdetails && sendung.sendungsdetails.
|
|
1711
|
+
if (sendung.sendungsdetails && sendung.sendungsdetails.liveTracking) {
|
|
1739
1712
|
status = status + ' ' + sendung.sendungsdetails.liveTracking.countdown + ' Stopps';
|
|
1740
1713
|
}
|
|
1714
|
+
if (sendung.sendungsdetails && sendung.sendungsdetails.zustellung && sendung.sendungsdetails.zustellung.zustellzeitfensterBis) {
|
|
1715
|
+
const bisDate = new Date(sendung.sendungsdetails.zustellung.zustellzeitfensterBis).toLocaleTimeString('de-DE');
|
|
1716
|
+
const vonDate = new Date(sendung.sendungsdetails.zustellung.zustellzeitfensterVon).toLocaleTimeString('de-DE');
|
|
1717
|
+
status = status + ' ' + vonDate + '-' + bisDate;
|
|
1718
|
+
}
|
|
1741
1719
|
const name = sendung.sendungsinfo.sendungsname || 'Unbekannt';
|
|
1742
1720
|
|
|
1743
1721
|
const sendungsObject = { id: sendung.id, name: name, status: status, source: 'DHL' };
|
|
@@ -1802,6 +1780,7 @@ class Parcel extends utils.Adapter {
|
|
|
1802
1780
|
}
|
|
1803
1781
|
const sendungsObject = {
|
|
1804
1782
|
id: sendung.id,
|
|
1783
|
+
tracking: sendung.order,
|
|
1805
1784
|
name: name,
|
|
1806
1785
|
status: sendung.status.text.longText || '',
|
|
1807
1786
|
source: 'Hermes',
|
|
@@ -1845,7 +1824,13 @@ class Parcel extends utils.Adapter {
|
|
|
1845
1824
|
}
|
|
1846
1825
|
if (id === 'amz' && data && data.sendungen) {
|
|
1847
1826
|
const sendungsArray = data.sendungen.map((sendung) => {
|
|
1848
|
-
const sendungsObject = {
|
|
1827
|
+
const sendungsObject = {
|
|
1828
|
+
id: sendung.id,
|
|
1829
|
+
name: sendung.name,
|
|
1830
|
+
status: sendung.status,
|
|
1831
|
+
source: 'AMZ',
|
|
1832
|
+
tracking: sendung.detailedState.orderId,
|
|
1833
|
+
};
|
|
1849
1834
|
|
|
1850
1835
|
sendungsObject.delivery_status = this.deliveryStatusCheck(sendung, id, sendungsObject);
|
|
1851
1836
|
if (sendungsObject.delivery_status === this.delivery_status.OUT_FOR_DELIVERY) {
|
|
@@ -1923,7 +1908,7 @@ class Parcel extends utils.Adapter {
|
|
|
1923
1908
|
const sendInstances = this.config.sendToInstance.replace(/ /g, '').split(',');
|
|
1924
1909
|
const sendUser = this.config.sendToUser.replace(/ /g, '').split(',');
|
|
1925
1910
|
for (const sendInstance of sendInstances) {
|
|
1926
|
-
|
|
1911
|
+
let text = '📦 ' + sendungen[id].source + ' ' + sendungen[id].name + '\n' + sendungen[id].status;
|
|
1927
1912
|
if (sendUser.length > 0) {
|
|
1928
1913
|
for (const user of sendUser) {
|
|
1929
1914
|
if (sendInstance.includes('pushover')) {
|
|
@@ -1937,6 +1922,37 @@ class Parcel extends utils.Adapter {
|
|
|
1937
1922
|
text: text,
|
|
1938
1923
|
phone: user,
|
|
1939
1924
|
});
|
|
1925
|
+
} else if (sendInstance.includes('telegram')) {
|
|
1926
|
+
let url = '';
|
|
1927
|
+
let trackingId = sendungen[id].tracking || id;
|
|
1928
|
+
if (sendungen[id].source === 'DHL') {
|
|
1929
|
+
url = 'https://www.dhl.de/de/privatkunden/dhl-sendungsverfolgung.html?piececode=' + trackingId;
|
|
1930
|
+
}
|
|
1931
|
+
if (sendungen[id].source === 'AMZ') {
|
|
1932
|
+
url = 'https://www.amazon.de/gp/your-account/order-details?orderID=' + trackingId;
|
|
1933
|
+
}
|
|
1934
|
+
if (sendungen[id].source === 'GLS') {
|
|
1935
|
+
url = 'https://gls-group.eu/DE/de/paketverfolgung?match=' + trackingId;
|
|
1936
|
+
}
|
|
1937
|
+
if (sendungen[id].source === 'DPD') {
|
|
1938
|
+
url = 'https://tracking.dpd.de/parcelstatus?query=' + trackingId;
|
|
1939
|
+
}
|
|
1940
|
+
if (sendungen[id].source === 'UPS') {
|
|
1941
|
+
url = 'https://www.ups.com/track?loc=de_DE&tracknum=' + trackingId;
|
|
1942
|
+
}
|
|
1943
|
+
if (sendungen[id].source === 'Hermes') {
|
|
1944
|
+
url = 'https://www.myhermes.de/empfangen/sendungsverfolgung/sendungsinformation/?trackingnumber=' + trackingId;
|
|
1945
|
+
}
|
|
1946
|
+
let name = sendungen[id].name;
|
|
1947
|
+
if (name != null && name.replace) {
|
|
1948
|
+
name = name.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
1949
|
+
}
|
|
1950
|
+
let status = sendungen[id].status;
|
|
1951
|
+
if (status != null && status.replace) {
|
|
1952
|
+
status = status.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
1953
|
+
}
|
|
1954
|
+
text = '📦 <a href="' + url + '">' + sendungen[id].source + '</a> ' + name + '\n' + status;
|
|
1955
|
+
await this.sendToAsync(sendInstance, { user: user, text: text, disable_web_page_preview: true, parse_mode: 'HTML' });
|
|
1940
1956
|
} else {
|
|
1941
1957
|
await this.sendToAsync(sendInstance, { user: user, text: text });
|
|
1942
1958
|
}
|
|
@@ -2135,6 +2151,7 @@ class Parcel extends utils.Adapter {
|
|
|
2135
2151
|
this.log.debug('Get Amazon Packages');
|
|
2136
2152
|
const amzResult = { sendungen: [] };
|
|
2137
2153
|
|
|
2154
|
+
await this.loginAmz();
|
|
2138
2155
|
let orders = await this.getAmazonOrders();
|
|
2139
2156
|
if (!orders) {
|
|
2140
2157
|
orders = await this.getAmazonOrders();
|
|
@@ -2152,13 +2169,38 @@ class Parcel extends utils.Adapter {
|
|
|
2152
2169
|
order.url = 'https://www.amazon.de' + order.url;
|
|
2153
2170
|
}
|
|
2154
2171
|
this.log.debug(order.url);
|
|
2155
|
-
order.url = order.url + '
|
|
2172
|
+
order.url = order.url + '';
|
|
2156
2173
|
const element = await this.requestClient({
|
|
2157
2174
|
method: 'get',
|
|
2158
2175
|
url: order.url,
|
|
2159
2176
|
headers: {
|
|
2160
|
-
|
|
2161
|
-
|
|
2177
|
+
authority: 'www.amazon.de',
|
|
2178
|
+
accept:
|
|
2179
|
+
'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',
|
|
2180
|
+
'accept-language': 'de,en;q=0.9,es;q=0.8,hi;q=0.7,kn;q=0.6',
|
|
2181
|
+
'cache-control': 'no-cache',
|
|
2182
|
+
'device-memory': '8',
|
|
2183
|
+
downlink: '2',
|
|
2184
|
+
dpr: '2',
|
|
2185
|
+
ect: '4g',
|
|
2186
|
+
pragma: 'no-cache',
|
|
2187
|
+
referer: 'https://www.amazon.de/gp/css/order-history?ref_=nav_orders_first',
|
|
2188
|
+
rtt: '50',
|
|
2189
|
+
'sec-ch-device-memory': '8',
|
|
2190
|
+
'sec-ch-dpr': '2',
|
|
2191
|
+
'sec-ch-ua': '"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"',
|
|
2192
|
+
'sec-ch-ua-mobile': '?0',
|
|
2193
|
+
'sec-ch-ua-platform': '"macOS"',
|
|
2194
|
+
'sec-ch-ua-platform-version': '"14.1.1"',
|
|
2195
|
+
'sec-ch-viewport-width': '1264',
|
|
2196
|
+
'sec-fetch-dest': 'document',
|
|
2197
|
+
'sec-fetch-mode': 'navigate',
|
|
2198
|
+
'sec-fetch-site': 'same-origin',
|
|
2199
|
+
'sec-fetch-user': '?1',
|
|
2200
|
+
'upgrade-insecure-requests': '1',
|
|
2201
|
+
'user-agent':
|
|
2202
|
+
'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',
|
|
2203
|
+
'viewport-width': '1264',
|
|
2162
2204
|
},
|
|
2163
2205
|
})
|
|
2164
2206
|
.then(async (res) => {
|
|
@@ -2209,6 +2251,18 @@ class Parcel extends utils.Adapter {
|
|
|
2209
2251
|
if (!status) {
|
|
2210
2252
|
status = stateObject.promise?.promiseMessage;
|
|
2211
2253
|
}
|
|
2254
|
+
if (!status) {
|
|
2255
|
+
const shippingInfo = document.querySelector('.js-shipment-info-container');
|
|
2256
|
+
if (shippingInfo) {
|
|
2257
|
+
status = shippingInfo.textContent.replace(/\n */g, '');
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
if (!status) {
|
|
2261
|
+
const returnInfo = document.querySelector('.a-alert-container .a-text-bold');
|
|
2262
|
+
if (returnInfo) {
|
|
2263
|
+
status = returnInfo.textContent.replace(/\n */g, '');
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2212
2266
|
if (!additionalStatus) {
|
|
2213
2267
|
additionalStatus = stateObject.promise?.pdwHelpIconMessage;
|
|
2214
2268
|
}
|
|
@@ -2226,7 +2280,11 @@ class Parcel extends utils.Adapter {
|
|
|
2226
2280
|
if (stopsStatus) {
|
|
2227
2281
|
status = status + '. ' + stopsStatus;
|
|
2228
2282
|
}
|
|
2229
|
-
|
|
2283
|
+
if (!status) {
|
|
2284
|
+
this.log.info('No status found for ' + order.url);
|
|
2285
|
+
this.log.debug(res.data);
|
|
2286
|
+
return;
|
|
2287
|
+
}
|
|
2230
2288
|
return {
|
|
2231
2289
|
id: document.querySelector('.pt-delivery-card-trackingId')
|
|
2232
2290
|
? document.querySelector('.pt-delivery-card-trackingId').textContent.replace('Trackingnummer ', '')
|
|
@@ -2268,16 +2326,35 @@ class Parcel extends utils.Adapter {
|
|
|
2268
2326
|
async getAmazonOrders() {
|
|
2269
2327
|
return await this.requestClient({
|
|
2270
2328
|
method: 'get',
|
|
2271
|
-
url: 'https://www.amazon.de/gp/css/order-history?ref_=nav_orders_first
|
|
2329
|
+
url: 'https://www.amazon.de/gp/css/order-history?ref_=nav_orders_first',
|
|
2272
2330
|
headers: {
|
|
2273
2331
|
authority: 'www.amazon.de',
|
|
2332
|
+
Connection: 'keep-alive',
|
|
2333
|
+
'Cache-Control': 'no-cache',
|
|
2274
2334
|
accept:
|
|
2275
2335
|
'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',
|
|
2276
2336
|
'accept-language': 'de-de',
|
|
2277
|
-
|
|
2278
|
-
'
|
|
2279
|
-
|
|
2280
|
-
'
|
|
2337
|
+
Pragma: 'no-cache',
|
|
2338
|
+
'Sec-Fetch-Dest': 'document',
|
|
2339
|
+
'Sec-Fetch-Mode': 'navigate',
|
|
2340
|
+
'Sec-Fetch-Site': 'none',
|
|
2341
|
+
'Sec-Fetch-User': '?1',
|
|
2342
|
+
'Upgrade-Insecure-Requests': '1',
|
|
2343
|
+
'User-Agent':
|
|
2344
|
+
'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',
|
|
2345
|
+
'device-memory': '8',
|
|
2346
|
+
downlink: '10',
|
|
2347
|
+
dpr: '2',
|
|
2348
|
+
ect: '4g',
|
|
2349
|
+
rtt: '50',
|
|
2350
|
+
'sec-ch-device-memory': '8',
|
|
2351
|
+
'sec-ch-dpr': '2',
|
|
2352
|
+
'sec-ch-ua': '"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"',
|
|
2353
|
+
'sec-ch-ua-mobile': '?0',
|
|
2354
|
+
'sec-ch-ua-platform': '"macOS"',
|
|
2355
|
+
'sec-ch-ua-platform-version': '"14.1.1"',
|
|
2356
|
+
'sec-ch-viewport-width': '1264',
|
|
2357
|
+
'viewport-width': '1264',
|
|
2281
2358
|
},
|
|
2282
2359
|
})
|
|
2283
2360
|
.then(async (res) => {
|
|
@@ -2286,6 +2363,8 @@ class Parcel extends utils.Adapter {
|
|
|
2286
2363
|
|
|
2287
2364
|
if (res.data.includes('auth-workflow')) {
|
|
2288
2365
|
this.log.debug('Amazon Login required');
|
|
2366
|
+
|
|
2367
|
+
this.log.debug(res.data);
|
|
2289
2368
|
await this.loginAmz();
|
|
2290
2369
|
return;
|
|
2291
2370
|
}
|
|
@@ -2581,8 +2660,7 @@ class Parcel extends utils.Adapter {
|
|
|
2581
2660
|
await this.requestClient({
|
|
2582
2661
|
method: 'post',
|
|
2583
2662
|
url: 'https://buyer.17track.net/orderapi/call',
|
|
2584
|
-
|
|
2585
|
-
|
|
2663
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
2586
2664
|
data: JSON.stringify({
|
|
2587
2665
|
version: '1.0',
|
|
2588
2666
|
timeZoneOffset: -60,
|
|
@@ -2702,6 +2780,19 @@ class Parcel extends utils.Adapter {
|
|
|
2702
2780
|
this.log.error(error);
|
|
2703
2781
|
}
|
|
2704
2782
|
}
|
|
2783
|
+
} else {
|
|
2784
|
+
await this.extendObjectAsync(id.replace('image_url', 'image'), {
|
|
2785
|
+
type: 'state',
|
|
2786
|
+
common: {
|
|
2787
|
+
name: 'Image Base64 Decrypted from URL',
|
|
2788
|
+
write: false,
|
|
2789
|
+
read: true,
|
|
2790
|
+
type: 'string',
|
|
2791
|
+
role: 'state',
|
|
2792
|
+
},
|
|
2793
|
+
native: {},
|
|
2794
|
+
});
|
|
2795
|
+
this.setState(id.replace('image_url', 'image'), imageBase64, true);
|
|
2705
2796
|
}
|
|
2706
2797
|
}
|
|
2707
2798
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.parcel",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Parcel tracking",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TA2k",
|
|
@@ -26,31 +26,31 @@
|
|
|
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
|
-
"json2iob": "^2.4.
|
|
32
|
+
"json2iob": "^2.4.11",
|
|
33
33
|
"qs": "^6.11.2",
|
|
34
34
|
"tough-cookie": "^4.1.3",
|
|
35
35
|
"uuid": "^9.0.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@iobroker/testing": "^4.1.0",
|
|
39
|
-
"@types/chai": "^4.3.
|
|
39
|
+
"@types/chai": "^4.3.11",
|
|
40
40
|
"@types/chai-as-promised": "^7.1.8",
|
|
41
|
-
"@types/mocha": "^10.0.
|
|
42
|
-
"@types/node": "^20.
|
|
41
|
+
"@types/mocha": "^10.0.6",
|
|
42
|
+
"@types/node": "^20.10.4",
|
|
43
43
|
"@types/proxyquire": "^1.3.31",
|
|
44
44
|
"@types/sinon": "^10.0.20",
|
|
45
45
|
"@types/sinon-chai": "^3.2.12",
|
|
46
46
|
"chai": "^4.3.10",
|
|
47
47
|
"chai-as-promised": "^7.1.1",
|
|
48
|
-
"eslint": "^8.
|
|
48
|
+
"eslint": "^8.55.0",
|
|
49
49
|
"mocha": "^10.2.0",
|
|
50
50
|
"proxyquire": "^2.1.3",
|
|
51
51
|
"sinon": "^15.2.0",
|
|
52
52
|
"sinon-chai": "^3.7.0",
|
|
53
|
-
"typescript": "~5.
|
|
53
|
+
"typescript": "~5.3.3"
|
|
54
54
|
},
|
|
55
55
|
"main": "main.js",
|
|
56
56
|
"files": [
|