iobroker.parcel 0.2.8 → 0.2.10

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/README.md CHANGED
@@ -62,6 +62,11 @@ Den Datenpunkt parcel.0.dhl.briefe....image ein "String img src" element als Obj
62
62
  <https://forum.iobroker.net/topic/51795/test-adapter-parcel-paketverfolgung-dhl-v0-0-1>
63
63
 
64
64
  ## Changelog
65
+ ### 0.2.10 (2025-01-15)
66
+
67
+ - add alternative way for dhl login
68
+ - move dhl connections error to info level
69
+
65
70
  ### 0.2.8 (2024-10-18)
66
71
 
67
72
  - fix amazon login
Binary file
@@ -118,6 +118,33 @@
118
118
  <label for="dhlMfa" class="translate">SMS/Mail Pin nach erstem Start</label>
119
119
  </div>
120
120
  </div>
121
+ <div class="row">
122
+ <div class="col s6 input-field" id="captchaResponse">
123
+ If normal login is not working alternate DHL login method is available
124
+ <p></p>
125
+ 1. Open the Url below in Chrome and login with your account
126
+ <p></p>
127
+ 2. Open Developer Console F12 or Option + Command + I
128
+ <p></p>
129
+ 3. You see a failed redirect in the Console copy the dhllogin:// url
130
+ <p></p>
131
+ <img src="copyurl.png" style="width: 30rem" />
132
+ <p></p>
133
+ 4. Paste the url in the input field below
134
+
135
+ <p></p>
136
+ <p></p>
137
+ <a
138
+ href="https://login.dhl.de/af5f9bb6-27ad-4af4-9445-008e7a5cddb8/login/authorize?redirect_uri=dhllogin://de.deutschepost.dhl/login&state=eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9&client_id=83471082-5c13-4fce-8dcb-19d2a3fca413&response_type=code&scope=openid%20offline_access&claims=%7B%22id_token%22:%7B%22email%22:null,%22post_number%22:null,%22twofa%22:null,%22service_mask%22:null,%22deactivate_account%22:null,%22last_login%22:null,%22customer_type%22:null,%22display_name%22:null,%22data_confirmation_required%22:null%7D%7D&nonce=&login_hint=&prompt=login&ui_locales=de-DE&code_challenge=MAhrhXXZP-Owy-R7ruyB7Fn-Z8ODW6qxCoHg4uXELCw&code_challenge_method=S256"
139
+ target="_blank"
140
+ style="color: red !important"
141
+ >DHL Login Url CLICK HERE</a
142
+ >
143
+ <p></p>
144
+ <input type="text" class="value" id="dhlCode" placeholder="dhllogin://de.deutschepost.dhl/login?code=Jqbzy3wbJ..." />
145
+ <label for="dhlCode" class="translate">dhllogin Url</label>
146
+ </div>
147
+ </div>
121
148
  <div class="row">
122
149
  <div class="col"><h5>Amazon</h5></div>
123
150
  </div>
