I’m currently struggling to figure out how to store (e.g. in LocalStorage; essentially the thing that ipfs does automagically if you give it a repo option) the (otherwise autogenerated) peerId and keypair across browser reloads.
and every time i press ctrl+r i get a new peerId, but i’d like the option to a) automatically store&reload that (via cookie, localStorage, or whatever), and b) also get a json representation or similar for the user to manually back up and paste back into my app (in case the browser profile wiped or something)
I looked into peer-id-factory a bit, but couldn’t quite wrap my head around that either, and frankly i’m rather baffled i can’t find anything related to this on e.g. google (or here, for that matter); it kinda feels like a pretty common thing to do.
i mean, i can also store keys on a piece of paper, but that’s not what i’m asking (and also i doubt i’d want/need the crypto api for any of this, but that’s beside the point).
what i’m asking is how to teach libp2p about me wanting to store keys.
as in:
how do i tell it to load a key if it exists
how do i tell it to create a key if it doesn’t
does it do that itself (like js-ipfs option repo) in any way? do i get a “i just generated a key for you” event if i don’t specify any? etc