dchristl / macless-haystack

Create your own AirTag with OpenHaystack, but without the need to own an Apple device
GNU General Public License v3.0
408 stars 66 forks source link

Importing my JSON file fails #18

Closed johnbaker26222 closed 1 year ago

johnbaker26222 commented 1 year ago

When running the python simplehttp server locally on my machine, I cannot import my JSON file. I can see my accessories after selecting the file, but when I click on import I go back to "There is nothing here yet add accessories to continue" Not seeing any errors in the terminal. Do I need to place my JSON file somewhere in the web directory before running the http server?

dchristl commented 1 year ago

Hello @johnbaker26222 ,

have you pressed the import button in the upper right corner, too?

image

If you go back (upper left) all changes are discarded.

johnbaker26222 commented 1 year ago

Hey thanks for the quick response. Yes clicked the import button and it takes me back with no accessories

johnbaker26222 commented 1 year ago

I also cannot create a new accessory

dchristl commented 1 year ago
johnbaker26222 commented 1 year ago

How many keys have you generated? 6

How long have you waited after the import? it immediately goes to the page with no accessories

Is your fetch-location service running? john@Johns-Mac-mini webserver % Using python2 serving at port 6176

Do you have any plugins, blocker in your browser? Can you try a different one? I tried chrome and firefox same same

Do you see any errors in the console of your Browser (normally F12)? main.dart.js:4720 Uncaught TypeError: Cannot read properties of undefined (reading 'generateKey') at main.dart.js:94267:36 at aLm.a (main.dart.js:5999:62) at aLm.$2 (main.dart.js:43271:14) at Object.G (main.dart.js:5985:10) at ah5.acr (main.dart.js:94279:10) at ah5.oC (main.dart.js:94247:21) at main.dart.js:94291:14 at aLm.a (main.dart.js:5999:62) at aLm.$2 (main.dart.js:43271:14) at Object.G (main.dart.js:5985:10)

Do you have the same result at my Github-Page? When I usee your page it will import. But I cannot get it to fetch location data. I get this error in the console of browser: Uncaught Error at Object.aW4 (main.dart.js:7570:24) at aby.$1 (main.dart.js:101402:53) at aH5.aAL (main.dart.js:46775:34) at aH5.O0 (main.dart.js:46777:21) at aDg.$0 (main.dart.js:46070:11) at Object.Bq (main.dart.js:6346:40) at aq.oQ (main.dart.js:45999:3) at Object.ben (main.dart.js:6446:8) at auI.$1 (main.dart.js:46227:9) at aCo.$1 (main.dart.js:50573:21)

johnbaker26222 commented 1 year ago

When using your page I this error appeared in the chrome console: main.dart.js:49845 Mixed Content: The page at 'https://dchristl.github.io/headless-haystack/#/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://<myip>:6176/'. This request has been blocked; the content must be served over HTTPS. So running chrome with the --allow-running-insecure-content fixed the error and everything worked as it should. So fetching is OK. Not sure what is going on with my local version. I'm not sure how I'm going to run chrome insecurely on my mobile device though. Is there any way you could host an http version of your page? or implement an SSL connnection for my fetching service?

dchristl commented 1 year ago

OK, I see the problem here. It is because the fetch location service is not served over https, but the github page or your local webserver is. I will have a deeper look into this next week, but it is not so easy to solve. The main problem is that you need a certificate for the fetch location service to avoid the error.

johnbaker26222 commented 1 year ago

Ok thanks any idea what is causing this error in my local instance? Uncaught TypeError: Cannot read properties of undefined (reading 'generateKey')

dchristl commented 1 year ago

Sorry, but I have no idea why you have this issue. I've set up a whole new system and followed the guide, downloaded the latest webserver-release and everything works like expected. The only thing you can try is to check all the files with my output:

user@users-iMac-Pro webserver % ls -lR
total 24
-rwxrwxr-x   1 user  staff  3744 Apr 17 19:44 FindMy_proxy.py
-rw-rw-r--   1 user  staff  8073 Apr 13 17:51 apple_cryptography.py
drwxrwxr-x  13 user  staff   416 Apr 17 19:43 web

