Hello!
How I can save data on itch.io ? Cookies, Local storage is bad idea, cause uploading a new build of your game changes the path it lives on.
So what to do?
Yes, what's really needed is for Itch to provide a signed token giving the user's account ID (and possibly other details if the user agrees to share them). I know there is a way to use such a token with Firebase and probably there is with PlayFab too.
A related problem is that there is no way for an HTML game to know if the user has paid. I will soon be uploading a new version of Gwen which will be chargeable after a short taster. It interfaces with PayPal entirely on its own because while I could set the game page to accept payments, there is no way for the game to be notified of them.
Can I get some clarity here: I have a web game hosted at https://codedread.itch.io - I understand that underneath it's an iframe (https://html-classic.itch.zone/html/(some number)/ as I update my web game, am I likely to lose that underlying origin such that anything stored in IndexedDB is lost?
I don't know if the iframe URL is likely to change, but one thing you can do is redirect the user to a domain you control. You upload a single HTML file to Itch, which contains some Javascript that redirects to the URL where your game is actually hosted. You can choose to change only the iframe URL, in which case the game will still be embedded in your Itch page, or you can redirect the whole page when the user clicks the Play button.
One recent nuisance is that Safari has started deleting sites' saved data if they're not used for a week (for "privacy"). There may be additional restrictions on iframes in Safari and other browsers—I vaguely remember something about that, because of them being used for cross-site tracking. To avoid all this, I'm moving saved games to the server, and I'm working on a system which will provide one-click sign-up with no personal data collection. There's no reason why I shouldn't make it available to other people too, once it's done, so if you'd be interested in this route let me know and I'll keep you updated.
I like your idea, but upon testing it, unless I redirect the entire page to my host, the IndexedDB instance is not shared, despite the iframe hosted at itch.io pointing to the same site. This was surprising to me.
I'd rather keep the itch.io link stable. I think I'll cross my fingers that itch.io doesn't change the underlying iframe host they control. I use the Google Drive API to host saved games so that's also an option for players.