package/io-package.json CHANGED
@@ -1,8 +1,34 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "parcel",
4
- "version": "0.2.8",
4
+ "version": "0.2.10",
5
5
  "news": {
6
+ "0.2.10": {
7
+ "en": "add alternative way for dhl login\nmove dhl connections error to info level",
8
+ "de": "alternative möglichkeit für dhl anmelden\ndhl-verbindungen fehler auf info-ebene verschieben",
9
+ "ru": "добавить альтернативный способ dhl login\nперенести ошибку подключений dhl на уровень информации",
10
+ "pt": "adicionar maneira alternativa para dhl login\nmover erro de conexões dhl para nível de informação",
11
+ "nl": "alternatieve manier toevoegen voor dhl login\ndhl-verbindingsfout naar infoniveau verplaatsen",
12
+ "fr": "ajouter une autre façon pour la connexion dhl\ndéplacer l'erreur de connexions dhl au niveau info",
13
+ "it": "aggiungere modo alternativo per il login dhl\nspostare l'errore di connessioni dhl a livello info",
14
+ "es": "añadir la forma alternativa para dhl login\nmovimiento dhl conexiones error a nivel de información",
15
+ "pl": "dodaj alternatywny sposób logowania dhl\nprzenieść błąd połączeń dhl do poziomu informacji",
16
+ "uk": "додати альтернативний спосіб для входу в систему\nперемістити помилки з'єднанням dhl на інформаційний рівень",
17
+ "zh-cn": "添加 dhl 登录的替代方式\n将 dhl 连接错误移动到信息级别"
18
+ },
19
+ "0.2.9": {
20
+ "en": "add alternative way for dhl login\nmove dhl connections error to info level",
21
+ "de": "alternative möglichkeit für dhl login\ndhl verbindungsfehler auf info level verschoben",
22
+ "ru": "добавить альтернативный способ dhl login\nперенести ошибку подключений dhl на уровень информации",
23
+ "pt": "adicionar maneira alternativa para dhl login\nmover erro de conexões dhl para nível de informação",
24
+ "nl": "alternatieve manier toevoegen voor dhl login\ndhl-verbindingsfout naar infoniveau verplaatsen",
25
+ "fr": "ajouter une autre façon pour la connexion dhl\ndéplacer l'erreur de connexions dhl au niveau info",
26
+ "it": "aggiungere modo alternativo per il login dhl\nspostare l'errore di connessioni dhl a livello info",
27
+ "es": "añadir la forma alternativa para dhl login\nmovimiento dhl conexiones error a nivel de información",
28
+ "pl": "dodaj alternatywny sposób logowania dhl\nprzenieść błąd połączeń dhl do poziomu informacji",
29
+ "uk": "додати альтернативний спосіб для входу в систему\nперемістити помилки з'єднанням dhl на інформаційний рівень",
30
+ "zh-cn": "添加 dhl 登录的替代方式\n将 dhl 连接错误移动到信息级别"
31
+ },
6
32
  "0.2.8": {
7
33
  "en": "fix amazon login",
8
34
  "de": "fix amazon login",
@@ -40,14 +66,6 @@
40
66
  "0.2.2": {
41
67
  "en": "Improvment for Amazon Login and fix for Briefaanündigung Image",
42
68
  "de": "Verbesserung für Amazon Login und Fix für Briefankündigung Image State"
43
- },
44
- "0.2.1": {
45
- "en": "Fix for Briefankündigung",
46
- "de": "Briefankündigung wieder aktiviert"
47
- },
48
- "0.1.6": {
49
- "en": "Fix DHL and UPS",
50
- "de": "DHL und UPS gefixt"
51
69
  }
52
70
  },
53
71
  "title": "Parcel tracking",
@@ -168,6 +186,7 @@
168
186
  "dpdpassword": "",
169
187
  "dhlusername": "",
170
188
  "dhlpassword": "",
189
+ "dhlCode": "",
171
190
  "dhlMfa": "",
172
191
  "17trackKey": "",
173
192
  "sendToActive": false,
package/main.js CHANGED
@@ -85,7 +85,15 @@ class Parcel extends utils.Adapter {
85
85
 
86
86
  if (this.config.dhlusername && this.config.dhlpassword) {
87
87
  this.log.info('Login to DHL');
88
- await this.loginDhlNew();
88
+ const dhlSessionState = await this.getStateAsync('auth.dhlSession');
89
+ if (dhlSessionState && dhlSessionState.val) {
90
+ this.log.info('Use existing DHL session. If this fails please delete auth.dhlSession');
91
+ this.sessions['dhl'] = JSON.parse(dhlSessionState.val);
92
+ await this.refreshToken();
93
+ await this.createDHLStates();
94
+ } else {
95
+ await this.loginDhlNew();
96
+ }
89
97
  }
90
98
 
91
99
  if (this.config.dpdusername && this.config.dpdpassword) {
@@ -163,241 +171,248 @@ class Parcel extends utils.Adapter {
163
171
  // this.setState("info.connection", true, true);
164
172
  // return;
165
173
  // }
166
-
167
- const [code_verifier, codeChallenge] = this.getCodeChallenge();
168
-
174
+ //https://login.dhl.de/af5f9bb6-27ad-4af4-9445-008e7a5cddb8/login/authorize?redirect_uri=dhllogin://de.deutschepost.dhl/login&state=eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9&client_id=83471082-5c13-4fce-8dcb-19d2a3fca413&response_type=code&scope=openid%20offline_access&claims=%7B%22id_token%22:%7B%22email%22:null,%22post_number%22:null,%22twofa%22:null,%22service_mask%22:null,%22deactivate_account%22:null,%22last_login%22:null,%22customer_type%22:null,%22display_name%22:null,%22data_confirmation_required%22:null%7D%7D&nonce=&login_hint=&prompt=login&ui_locales=de-DE&code_challenge=MAhrhXXZP-Owy-R7ruyB7Fn-Z8ODW6qxCoHg4uXELCw&code_challenge_method=S256
175
+ //eslint-disable-next-line
176
+ let [code_verifier, codeChallenge] = this.getCodeChallenge();
177
+ let codeUrl = '';
169
178
  const transactionId = this.randomString(40);
170
- const initUrl = await this.requestClient({
171
- method: 'get',
172
- maxBodyLength: Infinity,
173
- url: 'https://login.dhl.de/af5f9bb6-27ad-4af4-9445-008e7a5cddb8/login/authorize',
174
- params: {
175
- redirect_uri: 'dhllogin://de.deutschepost.dhl/login',
176
- state:
177
- 'eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9',
178
- client_id: '83471082-5c13-4fce-8dcb-19d2a3fca413',
179
- response_type: 'code',
180
- scope: 'openid offline_access',
181
- claims:
182
- '{"id_token":{"email":null,"post_number":null,"twofa":null,"service_mask":null,"deactivate_account":null,"last_login":null,"customer_type":null,"display_name":null}}',
183
- nonce: '',
184
- login_hint: '',
185
- prompt: 'login',
186
- ui_locales: 'de-DE',
187
- code_challenge: codeChallenge,
188
- code_challenge_method: 'S256"',
189
- },
190
- headers: {
191
- Host: 'login.dhl.de',
192
- Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
179
+ if (!this.config.dhlCode || !this.config.dhlCode.startsWith('dhllogin://')) {
180
+ const initUrl = await this.requestClient({
181
+ method: 'get',
182
+ maxBodyLength: Infinity,
183
+ url: 'https://login.dhl.de/af5f9bb6-27ad-4af4-9445-008e7a5cddb8/login/authorize',
184
+ params: {
185
+ redirect_uri: 'dhllogin://de.deutschepost.dhl/login',
186
+ state:
187
+ 'eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9',
188
+ client_id: '83471082-5c13-4fce-8dcb-19d2a3fca413',
189
+ response_type: 'code',
190
+ scope: 'openid offline_access',
191
+ claims:
192
+ '{"id_token":{"email":null,"post_number":null,"twofa":null,"service_mask":null,"deactivate_account":null,"last_login":null,"customer_type":null,"display_name":null}}',
193
+ nonce: '',
194
+ login_hint: '',
195
+ prompt: 'login',
196
+ ui_locales: 'de-DE',
197
+ code_challenge: 'dDp31yHNMAGZeMSXeoOK66WOZOtkZjqYzpdZnfbWZfQ',
198
+ code_challenge_method: 'S256"',
199
+ },
200
+ headers: {
201
+ Host: 'login.dhl.de',
202
+ Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
193
203
 
194
- 'User-Agent':
195
- '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',
196
- 'Accept-Language': 'de-de',
197
- Connection: 'keep-alive',
198
- },
199
- })
200
- .then(async (res) => {
201
- // this.log.debug(res.data);
202
- return res.request.path;
204
+ 'User-Agent':
205
+ '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',
206
+ 'Accept-Language': 'de-de',
207
+ Connection: 'keep-alive',
208
+ },
203
209
  })
204
- .catch((error) => {
205
- this.log.error(error);
206
- error.response && this.log.error(JSON.stringify(error.response.data));
207
- });
208
- const initParams = qs.parse(initUrl.split('?')[1]);
209
- const signin = await this.requestClient({
210
- method: 'post',
211
- maxBodyLength: Infinity,
212
- url: 'https://login-api.dhl.de/widget/traditional_signin.jsonp',
213
- headers: {
214
- Host: 'login-api.dhl.de',
215
- 'Content-Type': 'application/x-www-form-urlencoded',
216
- Origin: 'https://login.dhl.de',
217
- Connection: 'keep-alive',
218
- Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
219
- 'User-Agent':
220
- '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',
221
- Referer: 'https://login.dhl.de/',
222
- 'Accept-Language': 'de-de',
223
- },
224
- data: {
225
- utf8: '',
226
- capture_screen: 'signIn',
227
- js_version: 'd445bf4',
228
- capture_transactionId: transactionId,
229
- form: 'signInForm',
230
- flow: 'ciam_flow_001',
231
- client_id: 'f8s9584t9f9kz5wg9agkp259hc924uq9',
232
- redirect_uri: 'https://login.dhl.de' + initUrl,
233
- response_type: 'token',
234
- flow_version: '20230309140056615616',
235
- settings_version: '',
236
- locale: 'de-DE',
237
- recaptchaVersion: '2',
238
- emailOrPostNumber: this.config.dhlusername,
239
- currentPassword: this.config.dhlpassword,
240
- },
241
- })
242
- .then(async (res) => {
243
- this.log.debug(res.data);
244
- return true;
210
+ .then(async (res) => {
211
+ // this.log.debug(res.data);
212
+ return res.request.path;
213
+ })
214
+ .catch((error) => {
215
+ this.log.error(error);
216
+ error.response && this.log.error(JSON.stringify(error.response.data));
217
+ });
218
+ const initParams = qs.parse(initUrl.split('?')[1]);
219
+ const signin = await this.requestClient({
220
+ method: 'post',
221
+ maxBodyLength: Infinity,
222
+ url: 'https://login-api.dhl.de/widget/traditional_signin.jsonp',
223
+ headers: {
224
+ Host: 'login-api.dhl.de',
225
+ 'Content-Type': 'application/x-www-form-urlencoded',
226
+ Origin: 'https://login.dhl.de',
227
+ Connection: 'keep-alive',
228
+ Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
229
+ 'User-Agent':
230
+ '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',
231
+ Referer: 'https://login.dhl.de/',
232
+ 'Accept-Language': 'de-de',
233
+ },
234
+ data: {
235
+ utf8: '',
236
+ capture_screen: 'signIn',
237
+ js_version: 'd445bf4',
238
+ capture_transactionId: transactionId,
239
+ form: 'signInForm',
240
+ flow: 'ciam_flow_001',
241
+ client_id: 'f8s9584t9f9kz5wg9agkp259hc924uq9',
242
+ redirect_uri: 'https://login.dhl.de' + initUrl,
243
+ response_type: 'token',
244
+ flow_version: '20230309140056615616',
245
+ settings_version: '',
246
+ locale: 'de-DE',
247
+ recaptchaVersion: '2',
248
+ emailOrPostNumber: this.config.dhlusername,
249
+ currentPassword: this.config.dhlpassword,
250
+ },
245
251
  })
246
- .catch((error) => {
247
- this.log.error(error);
248
- error.response && this.log.error(JSON.stringify(error.response.data));
249
- });
250
- if (!signin) {
251
- this.log.error('DHL Signin failed');
252
- return;
253
- }
254
- const preSession = await this.requestClient({
255
- method: 'get',
256
- maxBodyLength: Infinity,
257
- url: 'https://login-api.dhl.de/widget/get_result.jsonp?transactionId=' + transactionId + '&cache=' + Date.now(),
258
- headers: {
259
- Host: 'login-api.dhl.de',
260
- Connection: 'keep-alive',
261
- Accept: '*/*',
262
- 'User-Agent':
263
- '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',
264
- 'Accept-Language': 'de-de',
265
- Referer: 'https://login.dhl.de/',
266
- },
267
- })
268
- .then(async (res) => {
269
- this.log.debug(res.data);
270
- return JSON.parse(res.data.split(')(')[1].split(');')[0]);
252
+ .then(async (res) => {
253
+ this.log.debug(res.data);
254
+ return true;
255
+ })
256
+ .catch((error) => {
257
+ this.log.error(error);
258
+ error.response && this.log.error(JSON.stringify(error.response.data));
259
+ });
260
+ if (!signin) {
261
+ this.log.error('DHL Signin failed');
262
+ return;
263
+ }
264
+ const preSession = await this.requestClient({
265
+ method: 'get',
266
+ maxBodyLength: Infinity,
267
+ url: 'https://login-api.dhl.de/widget/get_result.jsonp?transactionId=' + transactionId + '&cache=' + Date.now(),
268
+ headers: {
269
+ Host: 'login-api.dhl.de',
270
+ Connection: 'keep-alive',
271
+ Accept: '*/*',
272
+ 'User-Agent':
273
+ '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',
274
+ 'Accept-Language': 'de-de',
275
+ Referer: 'https://login.dhl.de/',
276
+ },
271
277
  })
272
- .catch((error) => {
273
- this.log.error(error);
274
- error.response && this.log.error(JSON.stringify(error.response.data));
275
- });
276
- if (!preSession || !preSession.result) {
277
- this.log.error('DHL PreSession failed. Please check username password');
278
- return;
279
- }
280
- const accessToken2 = await this.requestClient({
281
- method: 'post',
282
- maxBodyLength: Infinity,
283
- url: 'https://login.dhl.de/af5f9bb6-27ad-4af4-9445-008e7a5cddb8/auth-ui/token-url',
284
- params: {
285
- __aic_csrf: initParams.__aic_csrf,
286
- claims:
287
- '{"id_token":{"customer_type":null,"deactivate_account":null,"display_name":null,"email":null,"last_login":null,"post_number":null,"service_mask":null,"twofa":null}}',
288
- client_id: '83471082-5c13-4fce-8dcb-19d2a3fca413',
289
- code_challenge: codeChallenge,
290
- code_challenge_method: 'S256',
291
- login_hint: '',
292
- nonce: '',
293
- prompt: 'login',
294
- redirect_uri: 'dhllogin://de.deutschepost.dhl/login',
295
- response_type: 'code',
296
- scope: 'openid',
297
- state:
298
- 'eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9',
299
- ui_locales: 'de-DE",',
300
- },
301
- headers: {
302
- Host: 'login.dhl.de',
303
- 'Content-Type': 'application/x-www-form-urlencoded',
304
- Origin: 'https://login.dhl.de',
305
- Connection: 'keep-alive',
306
- Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
307
- 'User-Agent':
308
- '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',
309
- 'Accept-Language': 'de-de',
310
- },
311
- data: {
312
- screen: 'signIn',
313
- authenticated: 'True',
314
- registering: 'False',
315
- accessToken: preSession.result.accessToken,
316
- _csrf_token: this.cookieJar.store.idx['login.dhl.de']['/']._csrf_token.value,
317
- },
318
- })
319
- .then(async (res) => {
320
- // this.log.debug(res.data);
321
-
322
- return res.data.split("existingToken: '")[1].split("'")[0];
278
+ .then(async (res) => {
279
+ this.log.debug(res.data);
280
+ return JSON.parse(res.data.split(')(')[1].split(');')[0]);
281
+ })
282
+ .catch((error) => {
283
+ this.log.error(error);
284
+ error.response && this.log.error(JSON.stringify(error.response.data));
285
+ });
286
+ if (!preSession || !preSession.result) {
287
+ this.log.error('DHL PreSession failed. Please check username password');
288
+ return;
289
+ }
290
+ const accessToken2 = await this.requestClient({
291
+ method: 'post',
292
+ maxBodyLength: Infinity,
293
+ url: 'https://login.dhl.de/af5f9bb6-27ad-4af4-9445-008e7a5cddb8/auth-ui/token-url',
294
+ params: {
295
+ __aic_csrf: initParams.__aic_csrf,
296
+ claims:
297
+ '{"id_token":{"customer_type":null,"deactivate_account":null,"display_name":null,"email":null,"last_login":null,"post_number":null,"service_mask":null,"twofa":null}}',
298
+ client_id: '83471082-5c13-4fce-8dcb-19d2a3fca413',
299
+ code_challenge: codeChallenge,
300
+ code_challenge_method: 'S256',
301
+ login_hint: '',
302
+ nonce: '',
303
+ prompt: 'login',
304
+ redirect_uri: 'dhllogin://de.deutschepost.dhl/login',
305
+ response_type: 'code',
306
+ scope: 'openid',
307
+ state:
308
+ 'eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9',
309
+ ui_locales: 'de-DE",',
310
+ },
311
+ headers: {
312
+ Host: 'login.dhl.de',
313
+ 'Content-Type': 'application/x-www-form-urlencoded',
314
+ Origin: 'https://login.dhl.de',
315
+ Connection: 'keep-alive',
316
+ Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
317
+ 'User-Agent':
318
+ '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',
319
+ 'Accept-Language': 'de-de',
320
+ },
321
+ data: {
322
+ screen: 'signIn',
323
+ authenticated: 'True',
324
+ registering: 'False',
325
+ accessToken: preSession.result.accessToken,
326
+ _csrf_token: this.cookieJar.store.idx['login.dhl.de']['/']._csrf_token.value,
327
+ },
323
328
  })
324
- .catch((error) => {
325
- this.log.error(error);
326
- error.response && this.log.error(JSON.stringify(error.response.data));
327
- });
328
- const idtoken = await this.requestClient({
329
- method: 'post',
330
- maxBodyLength: Infinity,
331
- url: 'https://login.dhl.de/af5f9bb6-27ad-4af4-9445-008e7a5cddb8/auth-ui/token-url',
332
- maxRedirects: 0,
333
- params: {
334
- __aic_csrf: initParams.__aic_csrf,
335
- claims:
336
- '{"id_token":{"customer_type":null,"deactivate_account":null,"display_name":null,"email":null,"last_login":null,"post_number":null,"service_mask":null,"twofa":null}}',
337
- client_id: '83471082-5c13-4fce-8dcb-19d2a3fca413',
338
- code_challenge: codeChallenge,
339
- code_challenge_method: 'S256',
340
- login_hint: '',
341
- nonce: '',
342
- prompt: 'login',
343
- redirect_uri: 'dhllogin://de.deutschepost.dhl/login',
344
- response_type: 'code',
345
- scope: 'openid',
346
- state:
347
- 'eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9',
348
- ui_locales: 'de-DE',
349
- },
350
- headers: {
351
- Host: 'login.dhl.de',
352
- 'Content-Type': 'application/x-www-form-urlencoded',
353
- Origin: 'https://login.dhl.de',
354
- Connection: 'keep-alive',
355
- Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
356
- 'User-Agent':
357
- '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',
358
- 'Accept-Language': 'de-de',
359
- },
360
- data: {
361
- screen: 'loginSuccess',
362
- accessToken: accessToken2,
363
- _csrf_token: this.cookieJar.store.idx['login.dhl.de']['/']._csrf_token.value,
364
- },
365
- })
366
- .then(async (res) => {
367
- this.log.debug(res.data);
368
- return res.data;
329
+ .then(async (res) => {
330
+ // this.log.debug(res.data);
331
+
332
+ return res.data.split("existingToken: '")[1].split("'")[0];
333
+ })
334
+ .catch((error) => {
335
+ this.log.error(error);
336
+ error.response && this.log.error(JSON.stringify(error.response.data));
337
+ });
338
+ const idtoken = await this.requestClient({
339
+ method: 'post',
340
+ maxBodyLength: Infinity,
341
+ url: 'https://login.dhl.de/af5f9bb6-27ad-4af4-9445-008e7a5cddb8/auth-ui/token-url',
342
+ maxRedirects: 0,
343
+ params: {
344
+ __aic_csrf: initParams.__aic_csrf,
345
+ claims:
346
+ '{"id_token":{"customer_type":null,"deactivate_account":null,"display_name":null,"email":null,"last_login":null,"post_number":null,"service_mask":null,"twofa":null}}',
347
+ client_id: '83471082-5c13-4fce-8dcb-19d2a3fca413',
348
+ code_challenge: codeChallenge,
349
+ code_challenge_method: 'S256',
350
+ login_hint: '',
351
+ nonce: '',
352
+ prompt: 'login',
353
+ redirect_uri: 'dhllogin://de.deutschepost.dhl/login',
354
+ response_type: 'code',
355
+ scope: 'openid',
356
+ state:
357
+ 'eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9',
358
+ ui_locales: 'de-DE',
359
+ },
360
+ headers: {
361
+ Host: 'login.dhl.de',
362
+ 'Content-Type': 'application/x-www-form-urlencoded',
363
+ Origin: 'https://login.dhl.de',
364
+ Connection: 'keep-alive',
365
+ Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
366
+ 'User-Agent':
367
+ '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',
368
+ 'Accept-Language': 'de-de',
369
+ },
370
+ data: {
371
+ screen: 'loginSuccess',
372
+ accessToken: accessToken2,
373
+ _csrf_token: this.cookieJar.store.idx['login.dhl.de']['/']._csrf_token.value,
374
+ },
369
375
  })
370
- .catch((error) => {
371
- if (error.response && error.response.status === 302) {
372
- return error.response.headers.location.split('id_token_hint=')[1].split('&')[0];
373
- }
374
- this.log.error(error);
375
- error.response && this.log.error(JSON.stringify(error.response.data));
376
- });
377
- const codeUrl = await this.requestClient({
378
- method: 'get',
379
- maxBodyLength: Infinity,
380
- url:
381
- '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=' +
382
- codeChallenge +
383
- '&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=' +
384
- idtoken,
385
- })
386
- .then(async (res) => {
387
- this.log.debug(JSON.stringify(res.data));
376
+ .then(async (res) => {
377
+ this.log.debug(res.data);
378
+ return res.data;
379
+ })
380
+ .catch((error) => {
381
+ if (error.response && error.response.status === 302) {
382
+ return error.response.headers.location.split('id_token_hint=')[1].split('&')[0];
383
+ }
384
+ this.log.error(error);
385
+ error.response && this.log.error(JSON.stringify(error.response.data));
386
+ });
387
+ codeUrl = await this.requestClient({
388
+ method: 'get',
389
+ maxBodyLength: Infinity,
390
+ url:
391
+ '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=' +
392
+ codeChallenge +
393
+ '&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=' +
394
+ idtoken,
388
395
  })
389
- .catch((error) => {
390
- if (error.message.includes('Unsupported protocol')) {
391
- return qs.parse(error.request._options.query);
392
- }
393
- this.log.error(error);
394
- if (error.response) {
395
- this.log.error(JSON.stringify(error.response.data));
396
- }
397
- });
398
- if (!codeUrl) {
399
- this.log.error('DHL codeUrl failed');
400
- return;
396
+ .then(async (res) => {
397
+ this.log.debug(JSON.stringify(res.data));
398
+ })
399
+ .catch((error) => {
400
+ if (error.message.includes('Unsupported protocol')) {
401
+ return qs.parse(error.request._options.query);
402
+ }
403
+ this.log.error(error);
404
+ if (error.response) {
405
+ this.log.error(JSON.stringify(error.response.data));
406
+ }
407
+ });
408
+ if (!codeUrl) {
409
+ this.log.error('DHL codeUrl failed');
410
+ return;
411
+ }
412
+ }
413
+ if (this.config.dhlCode && this.config.dhlCode.startsWith('dhllogin://')) {
414
+ codeUrl = qs.parse(this.config.dhlCode.split('?')[1]);
415
+ code_verifier = 'zmVs5AKfGvv45a9aUvuOid9a_erOirp7XL1sn9kWT_o';
401
416
  }
402
417
  await this.requestClient({
403
418
  method: 'post',
@@ -428,6 +443,18 @@ class Parcel extends utils.Adapter {
428
443
  this.setState('info.connection', true, true);
429
444
  this.setState('auth.cookie', JSON.stringify(this.cookieJar.toJSON()), true);
430
445
  await this.createDHLStates();
446
+ await this.extendObject('auth.dhlSession', {
447
+ type: 'state',
448
+ common: {
449
+ name: 'DHL Session',
450
+ type: 'string',
451
+ role: 'json',
452
+ read: true,
453
+ write: false,
454
+ },
455
+ native: {},
456
+ });
457
+ this.setState('auth.dhlSession', JSON.stringify(res.data), true);
431
458
  return true;
432
459
  })
433
460
  .catch((error) => {
@@ -572,7 +599,7 @@ class Parcel extends utils.Adapter {
572
599
  this.log.info('Login to DHL successful');
573
600
  this.sessions['dhl'] = res.data;
574
601
  this.setState('info.connection', true, true);
575
- this.setState('auth.cookie', JSON.stringify(this.cookieJar.toJSON()), true);
602
+
576
603
  await this.createDHLStates();
577
604
  })
578
605
  .catch(async (error) => {
@@ -786,7 +813,7 @@ class Parcel extends utils.Adapter {
786
813
  this.log.error(JSON.stringify(error.response.data));
787
814
  }
788
815
  });
789
- if (body.indexOf('untrusted-app-sign-in-continue-button-announce') !== -1) {
816
+ if (body && body.indexOf('untrusted-app-sign-in-continue-button-announce') !== -1) {
790
817
  this.log.info('Amazon untrustet app warning detected');
791
818
  const form = this.extractHidden(body);
792
819
  delete form['sessionChallengeAck'];
@@ -1520,9 +1547,13 @@ class Parcel extends utils.Adapter {
1520
1547
  return [];
1521
1548
  })
1522
1549
  .catch((error) => {
1523
- this.log.error('Failed to get https://www.dhl.de/int-verfolgen/data/search?noRedirect=true&language=de&cid=app');
1524
- this.log.error(error);
1525
- error.response && this.log.error(JSON.stringify(error.response.data));
1550
+ if (error.code === 'ECONNRESET' || error.code === 'ETIMEDOUT') {
1551
+ this.log.info('DHL is not available. Maybe the DHL service down or overloaded at the moment');
1552
+ } else {
1553
+ this.log.error('Failed to get https://www.dhl.de/int-verfolgen/data/search?noRedirect=true&language=de&cid=app');
1554
+ this.log.error(error);
1555
+ error.response && this.log.error(JSON.stringify(error.response.data));
1556
+ }
1526
1557
  return [];
1527
1558
  });
1528
1559
  }
@@ -2587,6 +2618,7 @@ class Parcel extends utils.Adapter {
2587
2618
  await this.cookieJar.setCookie('dhli=' + res.data.id_token + '; path=/; domain=dhl.de', 'https:/dhl.de');
2588
2619
  await this.cookieJar.setCookie('dhli=' + res.data.id_token + '; path=/; domain=www.dhl.de', 'https:/www.dhl.de');
2589
2620
  this.setState('auth.cookie', JSON.stringify(this.cookieJar.toJSON()), true);
2621
+ this.setState('auth.dhlSession', JSON.stringify(res.data), true);
2590
2622
  this.setState('info.connection', true, true);
2591
2623
  })
2592
2624
  .catch((error) => {
@@ -2721,13 +2753,19 @@ class Parcel extends utils.Adapter {
2721
2753
  * Is called when adapter shuts down - callback has to be called under any circumstances!
2722
2754
  * @param {() => void} callback
2723
2755
  */
2724
- onUnload(callback) {
2756
+ async onUnload(callback) {
2725
2757
  try {
2726
2758
  this.setState('info.connection', false, true);
2727
2759
  this.reLoginTimeout && clearTimeout(this.reLoginTimeout);
2728
2760
  this.refreshTokenTimeout && clearTimeout(this.refreshTokenTimeout);
2729
2761
  this.updateInterval && clearInterval(this.updateInterval);
2730
2762
  this.refreshTokenInterval && clearInterval(this.refreshTokenInterval);
2763
+ //get adapter settings and set captcha to null
2764
+ if (this.config.dhlCode) {
2765
+ const adapterSettings = await this.getForeignObjectAsync('system.adapter.' + this.namespace);
2766
+ adapterSettings.native.dhlCode = null;
2767
+ await this.setForeignObjectAsync('system.adapter.' + this.namespace, adapterSettings);
2768
+ }
2731
2769
  callback();
2732
2770
  } catch (e) {
2733
2771
  this.log.error('Error onUnload: ' + e);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.parcel",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "description": "Parcel tracking",
5
5
  "author": {
6
6
  "name": "TA2k",
@@ -25,27 +25,27 @@
25
25
  "url": "https://github.com/TA2k/ioBroker.parcel"
26
26
  },
27
27
  "dependencies": {
28
- "@iobroker/adapter-core": "^3.2.2",
29
- "axios": "^1.7.7",
30
- "http-cookie-agent": "^6.0.6",
28
+ "@iobroker/adapter-core": "^3.2.3",
29
+ "axios": "^1.7.9",
30
+ "http-cookie-agent": "^6.0.8",
31
31
  "jsdom": "^25.0.1",
32
- "json2iob": "^2.6.12",
33
- "qs": "^6.13.0",
34
- "tough-cookie": "^5.0.0",
35
- "uuid": "^10.0.0"
32
+ "json2iob": "^2.6.13",
33
+ "qs": "^6.14.0",
34
+ "tough-cookie": "^5.1.0",
35
+ "uuid": "^11.0.5"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@alcalzone/release-script": "^3.8.0",
39
39
  "@alcalzone/release-script-plugin-iobroker": "^3.7.2",
40
40
  "@alcalzone/release-script-plugin-license": "^3.7.0",
41
41
  "@alcalzone/release-script-plugin-manual-review": "^3.7.0",
42
- "@eslint/eslintrc": "^3.1.0",
43
- "@eslint/js": "^9.12.0",
42
+ "@eslint/eslintrc": "^3.2.0",
43
+ "@eslint/js": "^9.18.0",
44
44
  "@iobroker/testing": "^5.0.0",
45
- "@types/node": "^22.7.6",
46
- "eslint": "^9.12.0",
47
- "globals": "^15.11.0",
48
- "typescript": "~5.6.3"
45
+ "@types/node": "^22.10.6",
46
+ "eslint": "^9.18.0",
47
+ "globals": "^15.14.0",
48
+ "typescript": "~5.7.3"
49
49
  },
50
50
  "main": "main.js",
51
51
  "files": [