iobroker.google-sharedlocations2 0.3.2 → 0.3.3

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
@@ -27,6 +27,9 @@ Copyright and trademark of Google are property of Google.
27
27
  Placeholder for the next version (at the beginning of the line):
28
28
  ### **WORK IN PROGRESS**
29
29
  -->
30
+ ### 0.3.3 (2026-02-17)
31
+ * (Garfonso) if deleting cookies, also delete cookies in Browser to force login with username & password.
32
+
30
33
  ### 0.3.2 (2026-02-09)
31
34
  * (Garfonso) refresh with browser ignores cookies from adapter
32
35
 
package/io-package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "google-sharedlocations2",
4
- "version": "0.3.2",
4
+ "version": "0.3.3",
5
5
  "news": {
6
+ "0.3.3": {
7
+ "en": "if deleting cookies, also delete cookies in Browser to force login with username & password.",
8
+ "de": "wenn Sie Cookies löschen, löschen Sie auch Cookies im Browser, um die Anmeldung mit Benutzername & Passwort zu zwingen.",
9
+ "ru": "при удалении файлов cookie также удаляйте файлы cookie в браузере, чтобы заставить войти в систему с именем пользователя и паролем.",
10
+ "pt": "se excluir cookies, também excluir cookies no Navegador para forçar login com nome de usuário e senha.",
11
+ "nl": "als u cookies verwijdert, verwijdert u ook cookies in de browser om inloggen met gebruikersnaam en wachtwoord te forceren.",
12
+ "fr": "si vous supprimez les cookies, supprimez également les cookies dans le navigateur pour forcer la connexion avec le nom d'utilisateur et le mot de passe.",
13
+ "it": "se la cancellazione dei cookie, anche eliminare i cookie in Browser per forzare il login con nome utente e password.",
14
+ "es": "si elimina las cookies, también eliminar las cookies en Browser para forzar el login con el nombre de usuario & contraseña.",
15
+ "pl": "jeśli usuniesz pliki cookie, usuń je również w przeglądarce, aby wymusić logowanie z nazwą użytkownika i hasłem.",
16
+ "uk": "якщо видаліть файли cookie, також видаліть файли cookie у браузері, щоб захистити логін з ім'ям користувача та паролем.",
17
+ "zh-cn": "如果删除 cookie, 也可以在浏览器中删除 cookie, 以强制用户名和密码登录 ."
18
+ },
6
19
  "0.3.2": {
7
20
  "en": "refresh with browser ignores cookies from adapter",
8
21
  "de": "mit browser aktualisieren ignoriert cookies vom adapter",
@@ -80,19 +93,6 @@
80
93
  "pl": "dodane: wsparcie dla miejsc\ndodane: wsparcie dla ogrodzeń\nspróbuj zapobiec logowaniu jak najwięcej.",
81
94
  "uk": "додано: підтримка місць\nдоданий: підтримка парканів\nнамагатися попередити логін якомога простіше.",
82
95
  "zh-cn": "添加:对位置的支持\n添加:支持围栏\n尽量防止登录."
83
- },
84
- "0.0.3": {
85
- "en": "prevent login if no username and password is set\nfix tests",
86
- "de": "verhindern login, wenn kein benutzername und passwort eingestellt ist\ntests repariert",
87
- "ru": "предотвратить вход в систему, если имя пользователя и пароль не установлены\nисправление",
88
- "pt": "impedir o login se nenhum nome de usuário e senha estiver definido\ncorrigir os testes",
89
- "nl": "login voorkomen als er geen gebruikersnaam en wachtwoord is ingesteld\nvastleggen van tests",
90
- "fr": "empêcher le login si aucun nom d'utilisateur et mot de passe n'est défini\nessais de correction",
91
- "it": "impedire il login se non viene impostato nessun nome utente e password\ntest di correzione",
92
- "es": "previene el inicio de sesión si no se establece el nombre de usuario y la contraseña\npruebas de reparación",
93
- "pl": "zapobiec logowaniu, jeśli nie jest ustawiona nazwa użytkownika i hasło\nbadania naprawcze",
94
- "uk": "заборонити логін, якщо не встановлено ім’я користувача та пароль\nфіксувати тести",
95
- "zh-cn": "如果没有设置用户名和密码, 请防止登录\n固定测试"
96
96
  }
97
97
  },