./web:
total 6480
drwxrwxr-x  7 user  staff      224 Apr 17 19:43 assets
drwxrwxr-x  5 user  staff      160 Apr 17 19:42 canvaskit
-rw-rw-r--  1 user  staff      917 Apr 17 19:43 favicon.png
-rw-rw-r--  1 user  staff    13910 Apr 17 19:42 flutter.js
-rw-rw-r--  1 user  staff     7269 Apr 17 19:43 flutter_service_worker.js
drwxrwxr-x  6 user  staff      192 Apr 17 19:43 icons
-rw-rw-r--  1 user  staff     3855 Apr 17 19:43 index.html
-rw-rw-r--  1 user  staff  3274638 Apr 17 19:43 main.dart.js
-rw-rw-r--  1 user  staff      927 Apr 17 19:43 manifest.json
-rw-rw-r--  1 user  staff       85 Apr 17 19:43 version.json

./web/assets:
total 1784
-rw-rw-r--  1 user  staff      63 Apr 17 19:43 AssetManifest.json
-rw-rw-r--  1 user  staff      82 Apr 17 19:43 FontManifest.json
-rw-rw-r--  1 user  staff  904025 Apr 17 19:43 NOTICES
drwxrwxr-x  3 user  staff      96 Apr 17 19:43 assets
drwxrwxr-x  3 user  staff      96 Apr 17 19:43 fonts

./web/assets/assets:
total 400
-rw-rw-r--  1 user  staff  204339 Apr 17 19:43 OpenHaystackIcon.png

./web/assets/fonts:
total 3216
-rw-rw-r--  1 user  staff  1645184 Apr 17 19:43 MaterialIcons-Regular.otf

./web/canvaskit:
total 13632
-rw-rw-r--  1 user  staff   127110 Apr 17 19:42 canvaskit.js
-rw-rw-r--  1 user  staff  6845886 Apr 17 19:42 canvaskit.wasm
drwxrwxr-x  4 user  staff      128 Apr 17 19:42 profiling

./web/canvaskit/profiling:
total 18040
-rw-rw-r--  1 user  staff   247863 Apr 17 19:42 canvaskit.js
-rw-rw-r--  1 user  staff  8985203 Apr 17 19:42 canvaskit.wasm

./web/icons:
total 104
-rw-rw-r--  1 user  staff   5292 Apr 17 19:43 Icon-192.png
-rw-rw-r--  1 user  staff   8252 Apr 17 19:43 Icon-512.png
-rw-rw-r--  1 user  staff   5594 Apr 17 19:43 Icon-maskable-192.png
-rw-rw-r--  1 user  staff  20998 Apr 17 19:43 Icon-maskable-512.png

Maybe there is an error.

The Https-problem occurs if the host is not localhost. This works - of course - only if the virtual MacOS and the application is on the same machine. I will try to figure out a solution for other hosts in your network. This will take a bit, because the user have to provide its own certificate.

Sorry, but I can't (and want) disable the SSL encryption on the GitHub-page.

johnbaker26222 commented 1 year ago

Thanks for that I do indeed have all of those files so who knows why my accessories will not import when I run a local server. I did find a work around for the SSL error. I generated valid certs using letsencrypt and used those with stunnel to intercept the traffic from the FindMyproxy and convert to SSL so the browser would stop complaining. This seems to have worked so I finally have a way to track on my mobile devices. Next up is to write a python script to send me telegram notifications when my accessories move more than a few KM. Thanks so much for you work here!

dchristl commented 1 year ago

FYI: I've added a section about the problem as last paragraph of set up your virtual or real MAC - section. This works with self signed certificates (included), too. Although your solution is a way better, but harder to set up for the most users, especially when server names changes (internal and external name).

I will close this issue now, if you have a follow up problem/ question, just create a new one. Thanks

johnbaker26222 commented 1 year ago

Awesome thanks for taking the time to fix this!! When my cert expire I’ll do the self signed method

On Mon, Jul 3, 2023 at 22:52, dchristl @.***(mailto:On Mon, Jul 3, 2023 at 22:52, dchristl < wrote:

FYI: I've added a section about the problem as last paragraph of set up your virtual or real MAC - section. This works with self signed certificates (included), too. Although your solution is a way better, but harder to set up for the most users, especially when server names changes (internal and external name).

I will close this issue now, if you have a follow up problem/ question, just create a new one. Thanks

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>