iobroker.parcel 0.0.25 → 0.0.27
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 -1
- package/main.js +336 -29
- package/package.json +9 -9
package/io-package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "parcel",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.27",
|
|
5
5
|
"news": {
|
|
6
|
+
"0.0.27": {
|
|
7
|
+
"en": "Fix DHL Refresh token",
|
|
8
|
+
"de": "DHL Refresh token gefixt"
|
|
9
|
+
},
|
|
10
|
+
"0.0.26": {
|
|
11
|
+
"en": "Fix DHL Login",
|
|
12
|
+
"de": "DHL Login gefixt"
|
|
13
|
+
},
|
|
6
14
|
"0.0.25": {
|
|
7
15
|
"en": "Fix new Amazon UI parsing",
|
|
8
16
|
"de": "Neues Amazon UI parsing gefixt"
|
package/main.js
CHANGED
|
@@ -20,6 +20,7 @@ Module.prototype.require = function () {
|
|
|
20
20
|
const utils = require("@iobroker/adapter-core");
|
|
21
21
|
const axios = require("axios");
|
|
22
22
|
const qs = require("qs");
|
|
23
|
+
const crypto = require("crypto");
|
|
23
24
|
const Json2iob = require("./lib/json2iob");
|
|
24
25
|
const getPwd = require("./lib/rsaKey");
|
|
25
26
|
const tough = require("tough-cookie");
|
|
@@ -87,8 +88,9 @@ class Parcel extends utils.Adapter {
|
|
|
87
88
|
|
|
88
89
|
if (this.config.dhlusername && this.config.dhlpassword) {
|
|
89
90
|
this.log.info("Login to DHL");
|
|
90
|
-
await this.
|
|
91
|
+
await this.loginDhlNew();
|
|
91
92
|
}
|
|
93
|
+
|
|
92
94
|
if (this.config.dpdusername && this.config.dpdpassword) {
|
|
93
95
|
this.log.info("Login to DPD");
|
|
94
96
|
await this.loginDPD();
|
|
@@ -143,6 +145,299 @@ class Parcel extends utils.Adapter {
|
|
|
143
145
|
this.log.warn("No login session found");
|
|
144
146
|
}
|
|
145
147
|
}
|
|
148
|
+
async loginDhlNew() {
|
|
149
|
+
const validCookies = await this.requestClient({
|
|
150
|
+
method: "get",
|
|
151
|
+
url: "https://www.dhl.de/int-stammdaten/public/customerMasterData",
|
|
152
|
+
headers: {
|
|
153
|
+
accept: "application/json",
|
|
154
|
+
"content-type": "application/json",
|
|
155
|
+
"x-api-key": "a0d5b9049ba8918871e6e20bd5c49974",
|
|
156
|
+
"accept-language": "de-de",
|
|
157
|
+
"user-agent": "DHLPaket_PROD/1367 CFNetwork/1240.0.4 Darwin/20.6.0",
|
|
158
|
+
},
|
|
159
|
+
})
|
|
160
|
+
.then((res) => {
|
|
161
|
+
this.log.debug(res.data);
|
|
162
|
+
return true;
|
|
163
|
+
})
|
|
164
|
+
.catch((err) => {
|
|
165
|
+
return false;
|
|
166
|
+
});
|
|
167
|
+
// if (validCookies) {
|
|
168
|
+
// this.log.info("Valid dhl cookies found");
|
|
169
|
+
|
|
170
|
+
// this.setState("info.connection", true, true);
|
|
171
|
+
// return;
|
|
172
|
+
// }
|
|
173
|
+
const mfaTokenState = await this.getStateAsync("auth.dhlMfaToken");
|
|
174
|
+
const mfaToken = mfaTokenState ? mfaTokenState.val : null;
|
|
175
|
+
const [code_verifier, codeChallenge] = this.getCodeChallenge();
|
|
176
|
+
|
|
177
|
+
const transactionId = this.randomString(40);
|
|
178
|
+
const initUrl = await this.requestClient({
|
|
179
|
+
method: "get",
|
|
180
|
+
maxBodyLength: Infinity,
|
|
181
|
+
url: "https://login.dhl.de/af5f9bb6-27ad-4af4-9445-008e7a5cddb8/login/authorize",
|
|
182
|
+
params: {
|
|
183
|
+
redirect_uri: "dhllogin://de.deutschepost.dhl/login",
|
|
184
|
+
state: "eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9",
|
|
185
|
+
client_id: "83471082-5c13-4fce-8dcb-19d2a3fca413",
|
|
186
|
+
response_type: "code",
|
|
187
|
+
scope: "openid offline_access",
|
|
188
|
+
claims:
|
|
189
|
+
'{"id_token":{"email":null,"post_number":null,"twofa":null,"service_mask":null,"deactivate_account":null,"last_login":null,"customer_type":null,"display_name":null}}',
|
|
190
|
+
nonce: "",
|
|
191
|
+
login_hint: "",
|
|
192
|
+
prompt: "login",
|
|
193
|
+
ui_locales: "de-DE",
|
|
194
|
+
code_challenge: codeChallenge,
|
|
195
|
+
code_challenge_method: 'S256"',
|
|
196
|
+
},
|
|
197
|
+
headers: {
|
|
198
|
+
Host: "login.dhl.de",
|
|
199
|
+
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
|
200
|
+
|
|
201
|
+
"User-Agent":
|
|
202
|
+
"Mozilla/5.0 (iPhone; CPU iPhone OS 14_8 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Mobile/15E148 Safari/604.1",
|
|
203
|
+
"Accept-Language": "de-de",
|
|
204
|
+
Connection: "keep-alive",
|
|
205
|
+
},
|
|
206
|
+
})
|
|
207
|
+
.then(async (res) => {
|
|
208
|
+
// this.log.debug(res.data);
|
|
209
|
+
return res.request.path;
|
|
210
|
+
})
|
|
211
|
+
.catch((error) => {
|
|
212
|
+
this.log.error(error);
|
|
213
|
+
error.response && this.log.error(JSON.stringify(error.response.data));
|
|
214
|
+
});
|
|
215
|
+
const initParams = qs.parse(initUrl.split("?")[1]);
|
|
216
|
+
const signin = await this.requestClient({
|
|
217
|
+
method: "post",
|
|
218
|
+
maxBodyLength: Infinity,
|
|
219
|
+
url: "https://login-api.dhl.de/widget/traditional_signin.jsonp",
|
|
220
|
+
headers: {
|
|
221
|
+
Host: "login-api.dhl.de",
|
|
222
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
223
|
+
Origin: "https://login.dhl.de",
|
|
224
|
+
Connection: "keep-alive",
|
|
225
|
+
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
|
226
|
+
"User-Agent":
|
|
227
|
+
"Mozilla/5.0 (iPhone; CPU iPhone OS 14_8 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Mobile/15E148 Safari/604.1",
|
|
228
|
+
Referer: "https://login.dhl.de/",
|
|
229
|
+
"Accept-Language": "de-de",
|
|
230
|
+
},
|
|
231
|
+
data: {
|
|
232
|
+
utf8: "✓",
|
|
233
|
+
capture_screen: "signIn",
|
|
234
|
+
js_version: "d445bf4",
|
|
235
|
+
capture_transactionId: transactionId,
|
|
236
|
+
form: "signInForm",
|
|
237
|
+
flow: "ciam_flow_001",
|
|
238
|
+
client_id: "f8s9584t9f9kz5wg9agkp259hc924uq9",
|
|
239
|
+
redirect_uri: "https://login.dhl.de" + initUrl,
|
|
240
|
+
response_type: "token",
|
|
241
|
+
flow_version: "20230309140056615616",
|
|
242
|
+
settings_version: "",
|
|
243
|
+
locale: "de-DE",
|
|
244
|
+
recaptchaVersion: "2",
|
|
245
|
+
emailOrPostNumber: this.config.dhlusername,
|
|
246
|
+
currentPassword: this.config.dhlpassword,
|
|
247
|
+
},
|
|
248
|
+
})
|
|
249
|
+
.then(async (res) => {
|
|
250
|
+
this.log.debug(res.data);
|
|
251
|
+
return true;
|
|
252
|
+
})
|
|
253
|
+
.catch((error) => {
|
|
254
|
+
this.log.error(error);
|
|
255
|
+
error.response && this.log.error(JSON.stringify(error.response.data));
|
|
256
|
+
});
|
|
257
|
+
if (!signin) {
|
|
258
|
+
this.log.error("DHL Signin failed");
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
const preSession = await this.requestClient({
|
|
262
|
+
method: "get",
|
|
263
|
+
maxBodyLength: Infinity,
|
|
264
|
+
url: "https://login-api.dhl.de/widget/get_result.jsonp?transactionId=" + transactionId + "&cache=" + Date.now(),
|
|
265
|
+
headers: {
|
|
266
|
+
Host: "login-api.dhl.de",
|
|
267
|
+
Connection: "keep-alive",
|
|
268
|
+
Accept: "*/*",
|
|
269
|
+
"User-Agent":
|
|
270
|
+
"Mozilla/5.0 (iPhone; CPU iPhone OS 14_8 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Mobile/15E148 Safari/604.1",
|
|
271
|
+
"Accept-Language": "de-de",
|
|
272
|
+
Referer: "https://login.dhl.de/",
|
|
273
|
+
},
|
|
274
|
+
})
|
|
275
|
+
.then(async (res) => {
|
|
276
|
+
this.log.debug(res.data);
|
|
277
|
+
return JSON.parse(res.data.split(")(")[1].split(");")[0]);
|
|
278
|
+
})
|
|
279
|
+
.catch((error) => {
|
|
280
|
+
this.log.error(error);
|
|
281
|
+
error.response && this.log.error(JSON.stringify(error.response.data));
|
|
282
|
+
});
|
|
283
|
+
if (!preSession || !preSession.result) {
|
|
284
|
+
this.log.error("DHL PreSession failed. Please check username password");
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const accessToken2 = await this.requestClient({
|
|
288
|
+
method: "post",
|
|
289
|
+
maxBodyLength: Infinity,
|
|
290
|
+
url: "https://login.dhl.de/af5f9bb6-27ad-4af4-9445-008e7a5cddb8/auth-ui/token-url",
|
|
291
|
+
params: {
|
|
292
|
+
__aic_csrf: initParams.__aic_csrf,
|
|
293
|
+
claims:
|
|
294
|
+
'{"id_token":{"customer_type":null,"deactivate_account":null,"display_name":null,"email":null,"last_login":null,"post_number":null,"service_mask":null,"twofa":null}}',
|
|
295
|
+
client_id: "83471082-5c13-4fce-8dcb-19d2a3fca413",
|
|
296
|
+
code_challenge: codeChallenge,
|
|
297
|
+
code_challenge_method: "S256",
|
|
298
|
+
login_hint: "",
|
|
299
|
+
nonce: "",
|
|
300
|
+
prompt: "login",
|
|
301
|
+
redirect_uri: "dhllogin://de.deutschepost.dhl/login",
|
|
302
|
+
response_type: "code",
|
|
303
|
+
scope: "openid",
|
|
304
|
+
state: "eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9",
|
|
305
|
+
ui_locales: 'de-DE",',
|
|
306
|
+
},
|
|
307
|
+
headers: {
|
|
308
|
+
Host: "login.dhl.de",
|
|
309
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
310
|
+
Origin: "https://login.dhl.de",
|
|
311
|
+
Connection: "keep-alive",
|
|
312
|
+
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
|
313
|
+
"User-Agent":
|
|
314
|
+
"Mozilla/5.0 (iPhone; CPU iPhone OS 14_8 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Mobile/15E148 Safari/604.1",
|
|
315
|
+
"Accept-Language": "de-de",
|
|
316
|
+
},
|
|
317
|
+
data: {
|
|
318
|
+
screen: "signIn",
|
|
319
|
+
authenticated: "True",
|
|
320
|
+
registering: "False",
|
|
321
|
+
accessToken: preSession.result.accessToken,
|
|
322
|
+
_csrf_token: this.cookieJar.store.idx["login.dhl.de"]["/"]._csrf_token.value,
|
|
323
|
+
},
|
|
324
|
+
})
|
|
325
|
+
.then(async (res) => {
|
|
326
|
+
// this.log.debug(res.data);
|
|
327
|
+
|
|
328
|
+
return res.data.split("existingToken: '")[1].split("'")[0];
|
|
329
|
+
})
|
|
330
|
+
.catch((error) => {
|
|
331
|
+
this.log.error(error);
|
|
332
|
+
error.response && this.log.error(JSON.stringify(error.response.data));
|
|
333
|
+
});
|
|
334
|
+
const idtoken = await this.requestClient({
|
|
335
|
+
method: "post",
|
|
336
|
+
maxBodyLength: Infinity,
|
|
337
|
+
url: "https://login.dhl.de/af5f9bb6-27ad-4af4-9445-008e7a5cddb8/auth-ui/token-url",
|
|
338
|
+
maxRedirects: 0,
|
|
339
|
+
params: {
|
|
340
|
+
__aic_csrf: initParams.__aic_csrf,
|
|
341
|
+
claims:
|
|
342
|
+
'{"id_token":{"customer_type":null,"deactivate_account":null,"display_name":null,"email":null,"last_login":null,"post_number":null,"service_mask":null,"twofa":null}}',
|
|
343
|
+
client_id: "83471082-5c13-4fce-8dcb-19d2a3fca413",
|
|
344
|
+
code_challenge: codeChallenge,
|
|
345
|
+
code_challenge_method: "S256",
|
|
346
|
+
login_hint: "",
|
|
347
|
+
nonce: "",
|
|
348
|
+
prompt: "login",
|
|
349
|
+
redirect_uri: "dhllogin://de.deutschepost.dhl/login",
|
|
350
|
+
response_type: "code",
|
|
351
|
+
scope: "openid",
|
|
352
|
+
state: "eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9",
|
|
353
|
+
ui_locales: "de-DE",
|
|
354
|
+
},
|
|
355
|
+
headers: {
|
|
356
|
+
Host: "login.dhl.de",
|
|
357
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
358
|
+
Origin: "https://login.dhl.de",
|
|
359
|
+
Connection: "keep-alive",
|
|
360
|
+
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
|
361
|
+
"User-Agent":
|
|
362
|
+
"Mozilla/5.0 (iPhone; CPU iPhone OS 14_8 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Mobile/15E148 Safari/604.1",
|
|
363
|
+
"Accept-Language": "de-de",
|
|
364
|
+
},
|
|
365
|
+
data: {
|
|
366
|
+
screen: "loginSuccess",
|
|
367
|
+
accessToken: accessToken2,
|
|
368
|
+
_csrf_token: this.cookieJar.store.idx["login.dhl.de"]["/"]._csrf_token.value,
|
|
369
|
+
},
|
|
370
|
+
})
|
|
371
|
+
.then(async (res) => {
|
|
372
|
+
this.log.debug(res.data);
|
|
373
|
+
return res.data;
|
|
374
|
+
})
|
|
375
|
+
.catch((error) => {
|
|
376
|
+
if (error.response && error.response.status === 302) {
|
|
377
|
+
return error.response.headers.location.split("id_token_hint=")[1].split("&")[0];
|
|
378
|
+
}
|
|
379
|
+
this.log.error(error);
|
|
380
|
+
error.response && this.log.error(JSON.stringify(error.response.data));
|
|
381
|
+
});
|
|
382
|
+
const codeUrl = await this.requestClient({
|
|
383
|
+
method: "get",
|
|
384
|
+
maxBodyLength: Infinity,
|
|
385
|
+
url:
|
|
386
|
+
'https://login.dhl.de/af5f9bb6-27ad-4af4-9445-008e7a5cddb8/login/authorize?claims={"id_token":{"customer_type":null,"deactivate_account":null,"display_name":null,"email":null,"last_login":null,"post_number":null,"service_mask":null,"twofa":null}}&client_id=83471082-5c13-4fce-8dcb-19d2a3fca413&code_challenge=' +
|
|
387
|
+
codeChallenge +
|
|
388
|
+
"&code_challenge_method=S256&prompt=none&redirect_uri=dhllogin://de.deutschepost.dhl/login&response_type=code&scope=openid&state=eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9&ui_locales=de-DE&id_token_hint=" +
|
|
389
|
+
idtoken,
|
|
390
|
+
})
|
|
391
|
+
.then(async (res) => {
|
|
392
|
+
this.log.debug(JSON.stringify(res.data));
|
|
393
|
+
})
|
|
394
|
+
.catch((error) => {
|
|
395
|
+
if (error.message.includes("Unsupported protocol")) {
|
|
396
|
+
return qs.parse(error.request._options.query);
|
|
397
|
+
}
|
|
398
|
+
this.log.error(error);
|
|
399
|
+
if (error.response) {
|
|
400
|
+
this.log.error(JSON.stringify(error.response.data));
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
await this.requestClient({
|
|
404
|
+
method: "post",
|
|
405
|
+
url: "https://login.dhl.de/af5f9bb6-27ad-4af4-9445-008e7a5cddb8/login/token",
|
|
406
|
+
headers: {
|
|
407
|
+
Host: "login.dhl.de",
|
|
408
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
409
|
+
Accept: "application/json, text/plain, */*",
|
|
410
|
+
Origin: "https://login.dhl.de",
|
|
411
|
+
Connection: "keep-alive",
|
|
412
|
+
Authorization: "Basic ODM0NzEwODItNWMxMy00ZmNlLThkY2ItMTlkMmEzZmNhNDEzOg==",
|
|
413
|
+
"User-Agent": "DHLPaket_PROD/1367 CFNetwork/1240.0.4 Darwin/20.6.0",
|
|
414
|
+
"Accept-Language": "de-de",
|
|
415
|
+
},
|
|
416
|
+
data: {
|
|
417
|
+
redirect_uri: "dhllogin://de.deutschepost.dhl/login",
|
|
418
|
+
grant_type: "authorization_code",
|
|
419
|
+
code_verifier: code_verifier,
|
|
420
|
+
code: codeUrl.code,
|
|
421
|
+
},
|
|
422
|
+
})
|
|
423
|
+
.then(async (res) => {
|
|
424
|
+
this.log.debug(JSON.stringify(res.data));
|
|
425
|
+
this.log.info("Login to DHL successful");
|
|
426
|
+
this.sessions["dhl"] = res.data;
|
|
427
|
+
await this.cookieJar.setCookie("dhli=" + res.data.id_token + "; path=/; domain=dhl.de", "https:/dhl.de");
|
|
428
|
+
await this.cookieJar.setCookie("dhli=" + res.data.id_token + "; path=/; domain=www.dhl.de", "https:/www.dhl.de");
|
|
429
|
+
this.setState("info.connection", true, true);
|
|
430
|
+
this.setState("auth.cookie", JSON.stringify(this.cookieJar.toJSON()), true);
|
|
431
|
+
await this.createDHLStates();
|
|
432
|
+
return true;
|
|
433
|
+
})
|
|
434
|
+
.catch((error) => {
|
|
435
|
+
this.log.error(error);
|
|
436
|
+
if (error.response) {
|
|
437
|
+
this.log.error(JSON.stringify(error.response.data));
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
}
|
|
146
441
|
async loginDHL() {
|
|
147
442
|
const mfaTokenState = await this.getStateAsync("auth.dhlMfaToken");
|
|
148
443
|
await this.requestClient({
|
|
@@ -1715,6 +2010,7 @@ class Parcel extends utils.Adapter {
|
|
|
1715
2010
|
IN_TRANSIT: this.delivery_status.IN_TRANSIT,
|
|
1716
2011
|
OUT_FOR_DELIVERY: this.delivery_status.OUT_FOR_DELIVERY,
|
|
1717
2012
|
DELIVERED: this.delivery_status.DELIVERED,
|
|
2013
|
+
PICKED_UP: this.delivery_status.DELIVERED,
|
|
1718
2014
|
};
|
|
1719
2015
|
if (amz_status[sendung.detailedState.shortStatus] !== undefined) {
|
|
1720
2016
|
return amz_status[sendung.detailedState.shortStatus];
|
|
@@ -1799,7 +2095,7 @@ class Parcel extends utils.Adapter {
|
|
|
1799
2095
|
withCredentials: true,
|
|
1800
2096
|
})
|
|
1801
2097
|
.then(async (res) => {
|
|
1802
|
-
this.log.debug(JSON.stringify(res.data));
|
|
2098
|
+
// this.log.debug(JSON.stringify(res.data));
|
|
1803
2099
|
|
|
1804
2100
|
const dom = new JSDOM(res.data);
|
|
1805
2101
|
const document = dom.window.document;
|
|
@@ -1857,7 +2153,7 @@ class Parcel extends utils.Adapter {
|
|
|
1857
2153
|
},
|
|
1858
2154
|
})
|
|
1859
2155
|
.then(async (res) => {
|
|
1860
|
-
this.log.debug(JSON.stringify(res.data));
|
|
2156
|
+
// this.log.debug(JSON.stringify(res.data));
|
|
1861
2157
|
const dom = new JSDOM(res.data);
|
|
1862
2158
|
const document = dom.window.document;
|
|
1863
2159
|
const statusHandle =
|
|
@@ -1878,7 +2174,7 @@ class Parcel extends utils.Adapter {
|
|
|
1878
2174
|
stopsStatus = stateObject.mapTracking.calloutMessage;
|
|
1879
2175
|
}
|
|
1880
2176
|
} catch (error) {
|
|
1881
|
-
this.log.error(
|
|
2177
|
+
this.log.error(error);
|
|
1882
2178
|
}
|
|
1883
2179
|
}
|
|
1884
2180
|
|
|
@@ -1945,25 +2241,27 @@ class Parcel extends utils.Adapter {
|
|
|
1945
2241
|
if (id === "dhl") {
|
|
1946
2242
|
await this.requestClient({
|
|
1947
2243
|
method: "post",
|
|
1948
|
-
url: "https://
|
|
1949
|
-
|
|
2244
|
+
url: "https://login.dhl.de/af5f9bb6-27ad-4af4-9445-008e7a5cddb8/login/token",
|
|
1950
2245
|
headers: {
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
"
|
|
1957
|
-
|
|
2246
|
+
Host: "login.dhl.de",
|
|
2247
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
2248
|
+
Accept: "application/json, text/plain, */*",
|
|
2249
|
+
Origin: "https://login.dhl.de",
|
|
2250
|
+
Connection: "keep-alive",
|
|
2251
|
+
"User-Agent": "DHLPaket_PROD/1367 CFNetwork/1240.0.4 Darwin/20.6.0",
|
|
2252
|
+
"Accept-Language": "de-de",
|
|
2253
|
+
},
|
|
2254
|
+
data: {
|
|
2255
|
+
client_id: "83471082-5c13-4fce-8dcb-19d2a3fca413",
|
|
2256
|
+
grant_type: "refresh_token",
|
|
2257
|
+
refresh_token: this.sessions["dhl"].refresh_token,
|
|
1958
2258
|
},
|
|
1959
|
-
data: JSON.stringify({
|
|
1960
|
-
force: false,
|
|
1961
|
-
meta: this.sessions["dhl"].meta,
|
|
1962
|
-
}),
|
|
1963
2259
|
})
|
|
1964
|
-
.then((res) => {
|
|
2260
|
+
.then(async (res) => {
|
|
1965
2261
|
this.log.debug(JSON.stringify(res.data));
|
|
1966
2262
|
this.sessions["dhl"] = res.data;
|
|
2263
|
+
await this.cookieJar.setCookie("dhli=" + res.data.id_token + "; path=/; domain=dhl.de", "https:/dhl.de");
|
|
2264
|
+
await this.cookieJar.setCookie("dhli=" + res.data.id_token + "; path=/; domain=www.dhl.de", "https:/www.dhl.de");
|
|
1967
2265
|
this.setState("auth.cookie", JSON.stringify(this.cookieJar.toJSON()), true);
|
|
1968
2266
|
this.setState("info.connection", true, true);
|
|
1969
2267
|
})
|
|
@@ -2085,17 +2383,26 @@ class Parcel extends utils.Adapter {
|
|
|
2085
2383
|
|
|
2086
2384
|
return matches;
|
|
2087
2385
|
}
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2386
|
+
randomString(length) {
|
|
2387
|
+
let result = "";
|
|
2388
|
+
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
2389
|
+
const charactersLength = characters.length;
|
|
2390
|
+
for (let i = 0; i < length; i++) {
|
|
2391
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
2392
|
+
}
|
|
2393
|
+
return result;
|
|
2394
|
+
}
|
|
2395
|
+
getCodeChallenge() {
|
|
2396
|
+
let hash = "";
|
|
2397
|
+
let result = "";
|
|
2398
|
+
const chars = "0123456789abcdef";
|
|
2399
|
+
result = "";
|
|
2400
|
+
for (let i = 64; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];
|
|
2401
|
+
hash = crypto.createHash("sha256").update(result).digest("base64");
|
|
2402
|
+
hash = hash.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
2403
|
+
|
|
2404
|
+
return [result, hash];
|
|
2405
|
+
}
|
|
2099
2406
|
/**
|
|
2100
2407
|
* Is called when adapter shuts down - callback has to be called under any circumstances!
|
|
2101
2408
|
* @param {() => void} callback
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.parcel",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.27",
|
|
4
4
|
"description": "Parcel tracking",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TA2k",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"url": "https://github.com/TA2k/ioBroker.parcel"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@iobroker/adapter-core": "^2.6.
|
|
29
|
-
"axios": "^1.
|
|
28
|
+
"@iobroker/adapter-core": "^2.6.8",
|
|
29
|
+
"axios": "^1.3.5",
|
|
30
30
|
"http-cookie-agent": "^5.0.2",
|
|
31
|
-
"jsdom": "^
|
|
31
|
+
"jsdom": "^21.1.1",
|
|
32
32
|
"json-bigint": "^1.0.0",
|
|
33
|
-
"qs": "^6.11.
|
|
33
|
+
"qs": "^6.11.1",
|
|
34
34
|
"tough-cookie": "^4.1.2",
|
|
35
35
|
"uuid": "^9.0.0"
|
|
36
36
|
},
|
|
@@ -40,18 +40,18 @@
|
|
|
40
40
|
"@types/chai-as-promised": "^7.1.5",
|
|
41
41
|
"@types/gulp": "^4.0.10",
|
|
42
42
|
"@types/mocha": "^10.0.1",
|
|
43
|
-
"@types/node": "^18.11
|
|
43
|
+
"@types/node": "^18.15.11",
|
|
44
44
|
"@types/proxyquire": "^1.3.28",
|
|
45
45
|
"@types/sinon": "^10.0.13",
|
|
46
46
|
"@types/sinon-chai": "^3.2.9",
|
|
47
47
|
"chai": "^4.3.7",
|
|
48
48
|
"chai-as-promised": "^7.1.1",
|
|
49
|
-
"eslint": "^8.
|
|
49
|
+
"eslint": "^8.38.0",
|
|
50
50
|
"mocha": "^10.2.0",
|
|
51
51
|
"proxyquire": "^2.1.3",
|
|
52
|
-
"sinon": "^15.0.
|
|
52
|
+
"sinon": "^15.0.3",
|
|
53
53
|
"sinon-chai": "^3.7.0",
|
|
54
|
-
"typescript": "~
|
|
54
|
+
"typescript": "~5.0.4"
|
|
55
55
|
},
|
|
56
56
|
"main": "main.js",
|
|
57
57
|
"files": [
|