98
98
  "titleLang": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.google-sharedlocations2",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Share your location with iobroker via google maps.",
5
5
  "author": {
6
6
  "name": "Garfonso",
package/src/lib/Cookie.ts CHANGED
@@ -314,6 +314,7 @@ export class Cookie {
314
314
  /**
315
315
  * Refresh the current cookie by using puppeteer to load Google Maps with existing cookie.
316
316
  *
317
+ * @param withCookies - if true, will try to set existing cookies in browser before loading page, default is false. This can help if cookies are still valid but not complete enough to work without browser session.
317
318
  * @returns true if refresh was successful
318
319
  */
319
320
  async refreshCookieWithBrowser(withCookies: boolean = false): Promise<boolean> {
@@ -376,21 +377,25 @@ export class Cookie {
376
377
 
377
378
  /**
378
379
  * Login to Google using puppeteer to get new cookies.
380
+ *
381
+ * @param forceLogin - if true, will try to login even if current cookie seems valid, default is false
379
382
  */
380
- async loginToGetNewCookies(): Promise<boolean> {
383
+ async loginToGetNewCookies(forceLogin: boolean = false): Promise<boolean> {
381
384
  let currentStep;
382
385
  try {
383
386
  // try to refresh cookie from browser session first:
384
- let result = await this.refreshCookieWithBrowser();
385
- if (result) {
386
- this.log.info('Cookie refresh successful, no need to login again.');
387
- return true;
388
- } else if (this.isValid()) {
389
- this.log.info('Current cookie seems valid, trying refresh.');
390
- result = await this.refreshCookieWithBrowser(true);
387
+ if (!forceLogin) {
388
+ let result = await this.refreshCookieWithBrowser();
391
389
  if (result) {
392
- this.log.info('Cookie refresh with existing cookies successful, no need to login again.');
390
+ this.log.info('Cookie refresh successful, no need to login again.');
393
391
  return true;
392
+ } else if (this.isValid()) {
393
+ this.log.info('Current cookie seems valid, trying refresh.');
394
+ result = await this.refreshCookieWithBrowser(true);
395
+ if (result) {
396
+ this.log.info('Cookie refresh with existing cookies successful, no need to login again.');
397
+ return true;
398
+ }
394
399
  }
395
400
  }
396
401
 
@@ -416,6 +421,13 @@ export class Cookie {
416
421
  currentStep = msg;
417
422
  this.log.debug(msg);
418
423
  };
424
+
425
+ if (forceLogin) {
426
+ logDebug('Force login enabled, clearing cookies and local storage.');
427
+ const cookies = await this.browser!.cookies();
428
+ await this.browser!.deleteCookie(...cookies);
429
+ }
430
+
419
431
  logDebug('going to google login page.');
420
432
  await page.goto(
421
433
  'https://accounts.google.com/ServiceLogin?hl=de&continue=https://www.google.com/maps&gae=cb-eomtm',
package/src/main.ts CHANGED
@@ -141,6 +141,9 @@ export class GoogleSharedlocations2 extends utils.Adapter {
141
141
  await this.setState('info.connection', false, true);
142
142
  if (this._successFullPolls > 0) {
143
143
  //try to get new cookie:
144
+ this.log.debug(
145
+ `Polling failed, trying to obtain new cookies, because got ${this._successFullPolls} valid results before.`,
146
+ );
144
147
  this._successFullPolls = 0;
145
148
  await this.cookie.loginToGetNewCookies();
146
149
  }
@@ -365,7 +368,7 @@ export class GoogleSharedlocations2 extends utils.Adapter {
365
368
  this.log.info('Current cookies state was cleared, trying to obtain new cookies.');
366
369
  this._successFullPolls = 0;
367
370
  this.cookie.readCookieFromString(''); //clear old cookie
368
- await this.cookie.loginToGetNewCookies();
371
+ await this.cookie.loginToGetNewCookies(true);
369
372
  } else {
370
373
  this.log.info(
371
374
  'Current cookies state was changed from outside the adapter, updating internal cookie store.',